lar.s 1012 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .define .lar
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. EILLINS=18
  8. ! (on entry d0 contains the integer size in the descriptor)
  9. .lar:
  10. cmp.l #4, d0
  11. beq 9f
  12. move.l #EILLINS, -(sp)
  13. jmp (.fatal)
  14. 9:
  15. ! register usage:
  16. ! a0: descriptor address
  17. ! a1: base address
  18. ! d0: index
  19. ! d1: # bytes / element
  20. ! For address calculation; see comment in 'aar.s'.
  21. move.l (sp)+, d1 ! return address
  22. move.l (sp)+, a0 ! descriptor address
  23. move.l (sp)+, d0 ! index
  24. move.l (sp)+, a1 ! array base address
  25. sub.l (a0), d0 ! relative index
  26. move.l d1,-(sp)
  27. move.l (8,a0), d1 ! # bytes / element
  28. cmp.l #1, d1
  29. bne 2f
  30. move.l (sp),a0
  31. clr.l (sp)
  32. move.b (a1,d0.l), (3,sp) ! one byte element
  33. jmp (a0)
  34. 2:
  35. cmp.l #2, d1
  36. bne 4f
  37. move.l (sp),a0
  38. clr.l (sp)
  39. move.w (a1,d0.l*2), (2,sp) ! two byte element
  40. jmp (a0)
  41. 4:
  42. muls.l d1, d0
  43. add.l d0, a1 ! address of 4n byte element
  44. add.l d1, a1 ! because of predecrement
  45. asr.l #2, d1
  46. move.l (sp)+,a0
  47. 1:
  48. move.l -(a1), -(sp)
  49. sub.l #1, d1
  50. bne 1b
  51. jmp (a0)
  52. .align 2