sri4.s 661 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. .define Sri4, Sru4
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! The subroutine Sri4 shifts a signed fourbyte integer to the
  8. ! right n times
  9. ! N is in register X.
  10. ! The subroutine Sru4 shifts an unsigned fourbyte integer to the
  11. ! right n times.
  12. Sru4:
  13. txa
  14. tay
  15. bne 1f
  16. rts
  17. 1: jsr Pop
  18. stx ARTH
  19. sta ARTH+1
  20. jsr Pop
  21. stx ARTH+2
  22. jmp 2f
  23. Sri4:
  24. txa
  25. tay
  26. bne 1f
  27. rts
  28. 1: jsr Pop
  29. stx ARTH
  30. sta ARTH+1
  31. jsr Pop
  32. stx ARTH+2
  33. tax
  34. bmi 1f
  35. 2: lsr a
  36. ror ARTH+2
  37. ror ARTH+1
  38. ror ARTH
  39. dey
  40. bne 2b
  41. beq 4f
  42. 1: sec
  43. ror a
  44. ror ARTH+2
  45. ror ARTH+1
  46. ror ARTH
  47. 3: dey
  48. bne 1b
  49. 4: ldx ARTH+2
  50. jsr Push
  51. lda ARTH+1
  52. ldx ARTH
  53. jmp Push