Download presentation
Presentation is loading. Please wait.
Published byAlexina Anderson Modified over 9 years ago
1
1 Compilers Modern Compiler Design Supplementary Note 2 SPIM Overview NCYU C. H. Wang
2
2 SPIM Simulator Spim is a self-contained simulator that will run MIPS32 assembly language programs. Spim reads and immediately executes assembly language code for this processor. Spim provides a simple debugger and minimal set of operating system services. SPIM’s name is just MIPS spelled backwards SPIM can read and immediately execute MIPS assembly language files or MIPS executable files Web site: http://www.cs.wisc.edu/~larus/spim.html
3
3 MIPS Processors MIPS is a load-store architecture, which means that only load and store instructions access memory Computation instructions operate only on values in registers
4
4 MIPS Registers (1/2)
5
5 MIPS Registers (2/2)
6
6 Addressing Modes
7
7 Assembler Syntax (1) Comments in assembler les begin with a sharp- sign (#). Everything from the sharp-sign to the end of the line is ignored. Identifiers are a sequence of alphanumeric characters, underbars (_), and dots (.) that do not begin with a number. Opcodes for instructions are reserved words that are not valid identifiers. Labels are declared by putting them at the beginning of a line followed by a colon.
8
8 Assembler Syntax (2) Example
9
9 Assembler Syntax (3) .data The following data items should be stored in the data segment. If the optional argument addr is present, the items are stored beginning at address addr. .text The next items are put in the user text segment. In SPIM, these items may only be instructions or words (see the.word directive below). If the optional argument addr is present, the items are stored beginning at address addr.
10
10 Assembler Syntax (4) .word w1,..., wn Store the n 32-bit quantities in successive memory words. .double d1,..., dn Store the n floating point double precision numbers in successive memory locations. .float f1,..., fn Store the n floating point single precision numbers in successive memory locations. .globl sym Declare that symbol sym is global and can be referenced from other files.
11
11 Assembly Instructions (1) Load, Store and Data Movement lird, immrd imm lard, labelrd label lwrd, imm(rs) rd imm(rs) swrd, imm(rs) imm(rs) rd moverd, rs rd rs
12
12 Assembly Instructions (2) Arithmetic & Logical Instructions add rd, rs, rtrd rs + rt sub rd, rs, rtrd rs – rt mul rd, rs, rtrd rs * rt div rd, rs, rtrd rs / rt rem rd, rs, rtrd rs % rt neg rd, rs rd - rs
13
13 Assembly Instructions (3) Branch & Jump Instructions beqrs, rt, label branch to label if rs == rt bners, rt, label branch to label if rs != rt bgtrs, rt, label branch to label if rs > rt bgers, rt, label branch to label if rs >= rt bltrs, rt, label branch to label if rs < rt blers, rt, label branch to label if rs <= rt blabel branch to label
14
14 Layout of Memory
15
15 System Services (1)
16
16 System Services (2) SPIM provides a small set of operating-system-like services through the system call (syscall) instruction. To request a service, a program loads the system call code (see Table 1) into register $v0 and the arguments into registers $a0: : :$a3 (or $f12 for oating point values). System calls that return values put their result in register $v0 (or $f0 for oating point results).
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.