MIPS Architecture + Hello World

As you know if you have read any of my past blogs on Console Development we have recently been taking apart the Playstation (PSX) having a look inside it and researching into what parts are which and what they all do. After giving a presentation I was told to look into the ISA (Instruction Set Architecture) for my console, here are my findings.

The playstation uses a MIPS Architecture, which is also used in many other consoles such as the N64, PSP and PS2. MIPS Instruction set was quite confusing to look at at first, as it is a totaly new concept to code in such a low level language. I soon picked up a few things after looking at examples using MIPS instrcution set and on Wikipiedia about the instructions used. After looking at the language and examples for a while I was happy with what i had learned. I think i could confidently write a basic program that for example would write out a string to the screen.

You would start off with .data < this is where you declare all your variables used in the program -> Then name the variable you want after this – string: followed by the type of variable, to use the print_string system call later you need to use the variable type .asciiz and follow this by the string, “Hello World”.

After the .data section its the .text section, this section is the main portion of your code. start this off with .text followed by main: on the line down, the first thing to do is copy the string into the register that is read later using – la $a0, string – then set the $v0 register to 4 by typing – li $v0, 4 – followed by a syscall, which reads the value in $v0 and as this number is 4 it prints_string in $a0, which is the string “Hello World” specified above.

To exit the program use the service code 10 in $v0 and call syscall again.

Here is how the code looks running in MARS 3.5 MIPS Editor:

 Hello World in MIPS

Hello World in MIPS

Here are some resources used:

http://en.wikipedia.org/wiki/MIPS_architecture – Wikipideia

http://logos.cs.uic.edu/366/notes/MIPS%20Quick%20Tutorial.htm – A Page used with information on it.

http://courses.missouristate.edu/KenVollmar/MARS/ – MARS 3.5 MIPS Editor

Leave a comment