File: icmp.s

package info (click to toggle)
cc65 2.19-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 20,272 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,008; perl: 607
file content (47 lines) | stat: -rw-r--r-- 1,130 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
;
; Piotr Fusik, 15.04.2002
; originally by Ullrich von Bassewitz
;
; Integer compare function - used by the compare operators
;

        .export         tosicmp, tosicmp0
        .importzp       sp, sreg


tosicmp0:
        ldx     #$00

tosicmp:
        sta     sreg
        stx     sreg+1          ; Save ax

        ldy     #$00
        lda     (sp),y          ; Get low byte
        tax
        inc     sp              ; 5
        bne     @L1             ; 3
        inc     sp+1            ; (5)
@L1:
        lda     (sp),y          ; Get high byte
        inc     sp              ; 5
        bne     @L2             ; 3
        inc     sp+1            ; (5)

; Do the compare.

@L2:    sec
        sbc     sreg+1          ; Compare high byte
        bne     @L4
        cpx     sreg            ; Compare low byte
        beq     @L3
        adc     #$FF            ; If the C flag is set then clear the N flag
        ora     #$01            ; else set the N flag
@L3:    rts

@L4:    bvc     @L3
        eor     #$FF            ; Fix the N flag if overflow
        ora     #$01            ; Clear the Z flag
        rts