2018-09-09 23:08:25 +00:00
|
|
|
#
|
|
|
|
.sect .text; .sect .rom; .sect .data; .sect .bss
|
|
|
|
|
|
|
|
/* Loads a variable-sized block onto the stack.
|
|
|
|
*
|
|
|
|
* On entry: r2 = size
|
|
|
|
* Stack: ( address -- block )
|
|
|
|
* Preserves r25 for .lar4 and .sar4
|
|
|
|
*/
|
|
|
|
|
|
|
|
.sect .text
|
|
|
|
.define .los4
|
|
|
|
.los4:
|
2018-09-17 17:44:17 +00:00
|
|
|
lw r4, 0(sp) ! r4 = address of source block
|
2018-09-09 23:08:25 +00:00
|
|
|
|
|
|
|
! Sizes 1 and 2 are handled specially.
|
|
|
|
|
|
|
|
li at, 1
|
|
|
|
beq r2, at, byte_sized
|
|
|
|
nop
|
|
|
|
|
|
|
|
li at, 2
|
|
|
|
beq r2, at, word_sized
|
|
|
|
nop
|
|
|
|
|
|
|
|
! Else the size must be a multiple of 4.
|
|
|
|
|
|
|
|
srl r5, r2, 2 ! r5 = number of words
|
2018-09-17 17:44:17 +00:00
|
|
|
addiu sp, sp, 4 ! retract over address
|
|
|
|
subu sp, sp, r2 ! allocate space for destination block
|
|
|
|
mov r6, sp ! r6 = start of destination block
|
2018-09-09 23:08:25 +00:00
|
|
|
|
|
|
|
1:
|
2018-09-17 17:44:17 +00:00
|
|
|
lw at, 0(r4)
|
2018-09-09 23:08:25 +00:00
|
|
|
sw at, 0(r6)
|
2018-09-17 17:44:17 +00:00
|
|
|
addiu r4, r4, 4
|
2018-09-09 23:08:25 +00:00
|
|
|
addiu r6, r6, 4
|
|
|
|
addiu r5, r5, -1
|
|
|
|
bne r5, zero, 1b
|
|
|
|
nop
|
|
|
|
|
|
|
|
jr ra
|
|
|
|
nop
|
|
|
|
|
|
|
|
byte_sized:
|
2018-09-17 17:44:17 +00:00
|
|
|
lbu at, 0(r4)
|
2018-09-09 23:08:25 +00:00
|
|
|
sw at, 0(sp)
|
|
|
|
jr ra
|
|
|
|
nop
|
|
|
|
|
|
|
|
word_sized:
|
2018-09-17 17:44:17 +00:00
|
|
|
lhu at, 0(r4)
|
2018-09-09 23:08:25 +00:00
|
|
|
sw at, 0(sp)
|
|
|
|
jr ra
|
|
|
|
nop
|