cmu.s 531 B

1234567891011121314151617181920212223242526272829303132333435
  1. .define Cmu2
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine compares two unsigned twobyte integers.
  8. ! If T is the first pushed and than S, the routine will return:
  9. ! -1 if S < T,
  10. ! 0 if S = T,
  11. ! 1 if S > T.
  12. Cmu2:
  13. stx EXG ! S (lowbyte)
  14. sta EXG+1 ! S (highbyte)
  15. jsr Pop ! get T
  16. cmp EXG+1
  17. beq 2f ! S (highbyte) = T (highbyte)
  18. bcc 1f
  19. 4: lda #0 ! S > T
  20. ldx #1
  21. rts
  22. 1: lda #0xFF ! S < T
  23. tax
  24. rts
  25. 2: cpx EXG
  26. bne 3f
  27. lda #0 ! S = T
  28. tax
  29. rts
  30. 3: bcc 1b
  31. bcs 4b