•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,760 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 803 | Replies: 2
![]() |
| |
•
•
Join Date: Dec 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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:
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.
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.
Last edited by Destini : Dec 3rd, 2007 at 7:49 pm.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
Are you taking a course or just doing this on your own?
You need to watch a few things. First, though, your strcopy should look like this:
If you don't already have a good MIPS reference you need to get one. It makes all the difference.
This one at WikiPedia is short, but good.
1. Every jal should be to a subroutine that returns with jr $ra. Using jal means that you don't need moo: at all.
2. The link I gave you gives the general meaning of all the register names.
3. The syscall to print the string requires $a0 to have the address of the string to print and $v0 to have the value 2.
The syscall to terminate the program only requires $v0 to have the value 10.
Hope this helps.
You need to watch a few things. First, though, your strcopy should look like this:
MIPS Syntax (Toggle Plain Text)
strcopy: lbu $t0,($a2) # load the char at $a2 sb $t0,($a3) # save the char at $a3 addi $a2,$a2,1 # next $a2 addi $a3,$a3,1 # next $a3 bgtz $t0,strcopy # do it all again? jr $ra # return to caller
This one at WikiPedia is short, but good.
1. Every jal should be to a subroutine that returns with jr $ra. Using jal means that you don't need moo: at all.
2. The link I gave you gives the general meaning of all the register names.
3. The syscall to print the string requires $a0 to have the address of the string to print and $v0 to have the value 2.
The syscall to terminate the program only requires $v0 to have the value 10.
Hope this helps.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the Assembly Forum
- Previous Thread: Having trouble ENCODING/DECODING ASSEMBLY
- Next Thread: I Desperately need help with this assignment!!



Hybrid Mode