rol4.s 569 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. .define .rol4
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! Rotate 4 bytes left
  8. ! Expects in de-reg: number of rotates
  9. ! Expects on stack: operand
  10. ! Yields on stack: result
  11. .rol4: 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,b
  23. ral
  24. 1: mov a,l
  25. ral
  26. mov l,a
  27. mov a,h
  28. ral
  29. mov h,a
  30. mov a,c
  31. ral
  32. mov c,a
  33. mov a,b
  34. ral
  35. mov b,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