Your mips tutorial #4 on printing a character


The correct code for printing characters is 11, not 4, and you should always use single quotes for characters.

What you actually did in the tutorial is to print a string that is one character long, and that is a different thing. You were lucky (or perhaps unlucky) that the next byte after your character happened to be zero and therefore terminated the string for you. When you use syscall code 4, it will print until it gets to a zero byte.

For example, try this code. It prints \”mabc\”.

chr: .byte \’m\’
.byte \’a\’
.byte \’b\’
.byte \’c\’


li $v0 4
la $a0 chr

This code does the right thing:

li $v0 11
lb $a0 chr

as does this:

li $v0 11
li $a0 \’m\’

One other thing: there\’s an assemble button right next to the run button, so you don\’t have to go to the menu to assemble your file.


Dear sender,

Thank you very much for the correction. We will fix this.


How did you like it?

Leave a Reply