4 ; Support for setjmp and longjmp
9 ;----- Standard header ------------------------------------------------------
16 ;----- Main code ------------------------------------------------------------
18 AREA |Sapphire$$Code|,CODE,READONLY
22 ; On entry: R0 == pointer to setjmp block
26 ; Use: Fills a jmp_buf with useful information
31 SWI XFPEmulator_Version ;Do we have FP available?
32 MOVVS R12,#0 ;No -- remember this
33 STRVS R12,[R0,#84] ;Store the value away
34 STFVCE F4,[R0],#12 ;Store FP registers
38 STMIA R0,{R4-R11,R13,R14} ;Store lots of stuff
39 MOV R0,#0 ;Return zero
40 MOVS PC,R14 ;And return to caller
46 ; On entry: R0 == pointer to jmp_buf block
49 ; On exit: R0 == R1 on entry, or 1 if R1 was 0
51 ; Use: Returns to a setjmp position.
56 LDR R14,[R0,#84] ;Load the final word out
57 CMP R14,#0 ;Is it defined there?
58 LDFNEE F4,[R0],#12 ;Load FP registers back
62 LDMIA R0,{R4-R14} ;Restore old registers
63 MOVS R0,R1 ;Get the return value
64 MOVEQ R0,#1 ;If it was zero, fiddle it
65 MOVS PC,R14 ;And return to `caller'
69 ;----- That's all, folks ----------------------------------------------------