CompuServe Messages

setjmp.asm

#: 4416 S1/SoftwareForum unknown
    06-Jan-86 16:49:31
Sb: setjmp.asm
Fm: GARY SARFF 70167,2216
To: steve poling 70177,1434

This message turned up in search, but its forum couldn’t be identified from the original transcript, so it may not be linked into its thread.

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.