aar2.s 793 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. .define .aar2
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! Load address of array element, decriptor contains 2-bytes integers
  8. ! Expects on stack: pointer to array descriptor
  9. ! index
  10. ! base address
  11. ! Yields on stack: address of array element
  12. .aar2:
  13. pop h
  14. shld .retadr1
  15. mov h,b
  16. mov l,c
  17. shld .bcreg
  18. pop h ! hl = pointer to descriptor
  19. pop d ! de = index
  20. mov a,e ! bc = index - lower bound
  21. sub m
  22. inx h
  23. mov c,a
  24. mov a,d
  25. sbb m
  26. inx h
  27. mov b,a
  28. push b ! first operand to multiply
  29. inx h
  30. inx h
  31. mov c,m ! bc = size
  32. inx h
  33. mov b,m
  34. push b ! second operand to multiply
  35. call .mli2 ! de = size * (index - lower bound)
  36. pop h ! hl = base address
  37. dad d ! hl = address of array[index]
  38. push h
  39. lhld .bcreg
  40. mov b,h
  41. mov c,l
  42. lhld .retadr1
  43. pchl