1 / 9

SPIM simulator

SPIM simulator. SPIM. SPIM Simulator that runs programs written for MIPS R2000/R3000 processors Advantages to using a machine simulator MIPS workstation are not generally available. Provides better environment for low-level programming than an actual machine: detect more errors

lara-love
Download Presentation

SPIM simulator

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SPIM simulator

  2. SPIM • SPIM • Simulator that runs programs written for MIPS R2000/R3000 processors • Advantages to using a machine simulator • MIPS workstation are not generally available. • Provides better environment for low-level programming than an actual machine: • detect more errors • provide more features • give convenient edit-assemble-load development cycle, compared to using a circuit board. • easy to identify and fix the bugs. • Disadvantages • The programs run slower than on a real machine.

  3. OS vs Applications • An application program asks the kernel to do I/O by making system calls. • The kernel implements these system calls by talking directly to the hardware. Application programs Programs make system calls asking kernel to do I/O Kernel Kernel controls I/O devices directly Hardware

  4. SPIM’s System Calls • SIMP provides a small set of 10 OS-like system services through the system call (syscall) instruction. • How t get a system service? • $v0 : system call code • $a0...$a3 : arguments ($f12 <- floating point values) • syscall (initiate system service) • $v0 :results ($f0: for the floating point) • exit: stop running a program.

  5. 1 ## hello.a -prints out "hello world" 2 ## 3 ## 4 ## a0 - points to the string 5 ## 6 7 ############################################################ 8 # # 9 # text segment # 10 # # 11 ############################################################ 12 13 .text 14 .globl __start 15 __ start : # execution starts here 16 la $a0,str # put string address into a0 17 li $v0,4 # system call to print 18 syscall # out a string 19 20 li $v0,10 21 syscall # au revoir ... 22 23 24 ############################################################ 25 # # 26 # data segment # 27 # # 28 ############################################################ 29 30 .data 31 str .asciiz "hello world" 32 33 ## 34 ## end of file hello.a

  6. 3 kinds of SPIM • spim for UNIX(installed in adam & cain) • runs on any type of terminal • type command on terminal • xspim for UNIX(installed in adam & cain) • runs on X-window system • commands & results are always displayed • much easier to run • PCSpim for MS Windows • runs on MS Windows system • similar to xspim • must be installed in your PC to use

  7. PCSpim(starting) • Registers window • Text segment • Data Segment • Messages window

  8. PCSpim(4 Windows) • Registers window • shows the values of all registers in the MIPS CPU and FPU • Text segment • address of instruction (hexadecimal) • instruction’s numerical encoding (hexadecimal) • instruction’s mnemonic description • line number in assembly file • actual line of assembly file • Data Segment • data loaded into program’s memory • data on the program’s stack • Messages window • messages for SPIM(including error messages) [0x00400000] 0x8fa40000 lw $4, 0($29) ; 89 : lw $a0, 0($sp)

  9. PCSpim(Loading, Running, Debugging) • Loading • File -> Open • select assembly file • Running • Simulator -> Go • results are displayed in console • Single step • Simulator -> Single Step(F10) • run an instruction at a time • Multiple steps • Simulator -> Multiple Step…(F11) • run given number of instructions at a time • Breakpoint • Simulator -> Breakpoints(Ctrl + B) • stop program immediately before it executes a particular instruction

More Related