rmi.s 548 B

1234567891011121314151617181920212223242526272829303132
  1. .define Rmi2
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! This subroutine returns the remainder of a twobyte signed division.
  8. ! The sign of the result is as specified in the emtest.
  9. Rmi2:
  10. ldy #0
  11. sty NBYTES ! for the sign of the result
  12. stx ARTH
  13. sta ARTH+1 ! first operand
  14. jsr Pop
  15. stx ARTH+2
  16. sta ARTH+3 ! second operand
  17. ldy #0
  18. sty UNSIGN ! its signed arithmetic
  19. jsr Div
  20. lsr ARTH+5
  21. ror ARTH+4 ! result must be shifted one time
  22. ldx ARTH+4
  23. lda ARTH+5
  24. ldy NBYTES
  25. beq 1f ! result must be positive
  26. jmp Ngi2
  27. 1: rts