ack/mach/powerpc/libem/set.s
David Given e7e29d34ff Add a test (currently failing) to check that Pascal char sets can store all 256
possible values. Add the PowerPC ncg and mcg backend support to let the test
actually run, including modifying a bunch of PowrePC libem functions so that
they can be called from both ncg and mcg.
2017-01-15 22:28:14 +01:00

33 lines
631 B
ArmAsm

#include "powerpc.h"
.sect .text
! Create singleton set.
! Stack: ( size bitnumber -- set )
.define .set
.set:
lwz r3, 0 (sp)
lwz r4, 4 (sp)
addi sp, sp, 8
rlwinm r7, r3, 30, 2, 31
neg r5, r3
add sp, sp, r5 ! allocate set
mr r6, sp ! r6 = ptr to set
mtspr ctr, r7 ! ctr = r3 / 4
1:
rlwinm. r7, r4, 0, 0, 26 ! r7 = r4 & ~31
bc IFTRUE, EQ, 2f ! branch if r4 in 0..31
addi r5, r0, 0 ! no bit, word is zero
b 3f
2:
addi r5, r0, 1
slw r5, r5, r4 ! yes bit, set bit in word
3:
stw r5, 0(r6) ! store word in set
addi r4, r4, -32
addi r6, r6, 4
bc DNZ, 0, 1b ! loop ctr times
bclr ALWAYS, 0, 0