cmu4.s 939 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. .define Cmu4
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine compares two unsigned fourbyte integers.
  8. ! If T is 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. Cmu4:
  13. lda #ARTH
  14. sta ADDR
  15. lda #0
  16. sta ADDR+1
  17. jsr Sdo ! store S in zeropage ARTH - ARTH+3
  18. lda #ARTH+4
  19. sta ADDR
  20. jsr Sdo ! store T in zeropage ARTH+4 - ARTH+7
  21. lda ARTH+7
  22. cmp ARTH+3
  23. bcc 3f ! S (lowbyte+3) < T (lowbyte+3)
  24. bne 2f ! S (lowbyte+3) < T (lowbyte+3)
  25. lda ARTH+6
  26. cmp ARTH+2
  27. bcc 3f ! S (lowbyte+2) < T (lowbyte+2)
  28. bne 2f ! S (lowbyte+2) < T (lowbyte+2)
  29. lda ARTH+5
  30. cmp ARTH+1
  31. bcc 3f ! S (lowbyte+1) < T (lowbyte+1)
  32. bne 2f ! S (lowbyte+1) < T (lowbyte+1)
  33. lda ARTH+4
  34. cmp ARTH
  35. bcc 3f ! S (lowbyte+0) < T (lowbyte+0)
  36. bne 2f ! S (lowbyte+0) < T (lowbyte+0)
  37. lda #0
  38. tax ! S = T
  39. rts
  40. 2: lda #0 ! S > T
  41. ldx #1
  42. rts
  43. 3: lda #0x0FF ! S < T
  44. tax
  45. rts