032bcffef6
The new features are the hi16/lo16 and ha16/lo16 syntax for relocations, and the extended mnemonics like "blr". Use ha16/lo16 to load some double floats with 2 instructions (lis/lfd) instead of 3 (lis/ori/lfd). Use the extended names for branches, comparisons, and bit rotations, so I can more easily read the code. The new names often encode the same machine instructions as the old names, except in a few places where I changed the instructions. Stop using andi. when we don't need to set cr0. In inn.s, I change andi. to extrwi to extract the same bits. In los.s and sts.s, I change "andi. r3, r3, ~3" to "clrrwi r3, r3, 2". This avoids setting cr0 and also stops clearing the high 16 bits of r3. In csa.s, los.s, sts.s, I change some comparisons and right shifts from signed to unsigned (cmplw, cmplwi, srwi), because the sizes are unsigned. In inn.s, the right shift can be signed (sraw) or unsigned (srw), but I use srw because we don't need the carry bit. In fef8.s, I save an instruction by using rlwinm instead of addis/andc to rlwinm to clear a field. The code no longer kills r7. In both fef8.s and fif8.s, I remove the list of killed registers. Also remove some whitespace from ends of lines.
41 lines
639 B
ArmAsm
41 lines
639 B
ArmAsm
.sect .text
|
|
|
|
! Load from bounds-checked array.
|
|
!
|
|
! On entry:
|
|
! r3 = ptr to descriptor
|
|
! r4 = index
|
|
! r5 = address of array
|
|
|
|
.define .lar4
|
|
.lar4:
|
|
mfspr r10, lr
|
|
bl .aar4
|
|
mtspr lr, r10
|
|
! r3 = ptr to element
|
|
! r0 = size of element
|
|
|
|
cmpwi r0, 1
|
|
bne 1f
|
|
! Load 1 byte.
|
|
lbz r4, 0(r3)
|
|
stwu r4, -4(sp)
|
|
blr
|
|
1:
|
|
cmpwi r0, 2
|
|
bne 2f
|
|
! Load 2 bytes.
|
|
lhz r4, 0(r3)
|
|
stwu r4, -4(sp)
|
|
blr
|
|
2:
|
|
! Load r0 bytes, where r0 must be a positive multiple of 4.
|
|
subf sp, r0, sp ! move stack pointer down
|
|
or r5, r0, r0 ! index r5 = length r0
|
|
3:
|
|
addic. r5, r5, -4 ! r5 -= 4
|
|
lwzx r4, r5, r3
|
|
stwx r4, r5, sp
|
|
bgt 3b ! loop if r5 > 0
|
|
blr
|