]> git.sur5r.net Git - cc65/blob - libsrc/runtime/icmp.s
Remove bash pecularities.
[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         .import         incsp2
9         .importzp       sp, sreg
10
11
12 tosicmp:
13         sta     sreg
14         stx     sreg+1          ; Save ax
15
16         ldy     #$01
17         lda     (sp),y          ; Get high byte
18         tax
19         dey
20         lda     (sp),y          ; Get low byte
21
22 ; Inline incsp2 for better performance
23
24         inc     sp              ; 5
25         bne     @L1             ; 3
26         inc     sp+1            ; (5)
27 @L1:    inc     sp              ; 5
28         bne     @L2             ; 3
29         inc     sp+1            ; (5)
30
31 ; Do the compare.
32
33 @L2:    cpx     sreg+1          ; Compare high byte
34         bne     @L3
35         cmp     sreg            ; Compare low byte
36         beq     @L3
37         bcs     @L4
38         lda     #$FF            ; Set the N flag
39 @L3:    rts
40
41 @L4:    lda     #$01            ; Clear the N flag
42         rts
43
44