The Assembly Language Level. Chapter 7

Similar documents
The A ssembly Assembly Language Level Chapter 7 1

Computer Organization & Assembly Language Programming

Compiler, Assembler, and Linker

CS2304-SYSTEM SOFTWARE 2 MARK QUESTION & ANSWERS. UNIT I INTRODUCTION

Monday, February 16, 2015

AS-2883 B.Sc.(Hon s)(fifth Semester) Examination,2013 Computer Science (PCSC-503) (System Software) [Time Allowed: Three Hours] [Maximum Marks : 30]

Intermediate Programming & Design (C++) Notation

CS 4201 Compilers 2014/2015 Handout: Lab 1

UNIT I - INTRODUCTION

Chapter 3 Loaders and Linkers

Chapter 9 Memory Management Main Memory Operating system concepts. Sixth Edition. Silberschatz, Galvin, and Gagne 8.1

Homework #6 Problems 1, 5, 9, 11, 13, 23 from textbook.

PSD1C SYSTEM SOFTWAE UNIT: I - V PSD1C SYSTEM SOFTWARE

Chapter 2. Assembler Design

Chapter 3 Loaders and Linkers

sarm User Guide Note that a space must appear before the operation field because any word beginning in the first column is a label

Computer Organization & Assembly Language Programming. CSE 2312 Lecture 15 Addressing and Subroutine

UNIT II ASSEMBLERS. Figure Assembler

Model Answer of System Software B. Tech. (4 th Semester Examination) Paper Code: AR Branch: Information Technology

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine


EECE416 :Microcomputer Fundamentals and Design. X86 Assembly Programming Part 1. Dr. Charles Kim

Instruction : A command to the microprocessor to perform a given task on specified data. Each instruction has two parts

CPU ARCHITECTURE. QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system.

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER-15 EXAMINATION Model Answer Paper

Chapter 3 Loaders and Linkers

MIPS (SPIM) Assembler Syntax

UNIT III LOADERS AND LINKERS

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

CSI 402 Lecture 5 (Assemblers Continued) 5 1 / 18

A Set Of Machine Language Instructions For A Program Is Called Source Code >>>CLICK HERE<<<

Chapter 3 Loaders and Linkers -- Loader Design Options

M2 Instruction Set Architecture

ECE 15B COMPUTER ORGANIZATION

Chapter 7 Assembly Language

Short Notes of CS201

ELEG3924 Microprocessor

Assemblers. System Software by Leland L. Beck. Chapter 2

OCR J276 GCSE Computer Science

COMPILER DESIGN LEXICAL ANALYSIS, PARSING

CS201 - Introduction to Programming Glossary By

Assembler. Lecture 8 CS301

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

Introduction to Programming

ASSIST Assembler Replacement User s Guide

CSCI341. Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory

Unit 2 -- Outline. Basic Assembler Functions Machine-dependent Assembler Features Machine-independent Assembler Features Assembler Design Options

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Hardware Level Organization


QUESTION BANK CHAPTER 1 : OVERVIEW OF SYSTEM SOFTWARE. CHAPTER 2: Overview of Language Processors. CHAPTER 3: Assemblers

A Fast Review of C Essentials Part I

Principles of Compiler Design

Q. P. Code : b. Draw and explain the block dig of a computer with microprocessor as CPU.

Assembly Language programming (1)

8086 ALP TOOLS (CH 2) CHAPTER 2

From Source to Execution:

Högnivåspråk och översättning

1 5. Addressing Modes COMP2611 Fall 2015 Instruction: Language of the Computer

ORG ; TWO. Assembly Language Programming

PESIT SOUTHCAMPUS 10CS52: SYSTEM SOFTWARE QUESTION BANK

Faculty of Engineering Systems & Biomedical Dept. First Year Cairo University Sheet 6 Computer I

The C Implementation of Icon; A Tour Through Version 5* Ralph E. Griswold William H. Mitchell Stephen B. Wampler. TR 83-1 la ABSTRACT

INT 21H and INT 10H Programming and Macros

2. Define Instruction Set Architecture. What are its two main characteristics? Be precise!

MODBUS Protocol for MiCOM P30 Series

Design and Implementation of a FPGA-based Pipelined Microcontroller

Chapter 1: Background

AC59/AT59 OPERATING SYSTEMS & SYSTEMS SOFTWARE DECEMBER 2012

Computers Programming Course 5. Iulian Năstac

The Big Picture. Linker. Module 1. Module 2. One Module. Module 3. Module 4

CS61C : Machine Structures

MOTOROLA DIGITAL SIGNAL PROCESSING DEVELOPMENT SOFTWARE MOTOROLA DSP ASSEMBLER REFERENCE MANUAL

The Software Stack: From Assembly Language to Machine Code

ECE260: Fundamentals of Computer Engineering

Machine Code and Assemblers November 6

CS1203-SYSTEM SOFTWARE UNIT I-INTRODUCTION

Chapter 04: Instruction Sets and the Processor organizations. Lesson 11: Generation of Memory Addresses and Addressing Modes

CS2422 Assembly Language & System Programming

Main Memory. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & APPS 1

A Plan 9 C Compiler for RISC-V

Assembler Directives

Machine Language, Assemblers and Linkers"

Hardware Address Binding Memory Allocation References. Physical Memory. Daniel Bosk 1

Systems Architecture I

Wednesday, September 21, 2016

Bootloader Design Techniques for MCUs. Jacob Beningo, CSDP

Macro Assembler. Defini3on from h6p://

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

UNIT 1: MACHINE ARCHITECTURE

CSCI 402: Computer Architectures. Instructions: Language of the Computer (4) Fengguang Song Department of Computer & Information Science IUPUI

Topic Notes: MIPS Instruction Set Architecture

Harry H. Porter, 2006

Chapter 8: Memory Management. Operating System Concepts with Java 8 th Edition

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

Relationship between Pointers and Arrays

Transcription:

The Assembly Language Level Chapter 7

Definitions Translator Converts user program to another language Source language Language of original program Target language Language into which source code is converted Object code or executable binary Interpretation Source translated, immediately executed

Steps of Translation 1. Generation of equivalent program in target language 2. Execution of newly generated program Happens only after Step 1 completed Contrast to interpretation

Assembly Language One-to-one correspondence between machine instructions and statements in assembly program Provides better performance and access to the machine Statements can contain: Label field Operation (opcode) field Operand field Comments field

Format of an Assembly Language Statement (1) Figure 7-1. Computation of N = I + J. (a) x86.

Format of an Assembly Language Statement (2) Figure 7-1. Computation of N = I + J. (b) Motorola 680x0.

Format of an Assembly Language Statement (3) Figure 7-1. Computation of N = I + J. (c) SPARC.

Pseudoinstructions (1) Figure 7-2. Some of the pseudoinstructions available in the MASM assembler (MASM).

Pseudoinstructions (2) Figure 7-2. Some of the pseudoinstructions available in the MASM assembler (MASM).

Macro Definition Macro header giving name of macro being defined Text body of the macro Pseudoinstruction marking end of definition

Macro Call, Expansion (1) Figure 7-3. Assembly language code for interchanging P and Q twice. (a) Without a macro. (b) With a macro.

Macro Call, Expansion (2) Figure 7-4. Comparison of macro calls with procedure calls.

Macros with Parameters Figure 7-5. Nearly identical sequences of statements. (a) Without a macro. (b) With a macro.

Pass 1 of Two Pass Assembler Figure 7-6. The instruction location counter (ILC) keeps track of the address where the instructions will be loaded in memory. In this example, the statements prior to MARIA occupy 100 bytes.

Tables Kept by Pass 1 Symbol table Pseudoinstruction table Opcode table Literal table

Information Kept in Symbol Table Length of data field associated with symbol Relocation bits Is the symbol is accessible outside the procedure

Example Symbol Table Figure 7-7. A symbol table for the program of Fig. 7-6.

Opcode Table Figure 7-8. A few excerpts from the opcode table for an x86 assembler

Results of Pass One (1) Figure 7-9. Pass one of a simple assembler.

Results of Pass One (2) Figure 7-9. Pass one of a simple assembler.

Pass Two (1) Figure 7-10. Pass two of a simple assembler

Pass Two (2) Figure 7-10. Pass two of a simple assembler

Dealing with Typical Code Errors Examples: A symbol has been used but not defined A symbol has been defined more than once The name in the opcode field is not a legal opcode An opcode is not supplied with enough operands An opcode is supplied with too many operands An number contains an invalid character like 143G6 Illegal register use (e.g., a branch to a register) The END statement is missing

The Symbol Table (1) Figure 7-11. Hash coding. (a) Symbols, values, and the hash codes derived from the symbols.

The Symbol Table (2) Figure 7-11. Hash coding. (b) Eight-entry hash table with linked lists of symbols and values.

Linking and Loading Figure 7-12. Generation of an executable binary program from a collection of independently translated source procedures requires using a linker.

Tasks Performed by the Linker (1) Figure 7-13. Each module has its own address space, starting at 0.

Tasks Performed by the Linker (2) Constructs table of all object modules, lengths Assigns base address to each object module Relocates all instructions that reference memory Links instructions that reference other procedures

Tasks Performed by the Linker (3) Figure 7-14. Object module table constructed in step 1 shown for the modules of Fig. 7-14. Gives name, length, and starting address of each module.

Structure of an Object Module (2) Figure 7-14. (a) object modules of Fig. 7-13 after being positioned in the binary image but before being relocated and linked.

Structure of an Object Module (3) Figure 7-14. (b) The same object modules after linking and after relocation has been performed.

Structure of an Object Module (1) Figure 7-15. The internal structure of an object module produced by a translator. The Identification field comes first.

Binding Time and Dynamic Relocation (1) Possibilities: When program is written When program is translated When program is linked but before it is loaded When program is loaded When a base register used for addressing is loaded When instruction containing the address is executed

Binding Time and Dynamic Relocation (2) Figure 7-16. The relocated binary program of Fig. 7-14(b) moved up 300 addresses. Many instructions now refer to an incorrect memory address.

Dynamic Linking (1) Figure 7-17. Dynamic linking. (a) Before EARTH is called.

Dynamic Linking (2) Figure 7-17. Dynamic linking. (b) After EARTH has been called and linked.

Dynamic Linking (3) Figure 7-18. Use of a DLL file by two processes.

End Chapter 7