So here's my code with the given argument; this is what my code ends up printing though.
Test function _strCopy
Please enter a string: test
You just entered : test
Result of _strCopy: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
If both strings are identical, your _strCopy works properly.
Honestly assembly gives me the biggest headache and I'm assuming this was supposed to be easy considering most of the code is already completed for me, I just have to make the functions. Any help would be appreciated thanks.
Edit1: removed unneeded lines Edit2: solved, had to change
move $t0, $a0
move $t1, $a1
into
move $t0, $a1
move $t1, $a0
and that fixxed it
# Arguments:
# - $a0: An address of the first character of a source string
# - $a1: An address of a buffer
# Return Value:
# - None
_strCopy:
move $t0, $a0
move $t1, $a1
strCopy_loop:
lbu $t3, 0($t1) # load
sb $t3, 0($t0) # write
addi $t0, $t0, 1
addi $t1, $t1, 1
beq $t3, $zero, __strCopy_end # Return if we hit a null terminator
j strCopy_loop
__strCopy_loop2:
addi $t2, $t2, -1
sb $zero, 0($t2)
__strCopy_end:
sub $v0, $t0, $a0
jr $ra