]> git.sur5r.net Git - cc65/blob - libsrc/runtime/add.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / runtime / add.s
1 ;
2 ; Ullrich von Bassewitz, 05.08.1998
3 ;
4 ; CC65 runtime: add ints
5 ;
6
7 ; Make this as fast as possible, even if it needs more space since it's
8 ; called a lot!
9
10         .export         tosadda0, tosaddax
11         .importzp       sp
12
13         .macpack        cpu
14
15 tosadda0:
16         ldx     #0
17 tosaddax:
18         clc
19 .if (.cpu .bitand CPU_ISET_65SC02)
20         adc     (sp)            ; 65SC02 version - saves 2 cycles
21         ldy     #1
22 .else
23         ldy     #0
24         adc     (sp),y          ; lo byte
25         iny
26 .endif
27         pha                     ; save it
28         txa
29         adc     (sp),y          ; hi byte
30         tax
31         clc
32         lda     sp
33         adc     #2
34         sta     sp
35         bcc     L1
36         inc     sp+1
37 L1:     pla                     ; Restore low byte
38         rts
39