]> git.sur5r.net Git - cc65/blob - libsrc/runtime/pushax.s
Fixed a bug
[cc65] / libsrc / runtime / pushax.s
1 ;
2 ; Ullrich von Bassewitz, 26.10.2000
3 ;
4 ; CC65 runtime: Push value in a/x onto the stack
5 ;
6
7         .export         push0, pusha0, pushax
8         .importzp       sp
9
10 push0:  lda     #0
11 pusha0: ldx     #0
12
13 ; This function is used *a lot*, so don't call any subroutines here.
14 ; Beware: The value in ax must not be changed by this function!
15 ; Beware^2: The optimizer knows about the value of Y after the function
16 ;           returns!
17
18 .proc   pushax
19
20         pha
21         lda     sp
22         sec
23         sbc     #2
24         sta     sp              ; (13)
25         bcs     @L1
26         dec     sp+1
27 @L1:    ldy     #1
28         txa                     ; (20)
29         sta     (sp),y
30         pla
31         dey
32         sta     (sp),y          ; (38)
33         rts
34
35 .endproc