Translating Assembly Language to Machine Language.

Slides:



Advertisements
Similar presentations
Chapter 11 Implementing an Assembler and a Linker Using C++ and Java.
Advertisements

The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
Princess Sumaya Univ. Computer Engineering Dept. Chapter 2: IT Students.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Instruction Set Architecture Classification According to the type of internal storage in a processor the basic types are Stack Accumulator General Purpose.
Cpe 252: Computer Organization1 Lo’ai Tawalbeh Programming The Basic Computer Chapter 6:
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
4/23/2015Engineering Problem Solving with C++ second edition, J. ingber 1 Engineering Problem Solving with C++, Etter/Ingber Chapter 1.
The Assembly Language Level
19-1 Programming… The Pencil and Paper Computer The Pencil & Paper Instruction Set: (table on p148) The Operand specifies a memory location.
LAB 9 Simulator Chap 14 REED. Datapath Simulator accompanying the text is a datapath simulator a.k.a. the Knob & Switch Computer developed by Grant Braught.
Program Translation Module 6. Mid-Term Results.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Computer Organization
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen.
4-1 Chapter 4 - The Instruction Set Architecture Department of Information Technology, Radford University ITEC 352 Computer Organization Principles of.
Computer Science 101 Assembly Language. Problems with Machine Language Uses binary - No English-like words to make it more readable Uses binary - No English-like.
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.
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 Science 101 How the Assembler Works. Assembly Language Programming.
Assembly Language A Brief Introduction. Unit Learning Goals CPU architecture. Basic Assembler Commands High level Programming  Assembler  Machine Language.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
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.
I/O Memory Reg File ALU Program Counter Instruction Register Control Interconnect Control 1)PC contains mem address of Instruction, 2)From memory, instr.
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
Computer Science 210 Computer Organization Control Circuits Decoders and Multiplexers.
 Lecture 2 Processor Organization  Control needs to have the  Ability to fetch instructions from memory  Logic and means to control instruction sequencing.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
An Example Architecture. A Paper Computer - Woody Woody's characteristics Word size – 8 bits One word.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Sahar Mosleh California State University San MarcosPage 1 Assembly language and Digital Circuit By Sahar Mosleh California State University San Marcos.
Lecture # 15. Mealy machine A Mealy machine consists of the following 1. A finite set of states q 0, q 1, q 2, … where q 0 is the initial state. 2. An.
8086/8088 Instruction Set, Machine Codes and Addressing Modes.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 4 - Assembler 1.
CS501 Advanced Computer Architecture Lecture 29 Dr.Noor Muhammad Sheikh.
1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003.
Invitation to Computer Science 6th Edition
PROGRAMMING THE BASIC COMPUTER
Addressing Modes in Microprocessors
Computer Science 210 Computer Organization
CPU Organisation & Operation
Computer Science 210 Computer Organization
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
More Devices: Control (Making Choices)
PROGRAMMING THE BASIC COMPUTER
Design of the Control Unit for Single-Cycle Instruction Execution
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Compiler Construction
Chapter 7 LC-2 Assembly Language.
Computer Programming Machine and Assembly.
Assembler CASE Tool.
Chap. 6 Programming the Basic Computer
MIPS Instruction Encoding
MIPS Instruction Encoding
CS 286 Computer Organization and Architecture
Program Execution.
Chapter 6 Programming the basic computer
CS334: MIPS language _Mars simulator Lab 2_1
Computer Architecture Assembly Language
CPSC 171 Introduction to Computer Science
Presentation transcript:

Translating Assembly Language to Machine Language

An example program Read*Read a value from input unit to Data Reg CopyTo Data1*Put value in memory at label Data1 CopyFrom Extra*Value at mem. loc. Extra to Data Reg Add Data1* Sum of Data Reg and Data1 Print* Send Sum to output unit Stop Extra5* Value to sum Data10* Storage for input value Notes: Parts of lines appearing after "*" are comments Labels in left hand column are names associated with the corresponding value

Instructions and addresses 00000Read 00001CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 Notes: Each instruction will occupy one location in Woody's main memory Comments are ignored in the translation process, so they have been removed here

Pass 1: Create a symbol table 00000Read 00001CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress

Pass 1: Create a symbol table 00000Read 00001CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110

Pass 1: Create a symbol table 00000Read 00001CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110

Pass 1: Create a symbol table 00000Read 00001CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data100111

Pass 2: "Assemble" the machine code 00000Read 00001CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 1

Pass 2: "Assemble" the machine code 00000Read 00001CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 2

Pass 2: "Assemble" the machine code 00000Read 00001CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 3

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 4

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 5

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 6

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 7

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 8

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 9

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 10

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 11

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra 00011Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 12

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 13

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 14

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 15

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 16

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 17

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 18

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 19

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 20

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 21

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print 00101Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 22

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 23

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 24

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 25

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop 00110Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 26

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 27

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop Extra Data10 LabelAddress Extra00110 Data Machine Code InstructionOp Code CopyFrom000 CopyTo001 Add010 Subtract011 Read100 Print101 IfNegGoto110 Stop111 28

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop Extra Data10 LabelAddress Extra00110 Data Machine Code Literal integer values are translated into binary using the signed magnitude representation 29

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop Extra Data10 LabelAddress Extra00110 Data Machine Code 5 10 = in 8 bit signed magnitude representation 30

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop Extra Data10 LabelAddress Extra00110 Data Machine Code 5 10 = in 8 bit signed magnitude representation 31

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop Extra Data10 LabelAddress Extra00110 Data Machine Code 32

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop Extra Data LabelAddress Extra00110 Data Machine Code 33

Pass 2: "Assemble" the machine code 00000Read CopyTo Data CopyFrom Extra Add Data Print Stop Extra Data LabelAddress Extra00110 Data Machine Code This sequence of values, stored in a file, forms the executable for this program.

Observations This is a very mechanical process. The program that does this job is called an assembler. Each different computer architecture (Intel Pentium, PowerPC, IBM Cell, etc.) has its own assembly language. The instructions in assembly language correspond one-to-one with instructions in the target architecture's machine language. An executable for a program consists of a file containing the machine language instructions for the program.