sar.s 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. .define .sar
  2. .sect .text
  3. .sect .rom
  4. .sect .data
  5. .sect .bss
  6. .sect .text
  7. ! (on entry d0 contains the integer size in the descriptor)
  8. .sar:
  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, later base address
  16. ! a1: return address
  17. ! d0: index
  18. ! d2: # bytes / element
  19. ! For address calculation; see comment in 'aar.s'.
  20. ! If the element size is a fraction of EM_WSIZE (4)
  21. ! the calculation is done by adding.
  22. move.l (sp)+,a1 ! return address
  23. move.l (sp)+, a0
  24. move.l (sp)+, d0
  25. sub.l (a0), d0
  26. move.l 8(a0), d2 ! # bytes / element
  27. move.l (sp)+, a0
  28. clr.l d1
  29. cmp.l #1, d2
  30. bne 2f
  31. move.l (sp)+, d1
  32. move.b d1, 0(a0, d0.l) ! store one byte element
  33. bra 5f
  34. 2:
  35. cmp.l #2, d2
  36. bne 4f
  37. asl.l #1, d0
  38. move.l (sp)+, d1
  39. move.w d1, 0(a0, d0.l) ! store two byte element
  40. bra 5f
  41. 4: ! here: 4n byte element
  42. move.l a0,-(sp)
  43. move.l d0, -(sp)
  44. move.l d2, -(sp)
  45. jsr .mlu
  46. move.l (sp)+,a0
  47. add.l d1, a0 ! address of 4n byte element
  48. asr.l #2, d2
  49. sub.l #1, d2
  50. 1:
  51. move.l (sp)+, (a0)+
  52. dbf d2, 1b
  53. 5:
  54. jmp (a1)
  55. .align 2