]> git.sur5r.net Git - cc65/blob - libsrc/runtime/add.s
added sleep() implementation
[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 tosadda0:
14         ldx     #0
15 tosaddax:
16         clc
17 .ifpc02
18         adc     (sp)            ; 65C02 version - saves 2 cycles
19         ldy     #1
20 .else
21         ldy     #0
22         adc     (sp),y          ; lo byte
23         iny
24 .endif
25         pha                     ; save it
26         txa
27         adc     (sp),y          ; hi byte
28         tax
29         clc
30         lda     sp
31         adc     #2
32         sta     sp
33         bcc     L1
34         inc     sp+1
35 L1:     pla                     ; Restore low byte
36         rts
37