ack/mach/powerpc/libem/aar4.s
David Given 80cb6ba927 Eliminate the RELOH2 relocation, as it never worked --- the address would be
calculated incorrectly because of overflow errors.

Replace it with an extended RELOPPC relocation which understands addis/ori
pairs; add an la pseudoop to the assembler which generates these and the
appropriate relocation. Make good.

--HG--
branch : dtrg-experimental-powerpc-branch
2016-09-17 12:43:15 +02:00

35 lines
612 B
ArmAsm

#
! $Source$
! $State$
! $Revision$
#include "powerpc.h"
.sect .text
! Index into a bounds-checked array.
!
! On entry:
! r3 = ptr to descriptor
! r4 = index
! r5 = address of array
.define .aar4
.aar4:
la r0, .trap_earray
mtspr ctr, r0 ! load CTR with trap address
lwz r0, 0(r3)
subf. r4, r0, r4 ! adjust range
bcctr IFTRUE, LT, 0 ! check lower bound
lwz r0, 4(r3)
cmpl cr0, 0, r4, r3
bcctr IFFALSE, LT, 0 ! check upper bound
lwz r0, 8(r3)
mullw r4, r4, r0 ! scale index
add r3, r4, r5 ! calculate element address
bclr ALWAYS, 0, 0