2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 06.06.1998
|
|
|
|
;
|
|
|
|
; int setjmp (jmp_buf buf);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export __setjmp
|
|
|
|
.importzp sp, ptr1
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
__setjmp:
|
2013-05-09 11:56:54 +00:00
|
|
|
sta ptr1 ; Save buf
|
|
|
|
stx ptr1+1
|
|
|
|
ldy #0
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; The parameter stack is now empty, put it into buf
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
lda sp
|
|
|
|
sta (ptr1),y
|
|
|
|
iny
|
|
|
|
lda sp+1
|
|
|
|
sta (ptr1),y
|
|
|
|
iny
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; Put the return stack pointer next
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
tsx
|
|
|
|
inx
|
|
|
|
inx ; drop return address
|
|
|
|
txa
|
|
|
|
sta (ptr1),y
|
|
|
|
iny
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; Last thing is the return address.
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
pla
|
|
|
|
tax
|
|
|
|
pla
|
|
|
|
sta (ptr1),y ; high byte first
|
|
|
|
iny
|
|
|
|
pha
|
|
|
|
txa
|
|
|
|
sta (ptr1),y
|
|
|
|
pha
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; Return zero
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #0
|
|
|
|
tax
|
|
|
|
rts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|