edit: sorry strcopy not strcat
Hi I'm new to MIPS and just need some basic clarification on what is actually going on here. I'm trying to make a copy of string1 into string2 by reading through the string copying each bit seperately, and stopping at the 0 terminator:
.data
string1: .asciiz "Hello"
string2: .space 128
.text
main: la $a2, string1
la $a3, string2
jal strcopy
moo: la $a0, $a3
li $v0, 4
syscall
li $v0, 10
syscall
strcopy: move $v0, $a2
loop: lbu $t0,0($a2)
sb $t0,0,($a3)
addi $a2,$a2,1
bgtz $t0,loop
jal moo
The only problem is im getting really mixed up with all my $a-something.
I've looked at other examples of strcat but I can never actually figure out which line actually overwrites the one string. I think it's cause I don't fully understand the principle of $a0.
Could someone please adjust the above so that string1 will be copied into string2?
Thanks for any help or information you can give.