Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tannenbaum Machine. Key Features Simple architecture Simple instruction set Focus on –Input -> Higher Level Language –Output -> Machine Language Addressing.

Similar presentations


Presentation on theme: "Tannenbaum Machine. Key Features Simple architecture Simple instruction set Focus on –Input -> Higher Level Language –Output -> Machine Language Addressing."— Presentation transcript:

1 Tannenbaum Machine

2 Key Features Simple architecture Simple instruction set Focus on –Input -> Higher Level Language –Output -> Machine Language Addressing techniques in response to language feature (parameter, local var, etc)! Activation records

3 Simple Architecture Registers –PC -> Location of NEXT instruction –SP -> Location of top of stack –AC -> Accumulator (source for an operand and usually location where results are placed) Memory of 4096 words Stack is part of regular memory and grows from top (4095) down (PUSH decrements SP) Program loads in low end (starts at 0)

4 PC location of the NEXT instruction Instructions Load 177 Addd 150 Stod 151 77 78 79 CPU IR PC Addd 150 79 CPU is executing the “Addd 150” instruction. The NEXT instruction will be from location 79.

5 SP location of current TOS CPU IRPUSH PC79 Instructions Load 177 PUSH Stod 151 77 78 79 AC12 SP200 Data and Activation Records 199 200 201

6 SP location of current TOS(after PUSH) CPU IRStod 151 PC80 Instructions Load 177 PUSH Stod 151 77 78 79 AC12 SP199 Data and Activation Records 199 200 201 12

7 Program Organization in Memory Instructions (Static/Fixed) Heap (Dynamic) Stack (Dynamic) Floating partition: As long as one doesn’t overlap the other, each can grow independently. 0 4095

8 Stack Operations 1049 1050 1051 SP = 1050 SP PUSH AC = 7 22 437 109 1049 1050 1051 SP = 1049 SP AC = 7 7 437 109 SP=SP-1 M[SP]=AC 1049 1050 1051 SP = 1050 SP POP AC = 7 22 437 109 1049 1050 1051 SP = 1051 SP AC = 437 22 437 109 AC=M[SP] SP=SP+1

9 Instruction set Moving to/from memory/AC/stack –PUSH/POP (stack) –LOAD/STORE Calculating –ADD/SUB Stack pointer –INSP/DESP Procedures –CALL/RETURN Branching –JUMP/JPOS/JZER/JNEG/JNZE

10 Instruction Set Operand depends on opcode –LOCO -> constant –LODL -> from activation record (local value) –LODD -> memory location Note the language specs used to define the instructions –LODD x -> AC := M[x] –load contents of memory cell x into accumulator FORMAT: OPCODE operand LOCO 3

11 Input HLL -> Output ML Note that although you may not know how to translate (compiler) you can see the result of a compilation Step though each and every statement! Notice the addressing techniques are a response to a need of the language as indicated in later slides

12 Activation Records What is inside one? Local variables Return address Parameters Consider what can change from one call to the next. Also consider a recursive call where the same parameter can occur repeatedly.

13 Activation Records Where are they stored? Instructions (Static/Fixed) Heap (Dynamic) Stack (Dynamic) 0 4095 main() a() b() An illustration of the activation stack where the calling sequence is main()->a()->b()

14 Activation Records and Calls main() a() b() main() a() main() a() main() main() is executingmain() calls a()a() calls b() b() returns to a() a() returns to main()

15 Activation Record Caller –pushes parameters (1) –makes call which pushes return address (2) Callee –DECrements sp to make room for local data (3) –does work accessing local data and params from stack –INCrements sp to delete local data (undo 3) –pops off return address on return (undo 2) Caller –Pops off parameters (undo 1) Low High ………….. Parameters(1) Return address(2) Local data(3) Caller activation records

16 Caller –pushes parameters (1) –makes call which pushes return address (2) Callee –DECrements sp to make room for local data (3) –does work accessing local data and params from stack –INCrements sp to delete local data –pops off return address on return Caller –Pops off parameters in call to pmul(2,k) (in main…) loco 2 push lodd k push call pmul insp 2 (in pmul …) desp 2 … insp 2 return pmul: done:

17 Addressing Techniques Direct - memory address is fixed –global data Indirect - value of AC is address of operand –reference parameters –arrays Local - from the procedure’s activation record –value parameters and local vars Stack - to/from the stack –stack need not be accessed from top only

18 Application Global data and instructions from low memory Activation Records on stack from high memory Main routine at bottom of pascal code Global data at top of pascal code var parameters are reference Not very hard to read! writeln is a subroutine in the pascal library (not seen) later linked to the code


Download ppt "Tannenbaum Machine. Key Features Simple architecture Simple instruction set Focus on –Input -> Higher Level Language –Output -> Machine Language Addressing."

Similar presentations


Ads by Google