Jump to content
  • Advertisement
Sign in to follow this  
sheep19

[assembly] storing bytes to an array

This topic is 2459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a program in assembly that reads a string of characters from the user and inserts it to a buffer of bytes. Then, the program has to search the buffer and copy some of the elements in a new array of bytes, depending on something that does not matter here.

The buffers are defined here:

.data # data segment
#.align 0


buffer: .byte 100 # stores input from the user
converted: .byte 100


The pseduocode for the loop is:
while he haven't reached the NULL character
if condition is true
store data in new buffer (converted)


Data is loaded to register $t3.
lb $t3, buffer($t0) # t0 is the counter that iterates through the 1st string ("buffer")
if condition is true
sb $t3, buffer($t1) ### PROGRAMS CRASHES HERE
increment $t1 by one # t1 shows the end of the second buffer
end if
increment $t0 by one


The program crashes at the commented line above. I am sure that there is the problem because when it's commented out the program runs.
What is the problem? Am I using "sb" in a wrong way?

Thanks in advance for your help.

Share this post


Link to post
Share on other sites
Advertisement
I don't know anything about MIPS assembly programming, but here's what I would do: Write a tiny C function that does the same thing and compile it to assembly (option -S in gcc). You can then rewrite the function in your own style, but you can probably learn a lot from looking at a working example.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!