Lecture9 - Lecture 9 Programming MIPS MIPS is an assembly...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 9 Programming MIPS MIPS is an assembly language SPIM is the simulator for MIPS instructions o Check the webpage for “Help with SPIM” ( http://www.cs.sunysb.edu/~cse220/helpwithSpim.html ) o SPIM is written in C . When we execute SPIM it acts like a MIPS machine o It assembles (compiles) and loads your assembly language program into simulated memory o Provides 10 system calls for input/output and program exit Why use this? Why should we learn this? o Best way to learn how a processor functions Compare C to MIPS code /* hello.c * Purpose - print hello */ #include <stdio.h> int main(void){ printf("Hello, world!\n"); return 0; } Note: the code below is available to you on Sparky, in directory ~cse220/examples/spim ## hello.asm - print out "hello world" ## a0 - points to the string ######################################### # text segment # ######################################### .text # tells assembler program code starts here .globl main # defines label for execution start main: # execution starts here la $a0,str # put string address into a0 li $v0,4 # system call to print syscall # out a string li $v0, 10 # Load exit syscall value syscall # Exit ############################################## # data segment # ############################################## .data # tells assembler data segment begins here str: .asciiz "hello world\n" # declaration of a string
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
C MIPS Comments // or /* */ # Main function int main (void) { ….. } .text
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Lecture9 - Lecture 9 Programming MIPS MIPS is an assembly...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online