]> git.sur5r.net Git - cc65/blob - libsrc/runtime/toslong.s
Splitted the lconvert module into three smaller ones to allow for smaller
[cc65] / libsrc / runtime / toslong.s
1 ;
2 ; Ullrich von Bassewitz, 25.10.2000
3 ;
4 ; CC65 runtime: Convert tos from int to long
5 ;
6
7         .export         tosulong, toslong
8         .import         decsp2
9         .importzp       sp
10
11 ; Convert TOS from int to long
12
13 tosulong:
14         pha
15         jsr     decsp2          ; Make room
16         ldy     #2
17         lda     (sp),y
18         ldy     #0
19         sta     (sp),y
20         ldy     #3
21         lda     (sp),y
22         ldy     #1
23         sta     (sp),y
24         lda     #0              ; Zero extend
25 toslong2:
26         iny
27         sta     (sp),y
28         iny
29         sta     (sp),y
30         pla
31         rts
32
33 toslong:
34         pha
35         jsr     decsp2          ; Make room
36         ldy     #2
37         lda     (sp),y
38         ldy     #0                 
39         sta     (sp),y
40         ldy     #3
41         lda     (sp),y
42         bmi     toslong1
43         ldy     #1
44         sta     (sp),y
45         lda     #$00            ; Positive, high word is zero
46         bne     toslong2
47 toslong1:
48         ldy     #1
49         sta     (sp),y
50         lda     #$FF
51         bne     toslong2
52