MIPS code acting funny - simple case regarding print statements

Go To StackoverFlow.com

0

I am having real problems trying debug my code to malfunctioning print statements. I am using MARS MIPS simulator. The following code prints:

degree! test degree! test

When it should print

degree! test

.data

test:       .ascii      "degree!\n"

test4:      .ascii      "test\n"

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

la  $a0, test4
li  $v0, 4
syscall 

j EXIT


EXIT:
2012-04-03 19:43
by spatara


1

The strings are not null-terminated. Use .asciiz instead of .ascii

2012-04-03 22:25
by Patrik


1

You need to use .asciiz instead of .ascii to get NULL terminated strings.

2012-04-03 22:25
by markgz