• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Macintosh toolbox assembly reference?

rafthe030

Active member
Well. Lately I've been studying 68k assembly. I find it a lot harder to understand than my ol' Netronics Cosmac Elf II's 8-bit RCA 1802 in hex. Still, i really want to start developing stuff.

I can find much of the 68k instruction set reference on many website but, there aren't many about the macintosh toolbox. Most of them (like Inside Mac pdf's) got reference about using the toolbox with C and Pascal, and almost no assembly reference. It leaves me with unanswered interrogations about it. With some hope i searched in some forums on here but did not found what i was seeking out. I am mostly looking for the traps's Input/output, etc (Axxx).

The assembler i am using is Lightsoft's Fantasm 6 ( which has become free) with Anvil.

So, if you have any suggestions like books or online resources for me, could you post it here?

Thanks for replies!  :)

Edit: I specified more what i am searching for.

 
Last edited by a moderator:

bigmessowires

Well-known member
I'll open my mouth, even though I don't have anything really useful to offer.

As far as I'm aware, the toolbox traps are basically designed for use with Pascal and C code, so they all use a consistent calling convention. Offhand I don't know what that convention is, but if you can't find it documented anywhere, you should be able to figure it out by examining the disassembly of a couple of toolbox routines.

Typically the calling convention has the arguments all pushed on the stack, either in left-to-right or right-to-left order as they appear in the trap function prototype. Possibly the first argument is passed in a register instead of on the stack. Then the return value (if any) is either returned on the top of the stack, or in a register. I seem to dimly recall that the Mac toolbox traps return their result in D0, but I may be wrong.

Once you figure this out, you should be able to use this calling convention and the normal Inside Macintosh documentation to call any toolbox trap from your assembly programs.

 

rafthe030

Active member
Even though you say you don't really have anything useful to offer, it illuminates me a bit. I'll try re-reading the documentation for a while and make various attempts to get it to work.

 

Gryphel

Active member
Many of the Macintosh toolbox traps use the Pascal calling convention, documented in the pdf Mac OS Runtime Architectures from Apple, in chapter 11.

Some of the traps don't use this calling convention. These tend to be documented in Inside Mac (see my list of Apple Developer Documentation, and search for the word "download"). The documentation for such traps have a section labeled "ASSEMBLY-LANGUAGE INFORMATION".

 

Gryphel

Active member
Also, the Trap Manager chapter (of the Operating System Utilities section of the Inside Mac pdf files) gives a lot of information about trap dispatching, including calling conventions.

 
Top