CSCI263 Computer Organization and Architectures Lecture Note Some
- Slides: 16
CSCI-263 Computer Organization and Architectures Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson & Hennessy, © 2005 Some slides and/or pictures in the following are adapted from: slides © 2008 UCB
The SPIM Simulator SPIM is a simulator that let you run and debug MIPS assembler programs. The simulator allows you to look at the content of registers and memory, and to single step through the simulation. Install PCSpim http: //www. cs. wisc. edu/~larus/spim. html Documentation book: appendix A 9 (on CD) www. cs. wisc. edu/~larus/SPIM/spim_documentation. pdf Webinterface: http: //cgi. aggregate. org/cgi-bin/cgispim. cgi
Steps to Starting a Program (translation) C program: foo. c Compiler Assembly program: foo. s Assembler Object(mach lang module): foo. o Linker Executable(mach lang pgm): a. out Loader Memory lib. o
Assembly Language (cont. ) Pseudo-instructions: extending the instruction set for convenience. Examples: move $2, $4 Translates to: add $2, $4, $0 # $2 = $4, (copy $4 to $2) li $8, 40 addi $8, $0, 40 # $8 = 40, (load 40 into $8) sd $4, 0($29) sw $4, 0 ($29) sw $5, 4($29) # mem[$29] = $4; Mem[$29+4] = $5 la $4, 0 x 1000056 c lui $4, 0 x 1000 ori $4, 0 x 056 c # Load address $4 = <address>
MIPS Pseudo Copy -instructions Arithmetic Shift Logic Memory access Control transfer Pseudoinstruction Usage Move Load address Load immediate Absolute value Negate Multiply (into register) Divide (into register) Remainder Set greater than Set less or equal Set greater or equal Rotate left Rotate right NOT Load doubleword Store doubleword Branch less than Branch greater than Branch less or equal Branch greater or equal move la li abs neg mul div rem sgt sle sge rol ror not ld sd blt bgt ble bge regd, regs regd, address regd, anyimm regd, regs regd, reg 1, reg 2 regd, reg 1, reg 2 regd, address reg 1, reg 2, L reg 1, reg 2, L
The MIPS Instruction Set Copy Arithmetic Logic Memory access Control transfer Instruction Usage Load upper immediate Add Subtract Set less than Add immediate Set less than immediate AND OR XOR NOR AND immediate OR immediate XOR immediate Load word Store word Jump register Branch less than 0 Branch equal Branch not equal Jump and link System call lui rt, imm add rd, rs, rt sub rd, rs, rt slt rd, rs, rt addi rt, rs, imm slti rd, rs, imm and rd, rs, rt or rd, rs, rt xor rd, rs, rt nor rd, rs, rt andi rt, rs, imm ori rt, rs, imm xori rt, rs, imm lw rt, imm(rs) sw rt, imm(rs) j L jr rs bltz rs, L beq rs, rt, L bne rs, rt, L jal L syscall op fn 15 0 0 0 8 10 0 0 12 13 14 35 43 2 0 1 4 5 3 0 32 34 42 36 37 38 39 8 12
Recalling Register Conventions Registers and data sizes in MIPS.
SPIM/MIPS assembly directives. data start data segment . ascii "str" store the string "str" in memory without '