Ass. Prof. Dr Masri Ayob TK 6123 Lecture 13: Assembly Language Level (Level 4)

Slides:



Advertisements
Similar presentations
The 8051 Microcontroller and Embedded Systems
Advertisements

Cpe 252: Computer Organization1 Lo’ai Tawalbeh Programming The Basic Computer Chapter 6:
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
The Assembly Language Level
Macro Processor.
Machine Independent Assembler Features
Lab6 – Debug Assembly Language Lab
Chih-Hung Wang Chapter 2: Assembler (Part-1) 參考書目 Leland L. Beck, System Software: An Introduction to Systems Programming (3rd), Addison-Wesley, 1997.
TK 2633 Microprocessor & Interfacing
Chapter 3 Assembly Language: Part 1. Machine language program (in hex notation) from Chapter 2.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
An introduction to systems programming
The Assembly Language Level
8051 ASSEMBLY LANGUAGE PROGRAMMING
1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved The Assembly Language Level.
ARM Core Architecture. Common ARM Cortex Core In the case of ARM-based microcontrollers a company named ARM Holdings designs the core and licenses it.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#1) By Dr. Syed Noman.
ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/ ECE265.
Assembler When a source program is a assembly language and the target program is a numerical machine language then the translator is called as a assembler.
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
Chapter 2 Software Tools and Assembly Language Syntax.
Fundamentals of Assembly language
Assembly Language Programming for the MC68HC11. Assembly language programming  Recall the 4 design levels for software development: – Application – High.
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 7: Assembly Language.
A Simple Two-Pass Assembler
MIPS coding. SPIM Some links can be found such as:
CoE3DJ4 Digital Systems Design
ASSEMBLY LANGUAGE. Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Versiion A Machine Code Actual version that will be executed.
1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.
Debug and Assembler By, B.R.Chandavarkar Lect. COMP Department NITK, Surathkal.
Assemblers.
Computer Science 101 How the Assembler Works. Assembly Language Programming.
Chapter 2-2 Assembly Instructions Number Systems Number Systems Assembly Instructions Assembly Instructions Branch Branch Next Lecture Next Lecture  Addressing.
2 : Assembler 1 Chapter II: Assembler Chapter goal: r Introduce the fundamental functions that any assembler must perform. m Assign machine address m Translate.
1 Segments and Pseudo Operations Program Development.
S YSTEMS P ROGRAMMING CHAPTER 2 PROGRAMMING IN ASSEMBLY LANGUAGE Er. Bharadwaj Choudhury.
8086/8088 Instruction Set, Machine Codes and Addressing Modes.
Macro Processors Basic Functions Machine-Independent Features Design Options Implementation Examples.
Ass. Prof. Dr Masri Ayob TK 2123 Lecture 14: Instruction Set Architecture Level (Level 2)
Introduction A computer system includes both hardware and software. The designer should be familiar with both of them. This chapter introduces some basic.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 10 – Loaders.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 11–Macro-Processors.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 4 - Assembler 1.
CS501 Advanced Computer Architecture Lecture 29 Dr.Noor Muhammad Sheikh.
1 CE 454 Computer Architecture Lecture 11 Ahmed Ezzat The Assembly Language Level, Ch-(7.1 – 7.4)
A LECTURE NOTE. Introduction to Programming languages.
PROGRAMMING THE BASIC COMPUTER
Addressing Modes in Microprocessors
Assembly Language programming
System Programming and administration
Assembly Language Ms. V.Anitha AP/CSE SCT
Chapter 3 Machine Language and Assembly Language.
Chapter 3 Machine Language and Assembly Language.
INTRODUCTION ABOUT ASSEMBLY
Assembler Design Options
The Assembly Language Level
Assembler CASE Tool.
COMP2121: Microprocessors and Interfacing
Chapter 4 –Requirements for coding in Assembly Language
A Simple Two-Pass Assembler
Requirements for coding in Assembly Language
Assembler Directives end label end of program, label is entry point
Chapter 6 Programming the basic computer
An introduction to systems programming
Introduction to 8086 Assembly Language
Location Counter (LC) = 0 while line of code <> END if ORG
Presentation transcript:

Ass. Prof. Dr Masri Ayob TK 6123 Lecture 13: Assembly Language Level (Level 4)

3 June 2016Prepared by: Dr Masri Ayob 2 Why Use Assembly Language? Assembly language programming is difficult. Writing a program in assembly language takes much longer than writing the same program in a high-level language. Much longer to debug and much harder to maintain. Why use assembly language? Performance Access to the machine

3 June 2016Prepared by: Dr Masri Ayob 3 Why Use Assembly Language? Performance An expert assembly language programmer can often produce code that is much smaller and faster than a high- level language programmer can. Some application – speed and size are critical. E.g. embedded application (code on a smart card, handphone, etc.) Access to the machine. Some procedure need complete access to the hardware. E.g. low-level interrupt, trap handlers in OS, device controller, etc. This is usually impossible in high-level language.

3 June 2016Prepared by: Dr Masri Ayob 4 Why Use Assembly Language? Comparison of assembly language and high-level language programming, with and without tuning.

3 June 2016Prepared by: Dr Masri Ayob 5 Assembly Language Assembly language: Assembly language is used for most programming because it is extremely difficult to program a microprocessor in its native, that is hexadecimal machine language. Assembler: An assembler is a program that converts software written in symbolic machine language (the source program) into hexadecimal machine language (object program). The primary reason to use assembler is because development and modification are always difficult in machine language.

3 June 2016Prepared by: Dr Masri Ayob 6 Assembly Language Instruction is a command to the microprocessor to perform a given task on specified data. Each instruction has two parts: one is the task to be performed, called the operation code (op-code), the second is the data to be operated on, called the operand. The operand (or data) can be specified in various ways. It may include an internal register or a memory location. In some instructions, the operand is implicit.

3 June 2016Prepared by: Dr Masri Ayob 7 Assembly Language The Two-pass Assembler : Read programme two times. 1. Generate a table of the labels/symbols within the source program. 2. Develop hexadecimal version of the source program. Allow forward addressing (the software can jump ahead to an instruction in a program).

3 June 2016Prepared by: Dr Masri Ayob 8 Assembly Language

3 June 2016Prepared by: Dr Masri Ayob 9 The assembler always assumes that the first instruction of the program is stored at memory address 0000H unless otherwise directed by the ORG command. Assembly Language

3 June 2016Prepared by: Dr Masri Ayob 10 Pass One: The assembler scans the source program during the first pass and generates a table of the labels found within the source program. Each entry in the label table contains the label and the address where the label appears in the program. During the first pass the assembler determines the length of each instruction by updating an internal program counter. This internal program counter allows the assembler to complete the label table by equating each label with the counter. Once the label table is complete the second pass begin. Assembly Language

3 June 2016Prepared by: Dr Masri Ayob 11 Pass Two: During the second pass of the source program, the assembler forms the object program. This occurs by referring to the label table for any labels that appear in the program and to an instruction table. The instruction table contains all the opcodes in both symbolic and machine language forms. The tables help convert the source program into the object program. Assembly Language

3 June 2016Prepared by: Dr Masri Ayob 12 Assembly Language Statement: Format : Label Field. Contains a symbolic memory address that refers to the statement in a program. Labels are optional. Labels are constructed from alphanumeric characters and must begin with any letter of the alphabet. Assembly Language

3 June 2016Prepared by: Dr Masri Ayob 13 Format of an Assembly Language Statement (1) Computation of N = I + J. (a) Pentium 4.

3 June 2016Prepared by: Dr Masri Ayob 14 Format of an Assembly Language Statement (2) Computation of N = I + J. (b) Motorola 680x0.

3 June 2016Prepared by: Dr Masri Ayob 15 Format of an Assembly Language Statement (3) Computation of N = I + J. (c) SPARC.

3 June 2016Prepared by: Dr Masri Ayob 16 Opcode field: This field must contain opcodes. Operand field: May contain register name, data or labels. If more than one of these is present, they must be separated with comma. Data must be encoded as decimal, binary, octal, hexadecimal, or ASCII. ASCII must appear as one of more letters surrounded by apostrophe. Assembly Language

3 June 2016Prepared by: Dr Masri Ayob 17 Operand arithmetic operations. Assembly Language

3 June 2016Prepared by: Dr Masri Ayob 18 Comment field. Must begin with semicolon in most 8085 assemblers and may continue to the end of the line only. Use asterisk * or semicolon ; if the comment should continue into the next line. Example : Assembly Language

3 June 2016Prepared by: Dr Masri Ayob 19 Assembler pseudo operations. Directives to the assembler program that may or may not generate machine code. Examples : END, DB, DW, DS, ORG, EQU, IF, ENDIF, SET, GLB, EXT, TITLE, SPC. All pseudo operations must appear in the opcode field of a statement. Pseudoinstructions

3 June 2016Prepared by: Dr Masri Ayob 20 Define Byte (DB). Defines 8-bit memory data for a program. Multiple one byte data, comma (, ) as a separator. Pseudoinstructions

3 June 2016Prepared by: Dr Masri Ayob 21 Assembly Language : Example

3 June 2016Prepared by: Dr Masri Ayob 22 Origin (ORG). Changes the starting location of the program to another address besides 0000H. Can be used at any place in a program to change the location of the assembled machine language instructions or data. Pseudoinstructions

3 June 2016Prepared by: Dr Masri Ayob 23 Assembly Language : Example

3 June 2016Prepared by: Dr Masri Ayob 24 Define Word (DW). Pseudo operation stores a 16-bit number in the memory for use by a program. Defines no only numeric data but also memory addresses and label. Pseudoinstructions

3 June 2016Prepared by: Dr Masri Ayob 25 Assembly Language : Example

3 June 2016Prepared by: Dr Masri Ayob 26 Define Storage (DS). Reserves space in a program for variable data. Does not place any specific data into the reserved area of memory. Pseudoinstructions

3 June 2016Prepared by: Dr Masri Ayob 27 Assembly Language : Example

3 June 2016Prepared by: Dr Masri Ayob 28 Equate (Equ). Equates a label to another label or value. Note that the EQU statement label does not contain a colon ( : ). Pseudoinstructions

3 June 2016Prepared by: Dr Masri Ayob 29 Assembly Language

3 June 2016Prepared by: Dr Masri Ayob 30 Assembly language programmer frequently need to repeat sequence of instructions several times within a program. Solution: Use subroutine (CALL instruction). Disadvantage: Procedure CALL overhead. Use Macro Easy and efficient solution Is a way to give name to a piece of text. Macro

3 June 2016Prepared by: Dr Masri Ayob 31 Macro Definition, Call, Expansion (1) Assembly language code for interchanging P and Q twice. (a) Without a macro. (b) With a macro. Macro

3 June 2016Prepared by: Dr Masri Ayob 32 Macro Definition, Call, Expansion (2) Comparison of macro calls with procedure calls.

3 June 2016Prepared by: Dr Masri Ayob 33 Macros with Parameters Nearly identical sequences of statements. (a) Without a macro. (b) With a macro.

3 June 2016Prepared by: Dr Masri Ayob 34 Thank you Q&A