mywiki:hw:mips:mipssimulator
Table of Contents
MIPS Simulator-SPIM
SPIM Simulator for Windows
SPIM Example 1
- test1.asm
# Sample spim program # # Written by Pat Troy, 11/8/2002 .data prompt: .asciiz "Enter in an integer: " str1: .asciiz "the answer is: " newline: .asciiz "\n" bye: .asciiz "Goodbye!\n" .globl main .text main: # initialize li $s0, 10 # prompt for input li $v0, 4 la $a0, prompt syscall # read in the value li $v0, 5 syscall move $s0, $v0 loop: # print str1 li $v0, 4 la $a0, str1 syscall # print loop value li $v0, 1 move $a0, $s0 syscall # print newline li $v0, 4 la $a0, newline syscall # decrement loop value and branch if not negative sub $s0, $s0, 1 bgez $s0, loop # print goodbye message li $v0, 4 la $a0, bye syscall
SPIM Example 2
- test2.asm
## addEm.asm ## program to add two integers ## .text .globl main main: la $t0,val2 # put a 32-bit address into $t0 lw $t1,0($t0) # load first value, 2 lw $t2,4($t0) # load second value, 3 sll $0,$0,0 # load delay slot addu $t1,$t1,$t2 # calc. sum .data val0: .word 0 val1: .word 1 val2: .word 2 val3: .word 3 val4: .word 4 val5: .word 5
mywiki/hw/mips/mipssimulator.txt · Last modified: by 127.0.0.1
