Crutch
Well-known member
From memory (I haven’t used CodeWarrior in a few years), CodeWarrior lets you write whole functions in assembly, if desired, but not use assembly instructions inside C functions.
In (at least) the System 6-7 era, the best choice for 68K assembly embedded in a C program was THINK C, which lets you sprinkle assembly anywhere you like in a very well-integrated way. For example, say you have patched an OS trap that takes a param in d0, and you have stored its address in oldAddr. You can cleanly head-patch it from C code (such that the trap doesn’t see your patch as a return address on the stack) like this:
You can also use goto to jump into asm blocks, use an asm block as a secondary entry point to a function different from the one currently executing (a very powerful/dangerous feature!), and do many other nifty things. (You can only do this from C code, not from inside a C++ code file.)
It doesn’t let you assemble “bare” assembly programs, that’s true, though I’m not sure if this is ever strictly necessary. You could if desired put all of your code inside one giant asm{…} block!
In (at least) the System 6-7 era, the best choice for 68K assembly embedded in a C program was THINK C, which lets you sprinkle assembly anywhere you like in a very well-integrated way. For example, say you have patched an OS trap that takes a param in d0, and you have stored its address in oldAddr. You can cleanly head-patch it from C code (such that the trap doesn’t see your patch as a return address on the stack) like this:
C:
long foo;
Ptr oldAddr;
…
if (foo < 6)
asm {
move.l oldAddr, a0
move.l foo, d0 // contents of foo are now in d0
unlk // clean up your stack frame; RTS from the code at a0 will return directly to our caller
jmp (a0)
// never get here
}
You can also use goto to jump into asm blocks, use an asm block as a secondary entry point to a function different from the one currently executing (a very powerful/dangerous feature!), and do many other nifty things. (You can only do this from C code, not from inside a C++ code file.)
It doesn’t let you assemble “bare” assembly programs, that’s true, though I’m not sure if this is ever strictly necessary. You could if desired put all of your code inside one giant asm{…} block!
Last edited: