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

Slides:



Advertisements
Similar presentations
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Advertisements

Instruction Set Design
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Run-time Environment for a Program different logical parts of a program during execution stack – automatically allocated variables (local variables, subdivided.
1 Lecture 3: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation.
CSI 3120, Implementing subprograms, page 1 Implementing subprograms The environment in block-structured languages The structure of the activation stack.
Procedures in more detail. CMPE12cGabriel Hugh Elkaim 2 Why use procedures? –Code reuse –More readable code –Less code Microprocessors (and assembly languages)
Lecture 6: MIPS Instruction Set Today’s topic –Control instructions –Procedure call/return 1.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Infix, Postfix and Stacks
1 Chapter 7: Runtime Environments. int * larger (int a, int b) { if (a > b) return &a; //wrong else return &b; //wrong } int * larger (int *a, int *b)
Memory Allocation. Three kinds of memory Fixed memory Stack memory Heap memory.
Runtime Environments Source language issues Storage organization
Accessing parameters from the stack and calling functions.
EECC250 - Shaaban #1 Lec # 5 Winter Stacks A stack is a First In Last Out (FILO) buffer containing a number of data items usually implemented.
Run-Time Storage Organization
Computer Structure - The Instruction Set (2) Goal: Implement Functions in Assembly  When executing a procedure (function in C) the program must follow.
Chapter 9: Subprogram Control
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Unit -II CPU Organization By- Mr. S. S. Hire. CPU organization.
1 Contents. 2 Run-Time Storage Organization 3 Static Allocation In many early languages, notably assembly and FORTRAN, all storage allocation is static.
Chapter 8 :: Subroutines and Control Abstraction
Chapter 7: Runtime Environment –Run time memory organization. We need to use memory to store: –code –static data (global variables) –dynamic data objects.
Runtime Environments What is in the memory? Runtime Environment2 Outline Memory organization during program execution Static runtime environments.
4-1 Chapter 4 - The Instruction Set Architecture Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring.
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Runtime Environments Compiler Construction Chapter 7.
Programming Language Principles Lecture 24 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Subroutines.
Compiler Construction
Functions and Procedures. Function or Procedure u A separate piece of code u Possibly separately compiled u Located at some address in the memory used.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
4-1 Chapter 4 - The Instruction Set Architecture Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
COMPUTER ARCHITECURE INSTRUCTION SET ARCHITECTURE.
Lecture 4: MIPS Instruction Set
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-2.ppt Modification date: March 23, Procedures Essential ingredient of high level.
M. Mateen Yaqoob The University of Lahore Spring 2014.
CSC 8505 Compiler Construction Runtime Environments.
Intermediate Representation II Storage Allocation and Management EECS 483 – Lecture 18 University of Michigan Wednesday, November 8, 2006.
RUNTIME ENVIRONMENT AND VARIABLE BINDINGS How to manage local variables.
© G. Drew Kessler and William M. Pottenger1 Subroutines, Part 2 CSE 262, Spring 2003.
Function Calling. Mips Assembly Call and Return Steps for procedure calling –Save the return address –Jump to the procedure (function) –Execute the procedure.
ICS51 Introductory Computer Organization Accessing parameters from the stack and calling functions.
1 Topic 6: Activation Records COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer.
Code Generation Instruction Selection Higher level instruction -> Low level instruction Register Allocation Which register to assign to hold which items?
Lecture 3 Translation.
Chapter 14 Functions.
Storage Classes There are three places in memory where data may be placed: In Data section declared with .data in assembly language in C - Static) On the.
Displacement (Indexed) Stack
Computer Science 210 Computer Organization
Run-Time Storage Organization
Run-Time Storage Organization
Introduction to Compilers Tim Teitelbaum
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
William Stallings Computer Organization and Architecture 8th Edition
Functions and Procedures
Application Binary Interface (ABI)
Stack Frame Linkage.
Chapter 8 Central Processing Unit
Processor Organization and Architecture
ECEG-3202 Computer Architecture and Organization
Understanding Program Address Space
ECE 3430 – Intro to Microcomputer Systems
UNIT V Run Time Environments.
Program and memory layout
Program and memory layout
Runtime Environments What is in the memory?.
Program and memory layout
Where is all the knowledge we lost with information? T. S. Eliot
Program and memory layout
Presentation transcript:

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 –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)

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

SP location of current TOS CPU IRPUSH PC79 Instructions Load 177 PUSH Stod AC12 SP200 Data and Activation Records

SP location of current TOS(after PUSH) CPU IRStod 151 PC80 Instructions Load 177 PUSH Stod AC12 SP199 Data and Activation Records

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

Stack Operations SP = 1050 SP PUSH AC = SP = 1049 SP AC = SP=SP-1 M[SP]=AC SP = 1050 SP POP AC = SP = 1051 SP AC = AC=M[SP] SP=SP+1

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

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

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

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.

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

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()

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

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:

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

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