sar.s 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. .define .sar
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. EILLINS=18
  7. .sect .text
  8. ! (on entry d0 contains the integer size in the descriptor)
  9. .sar:
  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. ! If the element size is a fraction of EM_WSIZE (4)
  22. ! the calculation is done by adding.
  23. move.l (sp)+, d1 ! return address
  24. move.l (sp)+, a0
  25. move.l (sp)+, d0
  26. move.l (sp)+, a1
  27. move.l d1,-(sp) ! return address
  28. sub.l (a0), d0
  29. move.l (8,a0), d1 ! # bytes / element
  30. cmp.l #1, d1
  31. bne 2f
  32. move.l (sp)+,a0
  33. move.l (sp)+, d1
  34. move.b d1, (a1,d0.l) ! store one byte element
  35. jmp (a0)
  36. 2:
  37. cmp.l #2, d1
  38. bne 4f
  39. move.l (sp)+,a0
  40. move.l (sp)+, d1
  41. move.w d1, (a1,d0.l*2) ! store two byte element
  42. jmp (a0)
  43. 4: ! here: 4n byte element
  44. muls.l d1, d0
  45. add.l d0, a1 ! address of 4n byte element
  46. asr.l #2, d1
  47. move.l (sp)+,a0
  48. 1:
  49. move.l (sp)+, (a1)+
  50. sub.l #1, d1
  51. bne 1b
  52. jmp (a0)
  53. .align 2