]> git.sur5r.net Git - cc65/blob - libsrc/runtime/lrsub.s
goto.c warning fix for implicit truncation
[cc65] / libsrc / runtime / lrsub.s
1 ;
2 ; Ullrich von Bassewitz, 05.08.1998
3 ; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
4 ;
5 ; CC65 runtime: long sub reversed
6 ;
7
8 ;
9 ; EAX = EAX - TOS
10 ;
11         .export         tosrsub0ax, tosrsubeax
12         .import         addysp1
13         .importzp       sp, sreg, tmp1
14
15         .macpack        cpu
16
17 tosrsub0ax:
18 .if (.cpu .bitand ::CPU_ISET_65SC02)
19         stz     sreg
20         stz     sreg+1
21 .else
22         ldy     #$00
23         sty     sreg
24         sty     sreg+1
25 .endif
26
27 tosrsubeax:
28         sec
29 .if (.cpu .bitand ::CPU_ISET_65SC02)
30         sbc     (sp)
31         ldy     #1
32 .else                         
33         ldy     #0
34         sbc     (sp),y          ; byte 0
35         iny
36 .endif
37         sta     tmp1            ; use as temp storage
38         txa
39         sbc     (sp),y          ; byte 1
40         tax
41         iny
42         lda     sreg
43         sbc     (sp),y          ; byte 2
44         sta     sreg
45         iny
46         lda     sreg+1
47         sbc     (sp),y          ; byte 3
48         sta     sreg+1
49         lda     tmp1
50         jmp     addysp1         ; drop TOS
51