]> git.sur5r.net Git - cc65/blob - libsrc/runtime/icmp.s
Added mouse module from C64
[cc65] / libsrc / runtime / icmp.s
1 ;
2 ; Ullrich von Bassewitz, 10.12.1998
3 ;
4 ; Integer compare function - used by the compare operators
5 ;
6
7         .export         tosicmp
8         .importzp       sp, sreg
9
10
11 tosicmp:
12         sta     sreg
13         stx     sreg+1          ; Save ax
14
15         ldy     #$01
16         lda     (sp),y          ; Get high byte
17         tax
18         dey
19         lda     (sp),y          ; Get low byte
20
21 ; Inline incsp2 for better performance
22
23         inc     sp              ; 5
24         bne     @L1             ; 3
25         inc     sp+1            ; (5)
26 @L1:    inc     sp              ; 5
27         bne     @L2             ; 3
28         inc     sp+1            ; (5)
29
30 ; Do the compare.
31
32 @L2:    cpx     sreg+1          ; Compare high byte
33         bne     @L3
34         cmp     sreg            ; Compare low byte
35         beq     @L3
36         bcs     @L4
37         lda     #$FF            ; Set the N flag
38 @L3:    rts
39
40 @L4:    lda     #$01            ; Clear the N flag
41         rts
42
43