ack/mach/powerpc/libem/csb.s
David Given d31bc6a3f9 Made csa and csb work with mcg; adjust the libem functions and the
corresponding invocation in the ncg table so the same helpers can be used for
both mcg and ncg. Add a new IR opcode, FARJUMP, which jumps to a helper
function but saves volatile registers.
2016-11-19 10:55:41 +01:00

43 lines
916 B
ArmAsm

#
! $Source$
! $State$
! $Revision$
#include "powerpc.h"
.sect .text
! this is not a subroutine, but just a
! piece of code that computes the jump-
! address and jumps to it.
! traps if resulting address is zero
!
! Stack: ( value tableaddr -- )
.define .csb
.csb:
lwz r3, 0(sp)
lwz r4, 4(sp)
addi sp, sp, 8
lwz r5, 0(r3) ! load default
mtspr ctr, r5
lwz r6, 4(r3) ! fetch count
1:
or. r6, r6, r6 ! test count
bcctr IFTRUE, EQ, 0 ! exit if zero
addi r6, r6, -1 ! otherwise decrement
lwzu r7, 8(r3) ! fetch target index, increment pointer
cmp cr0, 0, r4, r7 ! compare with value
bc IFFALSE, EQ, 1b ! if not equal, go again
lwz r7, 4(r3) ! fetch target address
mtspr ctr, r7
or. r7, r7, r7 ! test it
bcctr IFFALSE, EQ, 0 ! jump to target if non-zero
b .trap_ecase ! otherwise trap