ack/mach/powerpc/libem/csb.s

36 lines
851 B
ArmAsm
Raw Normal View History

2007-11-02 18:56:58 +00:00
.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 -- )
2007-11-02 18:56:58 +00:00
.define .csb
.csb:
lwz r3, 0(sp)
lwz r4, 4(sp)
addi sp, sp, 8
2007-11-02 18:56:58 +00:00
lwz r5, 0(r3) ! load default
mtspr ctr, r5
2007-11-02 18:56:58 +00:00
lwz r6, 4(r3) ! fetch count
2007-11-02 18:56:58 +00:00
1:
or. r6, r6, r6 ! test count
beqctr ! exit if zero
2007-11-02 18:56:58 +00:00
addi r6, r6, -1 ! otherwise decrement
2007-11-02 18:56:58 +00:00
lwzu r7, 8(r3) ! fetch target index, increment pointer
cmpw r4, r7 ! compare with value
bne 1b ! if not equal, go again
2007-11-02 18:56:58 +00:00
lwz r7, 4(r3) ! fetch target address
mtspr ctr, r7
2007-11-02 18:56:58 +00:00
or. r7, r7, r7 ! test it
bnectr ! jump to target if non-zero
2007-11-02 18:56:58 +00:00
b .trap_ecase ! otherwise trap