sti.s 557 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. .define .sti
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! Store indirect
  8. ! Expects on stack: number of bytes to be stored
  9. ! bytes to be stored
  10. .sti: pop h
  11. shld .retadr
  12. mov l,c
  13. mov h,b
  14. shld .bcreg ! save bc
  15. pop h
  16. xra a
  17. mov a,d
  18. rar
  19. mov d,a
  20. mov a,e
  21. rar
  22. mov e,a ! de = word count
  23. jnc 1f
  24. ! if 1 byte array element only:
  25. mov a,d ! trap if de odd and <>1
  26. ora e
  27. cnz eoddz
  28. pop b
  29. mov m,c
  30. jmp 2f
  31. 1: pop b
  32. mov m,c
  33. inx h
  34. mov m,b
  35. inx h
  36. dcx d
  37. mov a,d
  38. ora e
  39. jnz 1b
  40. 2: lhld .bcreg
  41. mov c,l
  42. mov b,h
  43. lhld .retadr
  44. pchl