]> git.sur5r.net Git - cc65/blob - libsrc/common/setjmp.s
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / libsrc / common / setjmp.s
1 ;
2 ; Ullrich von Bassewitz, 06.06.1998
3 ;
4 ; int setjmp (jmp_buf buf);
5 ;
6
7         .export         __setjmp
8         .importzp       sp, ptr1
9
10 __setjmp:
11         sta     ptr1            ; Save buf
12         stx     ptr1+1
13         ldy     #0
14
15 ; The parameter stack is now empty, put it into buf
16
17         lda     sp
18         sta     (ptr1),y
19         iny
20         lda     sp+1
21         sta     (ptr1),y
22         iny
23
24 ; Put the return stack pointer next
25
26         tsx
27         inx
28         inx                     ; drop return address
29         txa
30         sta     (ptr1),y
31         iny
32
33 ; Last thing is the return address.
34
35         pla
36         tax
37         pla
38         sta     (ptr1),y        ; high byte first
39         iny
40         pha
41         txa
42         sta     (ptr1),y
43         pha
44
45 ; Return zero
46
47         lda     #0
48         tax
49         rts
50
51
52