Академический Документы
Профессиональный Документы
Культура Документы
SPIM
• SPIM
– Simulator that runs programs written for MIPS R2000/R3000
processors
Application
programs
Programs make system calls asking kernel to do I/O
Kernel
Hardware
SPIM’s System Calls
• SIMP provides a small set of Service Call Arguments Results
10 OS-like system services code
through the system call
(syscall) instruction. print_int 1 $a0 = integer
• How t get a system service? print_float 2 $f12 = float
– $v0 : system call code print_double 3 $f12 = double
– $a0...$a3 : arguments print_string 4 $a0 = string
($f12 <- floating point
values) read_int 5 integer (in
– syscall (initiate system $v0)
service) read_float 6 float (in
– $v0 :results ($f0: for the $f0)
floating point) read_double 7 double (in
– exit: stop running a $f0)
program.
read_string 8 $a0 = buffer,
$a1 = length
sbrk 9 $a0 = amount address
(in $v0)
exit 10
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
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
PCSpim(starting)
• Registers window
• Text segment
• Data Segment
• Messages window
PCSpim(4 Windows)
• Registers window
– shows the values of all registers in the MIPS CPU and FPU
• Text segment