





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This lecture was delivered by Mr. Gurpreet Verma at Cochin University of Science and Technology for Assembly Language Programming course. It includes: Spim, MIPS, Simultaion, Register, Stepping, Version, Windows, Evaluation, LINUX, Layout, Subroutine, Main, Pseudinstruction
Typology: Slides
1 / 37
This page cannot be seen from the preview
Don't miss anything!






























http://chortle.ccsu.edu/AssemblyTutorial/Chapter-09/ass09_1.html
http://chortle.ccsu.edu/AssemblyTutorial/tutorialContents.html
Patterson_Hennessy_AppendixA.pdf
And http://babbage.clarku.edu/~jbreecher/comp_org/labs/Introduction_To_SPIM.pdf
.data # data memory foo: .word 0 # 32 bit variable
.text # program memory .align 2 # word alignment .globl main # main is global
main: lw $a0,foo
SPIM provides some simple I/O using the “syscall” instruction. The specific I/O done depends on some registers.
li $v0,5 # Indicate we want function 5 syscall
move $a0,$v0 # Get the number to be printed into register li $v0,1 # Indicate we’re doing a write -integer syscall
.data msg: .asciiz “SPIM IS FUN” .text .globl main: li $v0, la $a0,msg syscall jr $ra
.text .global main main: subu $sp, $sp, 32 #stack frame size is 32 bytes sw $ra,20($sp) #save return address li $a0,10 # load argument (10) in $a jal fact #call fact la $a0 LC #load string address in $a move $a1,$v0 #load fact result in $a jal printf # call printf lw $ra,20($sp) # restore $sp addu $sp, $sp,32 # pop the stack jr $ra # exit() .data LC: .asciiz "The factorial of 10 is %d\n"