]> git.sur5r.net Git - cc65/blob - libsrc/runtime/sub.s
Merge pull request #740 from laubzega/master
[cc65] / libsrc / runtime / sub.s
1 ;
2 ; Ullrich von Bassewitz, 05.08.1998
3 ;
4 ; CC65 runtime: sub ints
5 ;
6
7         .export         tossuba0, tossubax
8         .import         addysp1
9         .importzp       sp
10
11         .macpack        cpu
12
13 ; AX = TOS - AX
14
15 tossuba0:
16         ldx     #0
17 tossubax:
18         sec
19         eor     #$FF
20 .if (.cpu .bitand CPU_ISET_65SC02)
21         adc     (sp)
22         ldy     #1
23 .else
24         ldy     #0
25         adc     (sp),y          ; Subtract low byte
26         iny
27 .endif
28         pha                     ; Save high byte
29         txa
30         eor     #$FF
31         adc     (sp),y          ; Subtract high byte
32         tax                     ; High byte into X
33         pla                     ; Restore low byte
34         jmp     addysp1         ; drop TOS
35