aar.s 734 B

123456789101112131415161718192021222324252627282930313233
  1. .define .aar
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. EILLINS = 18
  8. .aar: ! (on entry d0 contains the integer size in the descriptor)
  9. cmp.l #4, d0
  10. beq 9f
  11. move.l #EILLINS, -(sp)
  12. jmp (.fatal)
  13. 9:
  14. ! register usage:
  15. ! a0: descriptor address
  16. ! a1: return address
  17. ! d0: index
  18. ! The address is calculated by taking the relative index
  19. ! (index - lower bound), multiplying that with the element
  20. ! size and adding the result to the array base address.
  21. move.l (sp)+, a1 ! return address
  22. move.l (sp)+, a0 ! descriptor address
  23. move.l (sp)+, d0 ! index
  24. sub.l (a0), d0 ! relative index
  25. muls.l (8,a0), d0
  26. move.l (sp)+, a0 ! array base address
  27. add.l d0, a0 ! address of array element
  28. jmp (a1) ! return
  29. .align 2