User Tools

Site Tools


mywiki:hw:mips:mipssimulator

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
mywiki:hw:mips:mipssimulator [2014/07/26 18:30] – created shaoguohmywiki: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 ======
 +| {{:mywiki:hw:mips:pcspim.zip|PcSpim For Windows download}} | 
 +| [[pcspim_syscall]] |
  
 +====== SPIM Example 1 ======
 +
 +<file asm 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
 +
 +</file>
 +
 +
 +
 +====== SPIM Example 2 ======
 +<file asm 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,     #  load delay slot
 +        addu  $t1,$t1,$t2  #  calc. sum
 +
 +        .data
 +val0:   .word   
 +val1:   .word   
 +val2:   .word   
 +val3:   .word   
 +val4:   .word   
 +val5:   .word   
 +
 +</file>
mywiki/hw/mips/mipssimulator.1406370644.txt.gz · Last modified: (external edit)