RosettaCodeData/Task/String-concatenation/MIPS-Assembly/string-concatenation.mips

40 lines
613 B
Plaintext

main:
la $a0,String1
la $a1,UserRam
jal strcpy
nop
la $a0,String2
jal strcpy
nop
la $a0,UserRam
jal PrintString
nop
shutdown:
nop ;normally not needed, but Project 64 will throw an exception if I don't have a nop here.
b shutdown ;loop forever
nop
strcpy:
LBU t0,(a0)
nop
beqz t0,strcpy_done
SB t0,(a1) ;branch delay slot - this is actually executed BEFORE the beqz!
addiu a0,a0,1
b strcpy
addiu a1,a1,1 ;branch delay slot
strcpy_done:
jr ra
nop
String1:
.ascii "abcdefghijk"
.byte 0
.align 4
String2:
.ascii "lmnopqrstuvwxyz"
.byte 0
.align 4