]> git.sur5r.net Git - cc65/blob - libsrc/runtime/lcmp.s
Working
[cc65] / libsrc / runtime / lcmp.s
1 ;
2 ; Ullrich von Bassewitz, 10.12.1998
3 ;
4 ; Long int compare function - used by the compare operators
5 ;
6
7         .export         toslcmp
8         .import         incsp4
9         .importzp       sp, sreg, ptr1
10
11
12 toslcmp:
13         sta     ptr1
14         stx     ptr1+1          ; EAX now in sreg:ptr1
15
16         ldy     #$03
17         lda     (sp),y
18         cmp     sreg+1
19         bne     L4
20
21         dey
22         lda     (sp),y
23         cmp     sreg
24         bne     L1
25
26         dey
27         lda     (sp),y
28         cmp     ptr1+1
29         bne     L1
30
31         dey
32         lda     (sp),y
33         cmp     ptr1
34
35 L1:     php                     ; Save flags
36         jsr     incsp4          ; Drop TOS
37         plp                     ; Restore the flags
38         beq     L2
39         bcs     L3
40         lda     #$FF            ; Set the N flag
41 L2:     rts
42
43 L3:     lda     #$01            ; Clear the N flag
44         rts
45
46 L4:     php                     ; Save flags
47         jsr     incsp4          ; Drop TOS
48         plp                     ; Restore flags
49         rts
50
51