68kMLA Classic Interface

This is a version of the 68kMLA forums for viewing on your favorite old mac. Visitors on modern platforms may prefer the main site.

Click here to select a new forum.
Macintosh toolbox assembly reference?
Posted by: rafthe030 on 2014-12-28 16:50:42
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.

Posted by: bigmessowires on 2014-12-28 17:27:00
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.

Posted by: rafthe030 on 2014-12-28 19:23:16
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.

Posted by: uniserver on 2014-12-28 19:37:26
steve is quite a humble guy 🙂

Posted by: Gryphel on 2014-12-28 20:28:39
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".

Posted by: Gryphel on 2014-12-28 20:44:16
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.

Posted by: CC_333 on 2014-12-28 22:23:48
steve is quite a humble guy 🙂
I agree wholeheartedly, especially after meeting him.

I did some reading, and I must say, he's SUPER humble!

c

Posted by: bigmessowires on 2014-12-28 23:05:10
steve is quite a humble guy
Well, I do have "Steve is great" engraved on the frame of my glasses:

1982339_10152076527024538_140209182_n.jpg

More helpfully, I think the info that Gryphel linked is what the original poster was searching for.

Posted by: rafthe030 on 2014-12-29 00:36:59
Yes, it is. Thanks a lot!

1