ack/mach/powerpc/libem/inn.s

27 lines
717 B
ArmAsm
Raw Normal View History

2016-11-20 11:53:44 +00:00
#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 */
rlwinm r6, r4, 29, 3, 29 /* r6 = byte index of word in set */
andi. r7, r4, 31 /* r7 = bit within word */
2016-11-20 11:53:44 +00:00
lwzx r8, r5, r6 /* r8 = individual byte from set */
2016-11-20 11:53:44 +00:00
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 */