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.

Slides:



Advertisements
Similar presentations
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
Advertisements

ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
The Assembly Language Level
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
Lab6 – Debug Assembly Language Lab
ITEC 352 Lecture 17 Functions in Assembly. Functions + Assembly Review Questions? Branching Call / Jump Reminder exam on Friday, project due next Friday.
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Assembly.
CPS4200 System Programming 2007 Spring 1 Systems Programming Chapter 2 Assembler I.
CPSC Compiler Tutorial 9 Review of Compiler.
Assemblers Dr. Monther Aldwairi 10/21/20071Dr. Monther Aldwairi.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
The Assembly Language Level
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
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.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved The Assembly Language Level.
Assembly & Machine Languages
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
ITEC 352 Lecture 11 ISA - CPU. ISA (2) Review Questions? HW 2 due on Friday ISA –Machine language –Buses –Memory.
10-1 Chapter 10 - Advanced Computer Architecture Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring.
4-1 Chapter 4 - The Instruction Set Architecture Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring.
A Simple Two-Pass Assembler
Instruction Set Architecture
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
4-1 Chapter 4 - The Instruction Set Architecture Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of.
ITEC 352 Lecture 20 JVM Intro. Functions + Assembly Review Questions? Project due today Activation record –How is it used?
1 History of compiler development 1953 IBM develops the 701 EDPM (Electronic Data Processing Machine), the first general purpose computer, built as a “defense.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
ITEC 352 Lecture 18 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Exam –Average 76 Methods for functions in assembly.
CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.
5-1 Chapter 5 - Languages and the Machine Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of Computer.
EEC4133 Computer Organization & Architecture Chapter 6: Languages and the Machine by Muhazam Mustapha, May 2014.
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.
6-1 Chapter 6 - Languages and the Machine Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer.
Chapter 1 Computer architecture Languages: machine, assembly, high
Languages and the Machine Chapter 5 CS221. Topics The Compilation Process The Assembly Process Linking and Loading Macros We will skip –Case Study: Extensions.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
Richard P. Paul, SPARC Architecture, Assembly Language Programming, and C Chapter 7 – Subroutines These are lecture notes to accompany the book SPARC Architecture,
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.
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.
1 Assemblers System Programming by Leland L. Beck Chapter 2.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
2 : Assembler 1 Chapter II: Assembler Chapter goal: r Introduce the fundamental functions that any assembler must perform. m Assign machine address m Translate.
Chapter# 6 Code generation.  The final phase in our compiler model is the code generator.  It takes as input the intermediate representation(IR) produced.
Chapter 1 Introduction. Chapter 1 -- Introduction2  Def: Compiler --  a program that translates a program written in a language like Pascal, C, PL/I,
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
ITEC 352 Lecture 19 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Stacks Function activation / deactivation.
1 The Instruction Set Architecture September 27 th, 2007 By: Corbin Johnson CS 146.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Hello world !!! ASCII representation of hello.c.
Operating Systems A Biswas, Dept. of Information Technology.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
Lecture 3 Translation.
Overview of Instruction Set Architectures
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
The Assembly Language Level
Compiler Construction
CSCE Fall 2013 Prof. Jennifer L. Welch.
by Richard P. Paul, 2nd edition, 2000.
A Simple Two-Pass Assembler
System Programming by Leland L. Beck Chapter 2
CSCE Fall 2012 Prof. Jennifer L. Welch.
Chapter 1 Computer architecture Languages: machine, assembly, high
Chapter 6 Programming the basic computer
Presentation transcript:

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 of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 5: Languages and the Machine

5-2 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents 5.1 The Compilation Process 5.2 The Assembly Process 5.3 Linking and Loading 5.4 Macros 5.5 Case Study: Extensions to the Instruction Set – The Intel MMX™ and Motorola AltiVec™ SIMD Instructions

5-3 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring The Compilation Process Compilation translates a program written in a high level language into a functionally equivalent program in assembly language. Consider a simple high-level language assignment statement: A = B + 4; Steps involved in compiling this statement into assemby code: — Reducing the program text to the basic symbols of the language (for example, into identifiers such as A and B), denotations such as the constant value 4, and program delimiters such as = and +. This portion of compilation is referred to as lexical analysis. — Parsing symbols to recognize the underlying program structure. For the statement above, the parser must recognize the form: Identifier “=” Expression, where Expression is further parsed into the form: Identifier “+” Constant. Parsing is sometimes called syntactic analysis.

5-4 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring The Compilation Process — Name analysis: associating the names A and B with particular program variables, and further associating them with particular memory locations where the variables are located at run time. — Type analysis: determining the types of all data items. In the example above, variables A and B and constant 4 would be recognized as being of type int in some languages. Name and type analysis are sometimes referred to together as semantic analysis: determining the underlying meaning of program components. — Action mapping and code generation: associating program statements with their appropriate assembly language sequence. In the statement above, the assembly language sequence might be as follows: ld [B], %r0, %r1! Get variable B into a register. add %r1, 4, %r2! Compute the value of the expression st %r2, %r0, [A]! Make the assignment.

5-5 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring The Assembly Process The process of translating an assembly language program into a machine language program is referred to as the assembly process. Production assemblers generally provide this support: — Allow programmer to specify locations of data and code. — Provide assembly-language mnemonics for all machine instructions and addressing modes, and translate valid assembly language statements into the equivalent machine language. — Permit symbolic labels to represent addresses and constants. — Provide a means for the programmer to specify the starting address of the program, if there is one; and provide a degree of assemble-time arithmetic. — Include a mechanism that allows variables to be defined in one assembly language program and used in another, separately assembled program. — Support macro expansion.

5-6 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Assembly Example We explore how the assembly process proceeds by “hand assembling” a simple ARC assembly language program.

5-7 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Instruc- tion For- mats and PSR Format for the ARC

5-8 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Assembled Code ld [x], %r ld [y], %r addcc %r1,%r2,%r st %r3, [z] jmpl %r15+4, %r

5-9 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Forward Referencing An example of forward referencing:

5-10 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring

5-11 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Assembled Program

5-12 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Linking: Using.global and.extern A.global is used in the module where a symbol is defined and a.extern is used in every other module that refers to it.

5-13 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Linking and Loading: Symbol Tables Symbol tables for the previous example:

5-14 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Example ARC Program

5-15 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Macro Definition A macro definition for push:

5-16 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Recursive Macro Expansion

5-17 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Intel MMX (MultiMedia eXtensions) Vector addition of eight bytes by the Intel PADDB mm0, mm1 instruction:

5-18 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Intel and Motorola Vector Registers Intel “aliases” the floating point registers as MMX registers. This means that the Pentium’s 8 64-bit floating-point registers do double- duty as MMX registers. Motorola implements bit vector registers as a new set, separate and distinct from the floating-point registers.

5-19 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring MMX and AltiVec Arithmetic Instructions

5-20 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Comparing Two MMX Byte Vectors for Equality

5-21 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Conditional Assignment of an MMX Byte Vector

5-22 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Addressing Modes Four ways of computing the address of a value in memory: (1) a constant value known at assembly time, (2) the contents of a register, (3) the sum of two registers, (4) the sum of a register and a constant. The table gives names to these and other addressing modes.

5-23 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Subroutine Linkage – Registers Subroutine linkage with registers passes parameters in registers.

5-24 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Subroutine Linkage – Data Link Area Subroutine linkage with a data link area passes parameters in a separate area in memory. The address of the memory area is passed in a register (%r5 here).

5-25 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Subroutine Linkage – Stack Subroutine linkage with a stack passes parameters on a stack.

5-26 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Stack Linkage Example A C program illustrates nested function calls.

5-27 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Stack Linkage Example (cont’) (a-f) Stack behavior during execution of the program shown in previous slide.

5-28 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Stack Linkage Example (cont’) (g-k) Stack behavior during execution of the C program shown previously.

5-29 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Input and Output for the ISA Memory map for the ARC, showing memory mapped I/O.

5-30 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Touchscreen I/O Device A user selecting an object on a touchscreen:

5-31 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Flowchart for I/O Device Flowchart illustrating the control structure of a program that tracks a touchscreen.

5-32 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Java Virtual Machine Architecture

5-33 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Java Pro- gram and Com- piled Class File

5-34 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring A Java Class File

5-35 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring A Java Class File (Cont’)

5-36 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Byte Code for Java Program Disassembled byte code for previous Java program. LocationCodeMnemonicMeaning 0x00e30x10bipushPush next byte onto stack 0x00e40x0f15Argument to bipush 0x00e50x3cistore_1Pop stack to local variable 1 0x00e60x10bipushPush next byte onto stack 0x00e70x099Argument to bipush 0x00e80x3distore_2Pop stack to local variable 2 0x00e90x03iconst_0Push 0 onto stack 0x00ea0x3eistore_3Pop stack to local variable 3 0x00eb0x1biload_1Push local variable 1 onto stack 0x00ec0x1ciload_2Push local variable 2 onto stack 0x00ed0x60iaddAdd top two stack elements 0x00ee0x3eistore_3Pop stack to local variable 3 0x00ef0xb1returnReturn