lar.s 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. .global aar
  2. .global lar
  3. .global sar
  4. aar: ! %o0 = descr %o1 = index %o2 = array_ptr
  5. save %sp, -64, %sp
  6. ld [%i0], %o0 ! lower bound
  7. subcc %i1, %o0, %o1 ! 0..N-1
  8. bl 1f ! <0
  9. nop
  10. ld [%i0+4], %o0 ! n
  11. cmp %o1, %o0
  12. bgt 1f ! > N
  13. nop
  14. call mli4 ! descr *= n.size
  15. ld [%i0+8], %o0 ! el.size
  16. add %i2, %o0, %i0 ! &base_addr[n]
  17. ret
  18. restore ! delay slot
  19. 1: restore
  20. set EARRAY, %o0
  21. call trp
  22. nop
  23. retl
  24. nop
  25. lar: ! %o0 = descr %o1 = index %o2 = array_ptr
  26. mov %o7, %o4
  27. call aar
  28. mov %o0, %o3
  29. mov %o4, %o7
  30. ! %o0 = address of el, %o1 = sizeof(el), %o2 = word, %o3 = descr
  31. ld [%o3+8], %o1 ! el.size
  32. cmp %o1, 1
  33. bne 2f
  34. nop
  35. ldub [%o0], %o2 ! el.size == 1
  36. dec 4, %l0
  37. retl
  38. st %o2, [%l0] ! delay slot
  39. 2: cmp %o1,2
  40. bne 3f
  41. nop
  42. lduh [%o0], %o2 ! el.size == 2
  43. dec 4, %l0
  44. retl
  45. st %o2, [%l0] ! delay slot
  46. 3: cmp %o1, 4
  47. bne 4f
  48. nop
  49. ld [%o0], %o2
  50. dec 4, %l0
  51. retl
  52. st %o2, [%l0] ! delay slot
  53. 4: sub %l0, %o1, %l0
  54. 5: deccc 4, %o1
  55. ld [%o0+%o1], %o2
  56. bnz 5b
  57. st %o2, [%l0+%o1]
  58. retl
  59. nop
  60. sar: ! %o0 = descr %o1 = index %o2 = array_ptr
  61. mov %o7, %o4
  62. call aar
  63. mov %o0, %o3
  64. mov %o4, %o7
  65. ! %o0 = address of el, %o1 = sizeof(el), %o2 = word, %o3 = descr
  66. ld [%o3+8], %o1 ! el.size
  67. cmp %o1, 1
  68. bne 2f
  69. nop
  70. ld [%l0], %o2
  71. stb %o2, [%o0]
  72. retl
  73. inc 4, %l0 ! delay slot
  74. 2: cmp %o1,2
  75. bne 3f
  76. nop
  77. ld [%l0], %o2
  78. sth %o2, [%o0]
  79. retl
  80. inc 4, %l0 ! delay slot
  81. 3: cmp %o1, 4
  82. bne 4f
  83. nop
  84. ld [%l0], %o2
  85. st %o2, [%o0]
  86. retl
  87. inc 4, %l0 ! delay slot
  88. 4: mov %o1, %o4
  89. 5: deccc 4, %o1
  90. ld [%l0+%o1], %o2
  91. bnz 5b
  92. st %o2, [%o0+%o1] ! delay slot
  93. retl
  94. add %l0, %o4, %l0 ! delay slot