I'm using MARS MIPS simulator and I want to print a newline in my program.
.data
space: .asciiz "\n"
.text
addi $v0, $zero, 4 # print_string syscall
la $a0, space # load address of the string
syscall
Instead of printing newline, it prints UUUU
. What's that I'm doing wrong?
If you're just trying to print a newline, it's simpler (and slightly more memory efficient) to do it using syscall 11 to print a single character.
.text
main: addi $a0, $0, 0xA #ascii code for LF, if you have any trouble try 0xD for CR.
addi $v0, $0, 0xB #syscall 11 prints the lower 8 bits of $a0 as an ascii character.
syscall