CompuServe Thread

Forum unknown · Software

setjmp.asm

1 messages in this thread
#4416From: GARY SARFFJan 6, 1986 4:49 PM
The code for setjmp.asm does save the context in the buffer that you provide, you must provide the ADDRESS of the buffer. The code is: _setjmp: movea.l (sp)+,a1 get return address from top of stack and save it in a1 and increment stack pointer 4 bytes movea.l (sp),a0 get address of user's buffer. movem.l sp-a1/d7-d2,(a0) and save registers in user's buffer. jmp (a1) return to caller of setjmp. _longjmp: movea.l 4(sp),a0 address of user's buffer into a0 move.l 8(sp),d0 return code to be handed back. movem.l (a0),sp-a1/d7-d2 restore from user's buffer. jmp (a1) return to the instruction after the most recent call to setjmp with return code in d0. Perhaps the confusion is in (sp) is the word the stack pointer points to, not the value of the stack pointer itself. I've used this code on the Amiga in my program I'm working on, so I know it works, just call with setjmp(your_buffer_address) and longjmp(your_buffer_address,your_return_code) and it should work.