ack/mach/6500/libem/cmi.s
1988-08-19 17:05:03 +00:00

32 lines
469 B
ArmAsm

.define Cmi
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
! 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
lda #0x0FF ! S < T
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