inn works now; add a helper for it.
This commit is contained in:
parent
196fa914b3
commit
953c08839f
|
@ -8,6 +8,7 @@ for _, plat in ipairs(vars.plats) do
|
|||
name = "lib_"..plat,
|
||||
srcs = {
|
||||
"./*.s",
|
||||
"./*.e",
|
||||
},
|
||||
vars = { plat = plat },
|
||||
deps = {
|
||||
|
|
26
mach/powerpc/libem/inn.s
Normal file
26
mach/powerpc/libem/inn.s
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "powerpc.h"
|
||||
|
||||
.sect .text
|
||||
|
||||
/* Tests a bit in a bitset on the stack.
|
||||
*
|
||||
* Stack: ( bitset bitnum setsize -- bool )
|
||||
*/
|
||||
|
||||
.define .inn
|
||||
.inn:
|
||||
lwz r3, 0(sp) /* r3 = size (bytes) */
|
||||
lwz r4, 4(sp) /* r4 = bit number */
|
||||
addi r5, sp, 8 /* r5 = base address of bit set */
|
||||
|
||||
srawi r6, r4, 3 /* r6 = byte address into set */
|
||||
andi. r7, r4, 7 /* r7 = bit within byte */
|
||||
|
||||
lbzx r8, r5, r6 /* r8 = individual byte from set */
|
||||
sraw r8, r8, r7
|
||||
rlwinm r8, r8, 0, 31, 31
|
||||
|
||||
addi sp, sp, 8 /* retract over the two words */
|
||||
add sp, sp, r3 /* retract over bitfield */
|
||||
stwu r8, -4(sp) /* push result */
|
||||
bclr ALWAYS, 0, 0 /* return */
|
|
@ -1447,12 +1447,11 @@ static void insn_ivalue(int opcode, arith value)
|
|||
* (Modula-2 bitset support, I believe). Leave them until leter. */
|
||||
case op_inn:
|
||||
{
|
||||
appendir(
|
||||
new_ir1(
|
||||
IR_CALL, 0,
|
||||
new_labelir(".unimplemented")
|
||||
)
|
||||
push(
|
||||
new_wordir(value)
|
||||
);
|
||||
|
||||
helper_function(".inn");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
76
plat/qemuppc/tests/inn_e.e
Normal file
76
plat/qemuppc/tests/inn_e.e
Normal file
|
@ -0,0 +1,76 @@
|
|||
#
|
||||
mes 2, 4, 4
|
||||
|
||||
exp $_m_a_i_n
|
||||
pro $_m_a_i_n, 0
|
||||
|
||||
/* Test non-existent bit */
|
||||
|
||||
.1
|
||||
rom 0I1, 0I1, 0I1, 0I1
|
||||
loe .1
|
||||
loc 1 /* bit number */
|
||||
inn 4
|
||||
zeq *1
|
||||
|
||||
loc __LINE__
|
||||
cal $fail
|
||||
ass 4
|
||||
1
|
||||
|
||||
/* Test existent bit */
|
||||
|
||||
.2
|
||||
rom 2I1, 0I1, 0I1, 0I1
|
||||
loe .2
|
||||
loc 1 /* bit number */
|
||||
inn 4
|
||||
zne *2
|
||||
|
||||
loc __LINE__
|
||||
cal $fail
|
||||
ass 4
|
||||
2
|
||||
|
||||
/* Test non-existent high bit */
|
||||
|
||||
.3
|
||||
rom 0I1, 0I1, 0I1, 0I1
|
||||
rom 0I1, 0I1, 0I1, 0I1
|
||||
.31
|
||||
rom 33 /* to defeat constant folding */
|
||||
|
||||
lae .3
|
||||
loi 8
|
||||
loe .31 /* bit number */
|
||||
inn 8
|
||||
zeq *3
|
||||
|
||||
loc __LINE__
|
||||
cal $fail
|
||||
ass 4
|
||||
3
|
||||
|
||||
/* Test existent high bit */
|
||||
|
||||
.4
|
||||
rom 0I1, 0I1, 0I1, 0I1
|
||||
rom 2I1, 0I1, 0I1, 0I1
|
||||
.41
|
||||
rom 33 /* to defeat constant folding */
|
||||
|
||||
lae .4
|
||||
loi 8
|
||||
loe .41 /* bit number */
|
||||
inn 8
|
||||
zne *4
|
||||
|
||||
loc __LINE__
|
||||
cal $fail
|
||||
ass 4
|
||||
4
|
||||
|
||||
cal $finished
|
||||
ret 0
|
||||
|
||||
end
|
Loading…
Reference in a new issue