]> git.sur5r.net Git - cc65/blob - libsrc/runtime/pushax.s
goto.c warning fix for implicit truncation
[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                     ; (3)
21         lda     sp              ; (6)
22         sec                     ; (8)
23         sbc     #2              ; (10)
24         sta     sp              ; (13)
25         bcs     @L1             ; (17)
26         dec     sp+1            ; (+5)
27 @L1:    ldy     #1              ; (19)
28         txa                     ; (21)
29         sta     (sp),y          ; (27)
30         pla                     ; (31)
31         dey                     ; (33)
32         sta     (sp),y          ; (38)
33         rts                     ; (44)     
34
35 .endproc