MacLennan Chapter 1 The Beginning: Pseudo-code Interpreters.

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

Chapter 8: Central Processing Unit
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
Names and Bindings.
The Assembly Language Level
Chapter 3 Loaders and Linkers
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
The Little man computer
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
1 Lecture-2 CSIT-120 Spring 2001 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
Chapter 16 Control Unit Operation No HW problems on this chapter. It is important to understand this material on the architecture of computer control units,
Chapter 7 Low-Level Programming Languages. 2 Chapter Goals List the operations that a computer can perform Discuss the relationship between levels of.
Chapter 16 Control Unit Implemntation. A Basic Computer Model.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Chapter 15 IA 64 Architecture Review Predication Predication Registers Speculation Control Data Software Pipelining Prolog, Kernel, & Epilog phases Automatic.
Unit -II CPU Organization By- Mr. S. S. Hire. CPU organization.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Computer ArchitectureFall 2007 © Sep 10 th, 2007 Majd F. Sakr CS-447– Computer Architecture.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
Chapter 3 Planning Your Solution
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
CS102 Introduction to Computer Programming
COMPUTER SCIENCE I C++ INTRODUCTION
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
MT311 Java Programming and Programming Languages Li Tak Sing ( 李德成 )
CSC141 Introduction to Computer Programming
Machine Instruction Characteristics
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Programming Languages The Beginning. In the beginning... Computers were very expensive; programmers were cheap Programming was by plugboards or binary.
Compiler Chapter# 5 Intermediate code generation.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
 1998 Morgan Kaufmann Publishers MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: A = B +
© GCSE Computing Candidates should be able to:  describe the characteristics of an assembler Slide 1.
FORTRAN History. FORTRAN - Interesting Facts n FORTRAN is the oldest Language actively in use today. n FORTRAN is still used for new software development.
Instruction Sets: Addressing modes and Formats Group #4  Eloy Reyes  Rafael Arevalo  Julio Hernandez  Humood Aljassar Computer Design EEL 4709c Prof:
The Instruction Set Architecture. Hardware – Software boundary Java Program C Program Ada Program Compiler Instruction Set Architecture Microcode Hardware.
Question What technology differentiates the different stages a computer had gone through from generation 1 to present?
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages Dr. Carter Tiernan.
Processor Fundamentals Assembly Language. Learning Objectives Show understanding of the relationship between assembly language and machine code, including.
Computer Organization Instructions Language of The Computer (MIPS) 2.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Chapter 0: Historical Overview.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Chapter Goals Describe the application development process and the role of methodologies, models, and tools Compare and contrast programming language generations.
Chapter 10 Application Development
Lecture 3 Translation.
The Little man computer
Component 1.6.
Assembler, Compiler, MIPS simulator
Addressing Modes in Microprocessors
System Programming and administration
Overview Introduction General Register Organization Stack Organization
The University of Adelaide, School of Computer Science
Compiler Construction
Designing and Debugging Batch and Interactive COBOL Programs
CMP 131 Introduction to Computer Programming
Processor Fundamentals
Mastering Memory Modes
ECE 352 Digital System Fundamentals
COMS 361 Computer Organization
Presentation transcript:

MacLennan Chapter 1 The Beginning: Pseudo-code Interpreters

2 History and Motivation Programming is difficult. –Because of its complexity, dealing with many different details at one time. Programming early computers was especially difficult. –Very little storage, slow, complicated programming –Four address, optimal coding, drum head Many program design notations were developed.

3 Floating point and indexing were simulated. –It was very difficult. Pseudo-code Interpreters were invented. Pseudo-code Interpreters implemented a Virtual computer with its own set of data types (floating point) and operations (indexing) in terms of the real computer with its own data types and operations.

4 The Automation Principle Automate mechanical, tedious, or error prone activities. The virtual computer is in a higher level than the real one. –Provide more suitable facilities. –Eliminate many details.

5 The Regularity Principle Regular rules, without exceptions, are easier to learn, use, describe, and implement. The virtual computer is more regular than the real one. –Simpler to understand through the absence of special cases.

6 Programming languages can be viewed as defining virtual computers. –Better in some respects –Usually slower

7 Compiling Routines Extract subroutines from libraries and combine them (compiling). Less overhead, is done once. Will be discussed in following chapter.

8 Design of a Pseudo-code Similar to real pseudo-codes, languages L1 and L2, Bell Labs, for the IBM 650, in 1955 and Goal: Illustrating many of the steps and decisions in design of a programming language.

9 A computer with 2000 words of 10-digit memory We want facilities as: –Arithmetic –Control of execution flow –Input-output

10 Floating-point arithmetic Floating-point comparisons Indexing Transfer of control Input-output

11 How large shall the addresses be? –Two, three, or four? –Two: 100 locations –Three: 1000 locations –Four: 10,000 locations

12 Three digits: –Addressing only 1000 locations  security –First 1000 locations for data –We are unable to address out of data area

13 The Impossible Error Principle Making errors impossible to commit is preferable to detecting them after their commission. With our addressing rule, we prevent the programmer to overwrite program or the interpreter.

14 The instructions could have two, three, or four operands. –Two addresses: x+y  x –Three addresses: x+y  z –Four addresses: x+y*z  w

15 Instructions have three operands. op opn1 opn2 dest add …

16 Encoding of operations: */ 3squaresquare root

17 The Orthogonality Principle Independent functions should be controlled by independent mechanisms. We can describe mn different possibilities even though we only have to memorize m+n independent facts

18 Design Principles must be applied flexibly. Some of the principles contradict one another. A balance must be find. No rules for this balancing task –Experience gives you a good eye!

19 Orthogonality may be inappropriate. –If there are lots of exceptions.

20 We need comparison to alter control flow */ 3squaresquare root 4If = gotoIf <> goto 5If>= gotoIf < goto

If [200] = [201] then goto 035 –Data location 200,201 –Program location If [702] < 0 then goto 100

22 Moving Do we need a ‘moving operation’? [150]  [280] But this is slow!

23 +0 for move (why +0 and not +6 ?) Easy-to-remember series of operations –Move,add, multiply,square –Application of Regularity Principle

24 Indexing and Loops We need –Address of the array –Address of the index variable So, we used two of the three address fields in the instruction.

25 What operation(s) shall we define on arrays? Move them to or from other locations +6 xxx iii zzz x i  z -6 xxx yyy iii x  y i

26 Examples for indexing We have a 100-element array beginning at location 250 in data memory, and location 050 contains 17, Move [267] to Move [722] to 267

27 Initialize, increment, and test index variables We can use instructions which already exist, but –They are floating point operations –Indexing is used very often

28 The Abstraction Principle Avoid requiring something to be stated more than once; factor out the recurring pattern. It is a corollary of Automation Principle.

29 +7 for increment and test indices We need to know –The location of the index –The location of the upper bound for the loop –The location where the loop begins

30 +7 iii nnn ddd –iii : address of the index, –nnn : address of the upper bound, –ddd : location of the beginning of the loop –[iii]+ +, if [iii] < [nnn] then go to ddd,

31 Input-Output +8 Read a card containing one 10-digit number into a specified memory location. -8 Print the contents of a memory location

32 Pseudo-Code operations table Page 19

33 Program Structure How do we arrange to get the program loaded into memory? How do we initialize locations in the data memory? How do we provide input data for the program?

34 Program Structure Initial data values Program instructions Input data (Declarations)

35 An example, page 20

36 Implementation Automatic Execution is patterned after manual execution

37 The read-execute cycle is the heart of an iterative interpreter 1.Read the next instruction. 2.Decode the instruction. 3.Execute the operation. 4.Continue from step 1 with the next instruction.

38 Where shall we add IP := IP + 1 ?

39 Interpreters simplify debugging. –Add an instruction to the interpreter to get a trace of the execution of the program. Statement labels simplify coding. –Using absolute locations in pseudo-code instruction, make changes error-prone and tedious.

40 The Labeling Principle Do not require the user to know the absolute position of an item in a list. Instead, associate labels with any position that must be referenced elsewhere.

41 Label definition operator -7 0LL It is a non-executable statement. It is a declaration and say bind a symbolic label to an absolute location. So we will have: +4 xxx yyy 0LL, Look at page 27

42 How can we interpret labels? Label tables We have to know –all the labels are defined once, –if there is any referencing to undefined labels, –if a label is defined in more than one place.

43 Variables can be processed like labels We can have variable declarations in Initial- data section of the program: +0 sss nnn 000 d ddd ddd ddd Declare a storage area with symbolic name sss, nnn locations long, initialized to all d ddd ddd ddd

Declares a 150-element array, identified by the label 666, Initialized to all

A simple variable, labeled 111, is declared and initialized to zero.

46 For each declaration, the loader keeps track of the next available memory location, and binds the symbolic variable number to that location. Binding time of the declaration is load time.

47 Loader also is doing: storage allocation

48 Binding times? X:=X+10 –Value of a variable? –Type of X? –Valid range of values for a variable (a type)? –Set of possible types for variable X? –Representation of the constant 10? –Properties of operator +?

49 Classes of Binding Times Execution time Translation time Language implementation time Language definition time

50 The interpreter can record in the symbol table the size of the array and so,can check each reference to the array. => Prevents a violation of the program’s intended structure.

51 The Security Principle No program that violates the definition of the language, or its own intended structure, should escape detection. C.A.R. Hoare

52 The idea presented here are easily extended to a symbolic pseudo-code. Declare declarations Begin statements End;

53 Fixed format statements …. Example in page 32

54 The Labeling Principle Do not require the user to know the absolute position of an item in a list. Instead, associate labels with any position that must be referenced elsewhere.

55 Programming Languages as Tools Tools are both amplifying and reductive –A stick to knock the fruit down, instead of your hands Fascination and fear are common reactions to new tools With mastery, you no more feel the tool as an external, additional object Programming languages influence focus and action –Writing by pen, a typewriter, a word processor

56 Conclusion Pseudo-code interpreters simplified programming –A virtual machine: more regular, higher level (abstract, automated), more secure, simplify debugging Floating-point hardware made interpreters unattractive –Computer time was more expensive than programmer time Libraries led to the idea of compiling routines –Up to mid 1950: still important programming had to be done in assembly language

57 Exercises