Microprocessor and Assembly Language Week-5. System Programming, BCS 6th, IBMS (2017)

Similar documents
Code segment Stack segment

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

Intel 8086 MICROPROCESSOR ARCHITECTURE

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

ADVANCE MICROPROCESSOR & INTERFACING

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

Intel 8086 MICROPROCESSOR. By Y V S Murthy

8086 INTERNAL ARCHITECTURE

Faculty of Engineering Computer Engineering Department Islamic University of Gaza Assembly Language Lab # 2 Assembly Language Fundamentals

Lecture 5:8086 Outline: 1. introduction 2. execution unit 3. bus interface unit

Intel 8086: Instruction Set

icroprocessor istory of Microprocessor ntel 8086:

Introduction to Microprocessor

Arithmetic Instructions

Introduction to IA-32. Jo, Heeseung

UNIT 2 PROCESSORS ORGANIZATION CONT.

INTRODUCTION TO IA-32. Jo, Heeseung

9/25/ Software & Hardware Architecture

The Instruction Set. Chapter 5

EC 333 Microprocessor and Interfacing Techniques (3+1)

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)

Internal architecture of 8086

INTRODUCTION TO MICROPROCESSORS

Basic Execution Environment

CS401 Assembly Language Solved MCQS From Midterm Papers

US06CCSC04: Introduction to Microprocessors and Assembly Language UNIT 1: Assembly Language Terms & Directives

Microcomputer Architecture..Second Year (Sem.2).Lecture(2) مدرس المادة : م. سندس العزاوي... قسم / الحاسبات

Signed number Arithmetic. Negative number is represented as

CC411: Introduction To Microprocessors

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

Chapter Three Addressing Mode MOV AX, BX

Assembly Language. Dr. Esam Al_Qaralleh CE Department Princess Sumaya University for Technology. Overview of Assembly Language

Complex Instruction Set Computer (CISC)

Lecture 5: Computer Organization Instruction Execution. Computer Organization Block Diagram. Components. General Purpose Registers.

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

Module 3 Instruction Set Architecture (ISA)

EC-333 Microprocessor and Interfacing Techniques

Computer Architecture 1 ح 303

1. Introduction to Assembly Language

16-Bit Intel Processor Architecture

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

ORG ; TWO. Assembly Language Programming

A Presentation created By Ramesh.K Press Ctrl+l for full screen view

EEM336 Microprocessors I. Data Movement Instructions

PESIT Bangalore South Campus

Summer 2003 Lecture 4 06/14/03

CS401 Assembly Language Solved Subjective MAY 03,2012 From Midterm Papers. MC

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

Addressing Modes on the x86

if 2 16bit operands multiplied the result will be

Experiment 3 3 Basic Input Output

PRACTICAL WORKBOOK. Department of Computer Engineering University of Lahore. Designed and Compiled by : Engineer Zahid Muneer. Batch.

Chapter 2 COMPUTER SYSTEM HARDWARE


Computer Architecture and System Software Lecture 06: Assembly Language Programming

Basic Assembly SYSC-3006

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

Hardware and Software Architecture. Chapter 2

Assembler Programming. Lecture 2

Assembly Language. Lecture 2 x86 Processor Architecture

CS401 - Computer Architecture and Assembly Language Programming Glossary By

Chapter 3: Addressing Modes

Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee

Computer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU)

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Lecture 9. INC and DEC. INC/DEC Examples ADD. Arithmetic Operations Overflow Multiply and Divide

UNIT-I. 1.Draw and explain the Architecture of a 8085 Microprocessor?

Tutorial Letter 103/3/2012 Computer Organization COS2621 Semesters 1 & 2

Assembling, Linking and Executing 1) Assembling: .obj obj .obj.lst .crf Assembler Types: a) One pass assembler:

Ex : Write an ALP to evaluate x(y + z) where x = 10H, y = 20H and z = 30H and store the result in a memory location 54000H.

8088/8086 Programming Integer Instructions and Computations

Moodle WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics

Assembly Language LAB

3.1 DATA MOVEMENT INSTRUCTIONS 45

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

complement) Multiply Unsigned: MUL (all operands are nonnegative) AX = BH * AL IMUL BH IMUL CX (DX,AX) = CX * AX Arithmetic MUL DWORD PTR [0x10]

Chapter Four Instructions Set

8086 Programming. Multiplication Instructions. Multiplication can be performed on signed and unsigned numbers.

The x86 Architecture

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

CS-202 Microprocessor and Assembly Language

LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS

The Microprocessor and its Architecture

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit

Section 001. Read this before starting!

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

Lesson 1. Fundamentals of assembly language

Computer Architecture and System Software Lecture 04: Floating Points & Intro to Assembly

CS 16: Assembly Language Programming for the IBM PC and Compatibles

EE2007 Microprocessor systems.

Computer Architecture and System Software Lecture 07: Assembly Language Programming

CG2007 Microprocessor systems.

WINTER 12 EXAMINATION Subject Code : Model Answer Page No : / N. a) Describe the function of SID and SOD pins of 8085 microprocessor

Kingdom of Saudi Arabia Ministry of Higher Education. Taif University. Faculty of Computers & Information Systems

Arithmetic and Logic Instructions And Programs

CS499. Intel Architecture

Transcription:

Microprocessor and Assembly Language Week-5 System Programming, BCS 6th, IBMS (2017)

High Speed Memory Registers CPU store data temporarily in these location CPU process, store and transfer data from one component to another with the help of registers More registers, High CPU Performance

Registers Size of registers depends on computer architecture Size of register is called Word Register is fastest (Nearer and inside CPU) Cache RAM HD is slowest System Programming, BCS 6th, IBMS (2017)

Registers Collection of Flip-Flops One Flip-Flop can store only one bit Flip-flop is a memory unit for single bit Early computers have 8-bits register then 16, 32 and now majority have 64 bits register System Programming, BCS 6th, IBMS (2017)

CPU Registers The general-purpose registers are primarily used for arithmetic and data movement. All of these registers can be further extended to 32 bits and 64 bits segment registers can not be extended which always occupy 16 bits. The extended register names begin with the letter E. For 64 bits R-prefix is added System Programming, BCS 6th, IBMS (2017)

32 bit General Purpose Registers System Programming, BCS 6th, IBMS (2017)

General-Purpose Registers (1) The AX, DX, CX, BX, BP, SP, DI, and SI registers are 16-bit general-purpose registers, used for temporary data storage. Since the processor accesses registers more quickly than it accesses memory, you can make your programs run faster System Programming, BCS 6th, IBMS (2017)

General-Purpose Registers (2) The processor can access four of the general registers AX, BX, CX, and DX These four registers are sometimes referred to as data registers. either as two 8-bit registers or as a single 16-bit register. E.g. System Programming, BCS 6th, IBMS (2017)

8 Bit High / 8 Bit Low Example: If AX contains the 16 bit number 1234h, than: AL contains 34h & AH contains 12h System Programming, BCS 6th, IBMS (2017)

General-Purpose Registers (3) AX: Accumulator Used for arithmetic operations purposes Some of operations such as MUL and DIV, requires one of operands be in the accumulator. Other operations ( ADD and SUB) can be applied to any of register, but are more efficient when working with the accumulator. System Programming, BCS 6th, IBMS (2017)

General-Purpose Registers (3) BX: Base Works as Pointer to base address Holds the address of variable Can also be used for arithmetic operations The only general purpose register used for indirect addressing Example: MOV [BX], AX CX: Count Count for loops, shifts OR Servers as loop counter DX: Data Used for Multiply, divide or I/O purpose It is a convenient place to store data System Programming, BCS 6th, IBMS (2017)

General-Purpose Registers (4) The remaining general-purpose registers can only be accessed using 32-bit or 16-bit names as shown in the following table: They are referred to as index/pointer registers System Programming, BCS 6th, IBMS (2017)

General-Purpose Registers These registers speed up processing of strings and arrays. SI: Source Index Pointer to the current character being read in a string instruction (LOD, MOV) Example: MOV [BX + SI], AX Used in string movement and points to the source string DI: Destination Index Pointer to the current character being written or compared in a string instruction Used in string movement and points to the destination string System Programming, BCS 6th, IBMS (2017)

General-Purpose Registers BP: Base Pointer Pointer to base address (stack) Some other place in the stack It is used for indirect addressing similar to BX SP: Stack Pointer Pointer to top of stack System Programming, BCS 6th, IBMS (2017)

Segment Registers (1) 16 bit Segment registers are CS, DS, SS, or ES. System Programming, BCS 6th, IBMS (2017)

Segment Registers (2) CS (Code Segment) Holds base locations for all executable instructions in a program Contains processor instructions and their immediate operands DS (Data Segment) Normally contains data allocated by the program SS (Stack Segment): Base location of the stack. ES(Extra Segment): Additional base locations for memory variables System Programming, BCS 6th, IBMS (2017)

IP (Instruction Pointer) It is also called program counter The IP register always contains the address of the next Instruction to be executed. Instructions that control program flow (such as calls, jumps, loops, and interrupts) automatically change the instruction pointer System Programming, BCS 6th, IBMS (2017)

Flag Register The FLAGS register is the status register in Intel x86 microprocessors that contains the current state of the processor. This register is 16 bits wide. Its successors, the EFLAGS and RFLAGS registers, are 32 bits and 64 bits wide, respectively. Most of flags are reserved for future use.

CPU Flags---(1) We use the values of CPU status flags to check the outcome of arithmetic operations The value of flag is either 0 or 1 1. Carry Flag The Carry flag indicates unsigned integer overflow. For example, if an instruction has an 8-bit destination operand but the instruction generates a result larger than 11111111 binary, the Carry flag is set.

Carry Flag-Example mov al,0ffh add al,1 CF is set to 1

CPU Flags---(2) 2. Zero flag The Zero flag indicates that an operation produce zero. For example, if an operand is subtracted from another of equal value, the Zero flag is set. Zf=1 if answer is zero..

Zero flag-example Org 100h mov cx,1 sub cx,1 Ret It sets ZF=1

CPU Flags---(3) 3. Sign flag The Sign flag indicates that an operation produced a negative result. If the most significant bit (MSB) of the destination operand is set, the Sign flag is set. SF=1 if MSB is set

Sign flag-example The example subtracts a larger integer (5) from a smaller one (4): Org 100h mov bl,4 sub bl,5 ; bl= -1, SF = 1

CPU Flags---(4) 4. Parity flag The Parity flag indicates whether or not an even number of 1 bits occurs. The even number of 1 s should be in the least significant byte of the destination operand. It occurs immediately after an arithmetic or boolean instruction has executed.

Parity flag-example Org 100h mov al,10001100b add al,00000010b ; AL = 10001110, PF = 1 sub al,10000000b ; AL = 00001110, PF = 0 RET

CPU Flags---(5) 5. Auxiliary Carry The Auxiliary Carry flag is set when a 1 bit carries out of position 3(starts from 0) in the least significant byte of the destination operand. The Auxiliary Carry (AC) flag indicates a carry or borrow out of bit 3 in the destination operand.

Auxiliary Carry-Example ORG 100h mov al,0fh add al,1 RET The sum (10h) or 16 contains a 1 in bit position 4 that was carried out of bit position 3.

CPU Flags---(6) 6. Overflow Flag: The Overflow flag is set when the result of a signed arithmetic operation overflows or underflows the destination operand. The largest possible integer signed byte value is 127; adding 1 to it causes overflow. Subtracting 1 from -128 causes underflow.

Overflow Flag-Example Org 100h mov al,+127 add al,1 ; OF = 1 mov bl,-128 sub bl,1 ; OF = 1

Data Types---(1) Data types, describes a set of values that can be assigned to variables of the given type. The essential characteristic of each type is its size in bits: 8, 16, 32, 48, 64 and so on. Emu8086 and MASM use different notations for defining data types.

Data Types (2) Masm supports: 1. BYTE(DB) : 8-bit unsigned integer. 2. SBYTE: 8-bit signed integer. S stands for signed 3. WORD(DW): 16-bit unsigned integer 4. SWORD: 16-bit signed integer 5. DWORD(DD): 32-bit unsigned integer. D stands for double 6. SDWORD: 32-bit signed integer. SD stands for signed double

Data Types (3) Emu8086 supports: DB: Define Byte DW: Define Word DD: Define Double word

1. BYTE(DB) The BYTE (define byte) and SBYTE (define signed byte) directives allocate storage for one or more unsigned or signed values. Each initializer must fit into 8 bits of storage. Example: value1 db 'A' ; in emu8086 value1 BYTE 'A' ; in masm

BYTE(DB) A question mark (?) initializer leaves the variable uninitialized value BYTE? Value db? o Multiple Initializers list BYTE 10,20,30,40

Example org 100h var db 49 ; var dw 49 can be used but with ax var1 db 55 mov al,var add al,var1 mov dl,al mov ah,2 int 21h Ret Result is h

Equate(Equ) Equ is used to define a constant Var equ 20 ;var=20 Example org 100h var equ 22 mov al,30 add al,var mov dl,al mov ah,6 int 21h ret

Taking Input from Keyboard org 100h ret mov ah,1 ; takes input int 21h ; execution add al,3 mov dl,al mov ah,6 int 21h

End

The End System Programming, BCS 6th, IBMS (2017)