cmi.s 469 B

12345678910111213141516171819202122232425262728293031
  1. .define Cmi
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine compares on two integers.
  8. ! If T is pushed first and than S, the routine will return:
  9. ! -1 if S < T,
  10. ! 0 if S = T,
  11. ! 1 if S > T.
  12. Cmi:
  13. jsr Sbi2 ! subtract operands (T - S)
  14. bpl 1f ! S >= T
  15. lda #0x0FF ! S < T
  16. tax ! AX becomes -1
  17. rts
  18. 1: beq 2f
  19. 3: lda #0 ! S > T
  20. ldx #1 ! AX becomes 1
  21. rts
  22. 2: txa
  23. bne 3b
  24. lda #0 ! S = T
  25. tax ! AX becomes 0
  26. rts