1 / 18

Tannenbaum Machine

Tannenbaum Machine. 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 . Simple Architecture. Registers

giza
Télécharger la présentation

Tannenbaum Machine

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. PClocation of the NEXT instruction CPU Instructions 77 78 79 Load 177 Addd 150 Stod 151 IR Addd 150 PC 79 CPU is executing the “Addd 150” instruction. The NEXT instruction will be from location 79.

  5. SPlocation of current TOS CPU Instructions 77 78 79 Load 177 PUSH Stod 151 IR PUSH PC 79 AC 12 SP 200 199 200 201 Data and Activation Records

  6. SPlocation of current TOS(after PUSH) CPU Instructions 77 78 79 Load 177 PUSH Stod 151 IR Stod 151 PC 80 AC 12 SP 199 12 199 200 201 Data and Activation Records

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

  8. Stack Operations SP = 1049 SP = 1050 AC = 7 AC = 7 1049 1049 SP PUSH 7 22 SP 1050 1050 437 437 1051 1051 109 109 SP=SP-1 M[SP]=AC SP = 1051 SP = 1050 AC = 437 AC = 7 1049 1049 POP 22 22 SP 1050 1050 437 437 1051 1051 SP 109 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 FORMAT:OPCODE operand LOCO 3 • 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

  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 RecordsWhat 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 RecordsWhere are they stored? 0 Instructions (Static/Fixed) Heap (Dynamic) An illustration of the activation stack where the calling sequence is main()->a()->b() Stack (Dynamic) b() a() main() 4095

  14. Activation Records and Calls b() a() a() main() main() main() main() is executing main() calls a() a() calls b() a() main() main() 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 ………….. Local data(3) Return address(2) Parameters(1) ………….. Caller activation records High

  16. in call to pmul(2,k) • 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 pmul …) desp 2 … insp 2 return pmul: done: (in main…) loco 2 push lodd k push call pmul insp 2

  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

More Related