hello all,
i need to mix a C program with a asm game. From the asm code , i need to call functions of the C program. I was thinking using the Trap opcode.
As i don't need to return to the asm program (no RTE) , i'll do a SP+6 in my trap handler.
Do i need to do something more ? good or bad idea to use trap ?
thanks
Trap
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Bad idea - just go with the C ABI. The 68000 ABI is save all regs other than d0-d1/a0-a1, and all args go on the stack as longs, regardless of size. Trap, as with all exceptions on the 68000, is slow, taking far longer to dispatch than a simple jsr. If the function never returns, a simple jmp is even faster!
Re: Trap
Depending on the compiler you use, you can inter-mix the C code with assembly. GCC's register ops is a bit funky but it can be done.Pascal wrote:hello all,
i need to mix a C program with a asm game. From the asm code , i need to call functions of the C program. I was thinking using the Trap opcode.
As i don't need to return to the asm program (no RTE) , i'll do a SP+6 in my trap handler.
Do i need to do something more ? good or bad idea to use trap ?
thanks
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Re: Trap
Just put "--register-prefix-optional" in the command line and forget the funk.plee wrote:Depending on the compiler you use, you can inter-mix the C code with assembly. GCC's register ops is a bit funky but it can be done.