ack/mach/powerpc/libem/aar4.s

33 lines
688 B
ArmAsm
Raw Normal View History

2007-11-02 18:56:58 +00:00
.sect .text
2007-11-02 18:56:58 +00:00
! Index into a bounds-checked array.
!
! On entry:
! r3 = ptr to descriptor
! r4 = index
! r5 = address of array
! Yields:
! r3 = address of element
! r0 = size of element (used by .lar4, .sar4)
! Preserves r10 for .lar4, .sar4
2007-11-02 18:56:58 +00:00
.define .aar4
.aar4:
lis r0, hi16[.trap_earray]
ori r0, r0, lo16[.trap_earray]
2007-11-02 18:56:58 +00:00
mtspr ctr, r0 ! load CTR with trap address
lwz r0, 0(r3)
subf. r4, r0, r4 ! adjust range
bltctr ! check lower bound
2007-11-02 18:56:58 +00:00
lwz r0, 4(r3)
cmplw r4, r3
bgectr ! check upper bound
2007-11-02 18:56:58 +00:00
lwz r0, 8(r3)
mullw r4, r4, r0 ! scale index
add r3, r4, r5 ! calculate element address
blr