Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIPS Lab CMPE 142 – Operating Systems. MIPS Simulator First Time Startup Setting Options.

Similar presentations


Presentation on theme: "MIPS Lab CMPE 142 – Operating Systems. MIPS Simulator First Time Startup Setting Options."— Presentation transcript:

1 MIPS Lab CMPE 142 – Operating Systems

2 MIPS Simulator First Time Startup Setting Options

3 Startup Screen e.g. No Program Loaded Yet.

4

5 After Loading a MIPS Assembly Source

6 Registers Code Segment Data Segment

7 0zero constant 0 1atreserved for assembler 2v0expression evaluation & 3v1function results 4a0arguments 5a1 6a2 7a3 8t0temporary: caller saves...(callee can clobber)‏ 15t7 16s0callee saves... (caller can ignore)‏ 23s7 24t8 temporary (cont’d)‏ 25t9 26k0reserved for OS kernel 27k1 28gpPointer to global area 29spStack pointer 30fpframe pointer 31raReturn Address (HW)‏ MIPS: Software conventions for Registers Before calling procedure: –Save caller-saves regs –Save v0, v1 –Save ra After return, assume –Callee-saves reg OK –gp, sp, fp OK (restored!)‏ –Other things trashed A()‏B()‏ A() { B() ; }

8 Examples Try these out… Load them (source in zip file) and single step execution in the simulator

9

10

11

12

13 Simple Stack Example

14 Single Step This Code… File: mips.stack.register.s

15 Challenge Problem Try to implement in MIPS Assembly the following slide from Lecture. HINT: Read Section 3.1 Function Environments and Linkage and Look at the TREESORT.ASM example in the MIPS Assembly Tutorial Also, use MIPS SDE Lite to view MIPS Assembly for the C code.

16 Execution Stack Example Stack holds temporary results Permits recursive execution Crucial to modern languages A(int tmp) { if (tmp<2)‏ B(); printf(tmp); } B() { C(); } C() { A(2); } main() { A(1); } A: tmp=2 ret=C+1 Stack Pointer Stack Growth A: tmp=1 ret=exit B: ret=A+2 C: ret=b+1

17 Register Usage is by Convention

18 MIPS Instruction Set Overview

19 END LAB


Download ppt "MIPS Lab CMPE 142 – Operating Systems. MIPS Simulator First Time Startup Setting Options."

Similar presentations


Ads by Google