]> git.sur5r.net Git - cc65/blob - libsrc/common/_sys.s
Working on the _scanf implementation
[cc65] / libsrc / common / _sys.s
1 ;
2 ; void __fastcall__ _sys (struct regs* r);
3 ;
4 ; Ullrich von Bassewitz, 16.12.1998
5 ;
6
7         .export         __sys
8         .import         jmpvec
9         .importzp       ptr1
10
11
12 __sys:  sta     ptr1
13         stx     ptr1+1          ; Save the pointer to r
14
15 ; Fetch the PC and store it into the jump vector
16
17         ldy     #5
18         lda     (ptr1),y
19         sta     jmpvec+2
20         dey     
21         lda     (ptr1),y
22         sta     jmpvec+1
23
24 ; Get the flags, mask unnecessary bits and push them. Push a
25
26         dey
27         lda     (ptr1),y
28         and     #%11001011
29         pha
30         ldy     #0
31         lda     (ptr1),y
32         pha
33
34 ; Get and assign X and Y
35
36         iny
37         lda     (ptr1),y
38         tay
39         iny
40         lda     (ptr1),y
41         tay
42
43 ; Set a and the flags, call the machine code routine
44
45         pla
46         plp
47         jsr     jmpvec
48
49 ; Back from the routine. Save the flags and a
50
51         php
52         pha
53
54 ; Put the register values into the regs structure
55
56         tya
57         ldy     #2
58         sta     (ptr1),y
59         dey
60         txa
61         sta     (ptr1),y
62         dey
63         pla
64         sta     (ptr1),y
65         ldy     #3
66         pla
67         sta     (ptr1),y
68
69 ; Done
70
71         rts
72