ror4.s 570 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. .define .ror4
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! Rotate 4 bytes right
  8. ! Expects in de-reg: number of rotates
  9. ! Expects on stack: operand
  10. ! Yields on stack: result
  11. .ror4: pop h
  12. shld .retadr
  13. mov h,b
  14. mov l,c
  15. shld .bcreg
  16. pop h ! low-order bytes of operand
  17. pop b ! high order bytes of operand
  18. mov a,e
  19. ani 31
  20. jz 2f
  21. mov e,a
  22. mov a,l
  23. rar
  24. 1: mov a,b
  25. rar
  26. mov b,a
  27. mov a,c
  28. rar
  29. mov c,a
  30. mov a,h
  31. rar
  32. mov h,a
  33. mov a,l
  34. rar
  35. mov l,a
  36. dcr e
  37. jnz 1b ! keep looping
  38. 2: push b
  39. push h
  40. lhld .bcreg
  41. mov b,h
  42. mov c,l
  43. lhld .retadr
  44. pchl