1

I am trying to print a few string in MIPS, but when i try print the first message, program prints all of them.

.data
first_msg: .ascii "Podaj pierwsza liczbe: "
second_msg: .ascii "Podaj druga liczbe: "
third_msg: .ascii "Wieksza z tych liczb jest liczba "

.text
main:
la $a0, first_msg
li $v0, 4
syscall

li $v0, 10
syscall

Sorry for my bad language and thanks for your help!

2
  • Could you please show the output and the system details Commented May 20, 2013 at 11:56
  • It's output: "Podaj pierwsza liczbe: Podaj druga liczbe: Wieksza z tych liczb jest liczba -- program is finished running --" I have a win xp and i use MARS 4.3 to run .asm file. Commented May 20, 2013 at 11:57

1 Answer 1

2

You do not null-terminate the strings. Use asciiz instead of ascii.

.ascii str
Store the string in memory, but do not null-terminate it.

.asciiz str
Store the string in memory and null-terminate it.

Read this.

So, your code becomes:

.data
first_msg: .asciiz "Podaj pierwsza liczbe: "
second_msg: .asciiz "Podaj druga liczbe: "
third_msg: .asciiz "Wieksza z tych liczb jest liczba "

.text
main:
la $a0, first_msg
li $v0, 4
syscall

li $v0, 10
syscall
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.