1984-12-17 11:03:13 +00:00
|
|
|
.define Cmi
|
1987-01-30 18:41:42 +00:00
|
|
|
.sect .text
|
|
|
|
.sect .rom
|
|
|
|
.sect .data
|
|
|
|
.sect .bss
|
|
|
|
.sect .text
|
1984-12-17 11:03:13 +00:00
|
|
|
|
|
|
|
! This subroutine compares on two integers.
|
|
|
|
! If T is pushed first and than S, the routine will return:
|
|
|
|
! -1 if S < T,
|
|
|
|
! 0 if S = T,
|
|
|
|
! 1 if S > T.
|
|
|
|
|
|
|
|
|
|
|
|
Cmi:
|
|
|
|
jsr Sbi2 ! subtract operands (T - S)
|
|
|
|
bpl 1f ! S >= T
|
1988-08-19 17:05:03 +00:00
|
|
|
lda #0x0FF ! S < T
|
1984-12-17 11:03:13 +00:00
|
|
|
tax ! AX becomes -1
|
|
|
|
rts
|
|
|
|
1: beq 2f
|
|
|
|
3: lda #0 ! S > T
|
|
|
|
ldx #1 ! AX becomes 1
|
|
|
|
rts
|
|
|
|
2: txa
|
|
|
|
bne 3b
|
|
|
|
lda #0 ! S = T
|
|
|
|
tax ! AX becomes 0
|
|
|
|
rts
|
|
|
|
|
|
|
|
|