mywiki:hw:mips:mipssimulator
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| mywiki:hw:mips:mipssimulator [2014/07/26 18:30] – created shaoguoh | mywiki:hw:mips:mipssimulator [2022/04/02 17:29] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| MIPS Simulator-SPIM | MIPS Simulator-SPIM | ||
| + | ====== SPIM Simulator for Windows ====== | ||
| + | | {{: | ||
| + | | [[pcspim_syscall]] | | ||
| + | ====== SPIM Example 1 ====== | ||
| + | |||
| + | <file asm test1.asm > | ||
| + | # Sample spim program | ||
| + | # | ||
| + | # Written by Pat Troy, 11/8/2002 | ||
| + | |||
| + | .data | ||
| + | prompt: | ||
| + | str1: | ||
| + | newline: .asciiz " | ||
| + | bye: | ||
| + | .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 ====== | ||
| + | <file asm test2.asm> | ||
| + | ## addEm.asm | ||
| + | ## program to add two integers | ||
| + | ## | ||
| + | .text | ||
| + | .globl | ||
| + | |||
| + | main: | ||
| + | la $t0, | ||
| + | lw $t1, | ||
| + | lw $t2, | ||
| + | sll | ||
| + | addu $t1, | ||
| + | |||
| + | .data | ||
| + | val0: | ||
| + | val1: | ||
| + | val2: | ||
| + | val3: | ||
| + | val4: | ||
| + | val5: | ||
| + | |||
| + | </ | ||
mywiki/hw/mips/mipssimulator.1406370644.txt.gz · Last modified: (external edit)
