Lecture 05-07 By SHERY KHAN sherykhan186@gmail.com Assembly Language Lecture 05-07 By SHERY KHAN sherykhan186@gmail.com.

Slides:



Advertisements
Similar presentations
Intel 8086.
Advertisements

Programming 8086 – Part IV Stacks, Macros
Array : To store multiple value in one variable, “but value must be homogenous or similar type” is called array. We can say in other word Arrangement of.
Registers of the 8086/ /2002 JNM.
There are two types of addressing schemes:
Assembly Programming Notes for Practical2 Munaf Sheikh
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
Princess Sumaya Univ. Computer Engineering Dept. د. بســام كحـالــه Dr. Bassam Kahhaleh.
Addressing modes The way in which an operand is specified is called the Address Mode.
ICS312 Set 6 Operands. Basic Operand Types (1) Register Operands. An operand that refers to a register. MOV AX, BX ; moves contents of register BX to.
1/2002JNM1 AL 00 Immediate Addressing Mode Mov AL, 3CH AL 3C.
Irvine, Kip R. Assembly Language For Intel-Based Computers TYPE and SIZE Operators TYPE –returns the size, in bytes of a single element of a data label.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
Handout 2 Digital System Engineering (EE-390)
Stack Memory H H FFFFF H FFFFE H SS 0105 SP 0008 TOS BOS BOS = FFFF = 1104F H H 1104F H.
Addressing modes – 1 The way in which an operand is specified is called the Address Mode.
The 8086 Assembly Programming Data Allocation & Addressing Modes
Lecture 2 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Princess Sumaya University
Target Processor Directives , When using.386, the program can only run on 386 and above processors.
Topic – string – Ch. 11 [Marut] Ch. 4 [Brey] String Data Transfer Instructions – The Direction Flag – LODS Instructions – STOS Instructions – MOVS Instructions.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 7: More on Addressing Modes, Structures, and Stack Constantine D. Polychronopoulos Professor, ECE.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
Types of Registers (8086 Microprocessor Based)
Faculty of Engineering, Electrical Department,
Strings, Procedures and Macros
Click to add Title Comunicación y Gerencia Click To add Subtitle Click to add Text Fundamentals of Assembly Language.
Review of Assembly language. Recalling main concepts.
University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Instruction set Architecture
Presentation on Real Mode Memory Addressing
ADDRESSING MODES.
Microprocessor and Assembly Language
Assembly IA-32.
ADDRESSING MODES.
University of Gujrat Department of Computer Science
Assembly Lang. – Intel 8086 Addressing modes – 1
Chapter 3 Addressing Modes
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Microprocessor and Assembly Language
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Introduction to Assembly Language
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
שפת סף וארכיטקטורה של מעבד 8086
8086 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Symbolic Instruction and Addressing
(Array and Addressing Modes)
CNET 315 Microprocessor & Assembly Language
Lecture 06 Programming language.
Computer Architecture CST 250
Chapter 6 –Symbolic Instruction and Addressing
Intel 8086.
CS-401 Computer Architecture and Assembly Language Programming
The JUMP GROUP Unconditional Jump (JMP).
Chapter 8: Instruction Set 8086 CPU Architecture
(Array and Addressing Modes)
CS-401 Computer Architecture & Assembly Language Programming
Presentation transcript:

Lecture 05-07 By SHERY KHAN sherykhan186@gmail.com Assembly Language Lecture 05-07 By SHERY KHAN sherykhan186@gmail.com

Agenda Direct Addressing Size Mismatch ERROR Indirect Addressing LOOPS Register offset Addressing HOW MANY WAYS TO ACCESS MEM Segment Association ASSEMBLY LANGUAGE

Addressing Example ; a program to add three numbers using memory variables [org 0x0100] mov ax, [num1] ; load first number in ax mov bx, [num2] ; load second number in bx add ax, bx ; accumulate sum in ax mov bx, [num3] ; load third number in bx add ax, bx ; accumulate sum in ax mov [num4], ax ; store sum in num4 mov ax, 0x4c00 ; terminate program int 0x21 num1: dw 5 num2: dw 10 num3: dw 15 num4: dw 0 Data if Given to Program ka sath constant cannot be placed in Destination/ & Changed Mov 5 ,ax is Incorrect DB DW 8 bit ,16 bit DB fit 1 byte DW 2 byte reserved Memory Defined 5,10,15 Every thing is Symbol but compiler/ assembler convert into num Adress Memory Location when Translated In ASL if we want to any particular loctaion to Reference it we attach a Symbol to it Readable Come HERE but Asm Covert it to Equivalent Adress 0100 sa start karo us na us ka baad byte Count kar liya when counting byte when reached to label it is Efective Location yeh label kitna offset pa waqi ha it is Adress of Label [] MEMORY OPERAND is num pa memory Access Karni Ha Illegal MEMORY TO MEMORY IS NOT ALLOWED Starting point sa hum next position la skta hain A1 offset is For MEMORY LOCATION B8 for Constant 1700-------------000000017 which Is 23 17+2=19 [] Memory Adresses

Size Mismatch ERROR: ; a program to add three numbers using byte variables [org 0x0100] mov al, [num1] ; load first number in al mov bl, [num1+1] ; load second number in bl add al, bl ; accumulate sum in al mov bl, [num1+2] ; load third number in bl add al, bl ; accumulate sum in al mov [num1+3], al ; store sum at num1+3 mov ax, 0x4c00 ; terminate program int 0x21 num1: db 5, 10, 15, 0 Source and Destination are same Byte AX------dw Al----db Mov Ax,bl illegal Size Nt Illegal 16 Bit MOVE mov ax,[num1] 8 bit Move mov al,[num1] Illegal mov ax,bl Illegal mov [num1] ,[num2] Tricky Illegal mov [num1],5 Ambigous ?? Mov byte [num1],5 or mov word [num1],5 Label is Memory Adress no Size is Attached size is Conveyed by us

Indirect Addressing: ; a program to add three numbers using indirect addressing [org 0x100] mov bx, num1 ; point bx to first number mov ax, [bx] ; load first number in ax add bx, 2 ; advance bx to second number add ax, [bx] ; add second number to ax add bx, 2 ; advance bx to third number add ax, [bx] ; add third number to ax add bx, 2 ; advance bx to result mov [bx], ax ; store sum at num1+6 mov ax, 0x4c00 ; terminate program int 0x21 num1: dw 5, 10, 15, 0 Some Register Hold Data and Also Address from this Address we Access Data Immediate Direct Address Da do us Address jisa who utha la ga now the adress is fix so I cannot change I told that you can pick the content on compile time num1=0017 pa ha it is decided on compile time Now the way I can take the address and change it on run time Iapx88 4 register are used to access the Memory BX,BP,SI ,DI If [] are not used then the value of label itself which is address of label not the content The bx,si bp, di take the square brakets [bx] it mean that the content are accessed which are present in the BX HERE IN ABOVE bx will contain adresses 0117 [bx] mean that it contain content so content is Num1 which is 5 in memory Bx,2 we use word so 2 byte is added so it can point to the next word in memory …………………….. Bx=num1 Ax=[bx] Ax=num1=5 Bx=num1+2=second location Ax=ax+[bx] Ax=5+10=15 Bx=num1+4= third location Ax=15+15=30 …………………………………………the END Bx=num+6=4thlocation Ax=30+0=30

LOOP CONTROL [org 0x0100] mov bx, num1 ; point bx to first number mov cx, 10 ; load count of numbers in cx mov ax, 0 ; initialize sum to zero l1: add ax, [bx] ; add number to ax add bx, 2 ; advance bx to next number sub cx, 1 ; numbers to be added reduced jnz l1 ; if numbers remain add next mov [total], ax ; write back sum in memory mov ax, 0x4c00 ; terminate program int 0x21 num1: dw 10, 20, 30, 40, 50, 10, 20, 30, 40, 50 Jump if NT Zero : Jump to the Location Li1 if the Zero flag is Not Set ZF: the Z flag is Set if the Last mathematical or logical has produced zero in its Destination Mov is nt mathematical or logical so zf is not set But ADD SUB is LOGICAL OR MATHEMATICAL AND OR XOR ETC if Zero in its destination then ZF is Set

Register + offset Addressing a program to add ten numbers using register + offset addressing [org 0x0100] mov bx, 0 ; initialize array index to zero mov cx, 10 ; load count of numbers in cx mov ax, 0 ; initialize sum to zero l1: add ax, [num1+bx] ; add number to ax add bx, 2 ; advance bx to next index sub cx, 1 ; numbers to be added reduced jnz l1 ; if numbers remain add next mov [total], ax ; write back sum in memory mov ax, 0x4c00 ; terminate program int 0x21 num1: dw 10, 20, 30, 40, 50, 10, 20, 30, 40, 50 total: dw 0 JNZ : Jump If the Zero flag is Not Set Cx=0 then zero flag is Set Bx is Increased by 2 and Cx is decreased by 1 according to the Command Conditional Jump is Decision maker in computer oFFSEt+ register= INDIRECT We use Bx,Bp which is Base register class When we use SI,DI INDEX FORMAT for Memory Access MIX MATCH (indirect +base) = Base +offset BX work like a Array Adress Function ka Sath adress ma 2 add karta gya INDEX CHANGED KARTA JAO aur Array ka jo base ha who constant raha & we can pick this from Index Lower BYTE on Lower Adress and Higher Byte In Higher Adress

How many ways we access Memory Direct Mode: offset Addressing: Register Indirect: Register Indirect +offset Base +index Base+index+offset Mov ax,[num1] // Address is Fixed and on the Address the Content is Access Mov ax,[bx] //that Address is fit in Register & through this Register Memory is Access Mov ax,[bx+num1]: base +offset Mov ax,[si+Num1]: index+ offset Mov ax,[bx+si] the two adresses one in index and other in base. Both are added from the resultant adress we can pick the data Mov ax,[bx+si+num1]

Total Seven Adressing Modes SEVEN WAYS TO ACCESS THE MEMORY OFFSET addressing Base Addressing INDEX Addressing Base +offset Index+offset Base+index Base+index+offset EFFECTIVE ADRESS: were our data is present

Segment Association Ip Associate by default CS(TIED) SI,DI,BX By def DS BP with SS(TIED) Sp with SS(TIED) SEGMENT OVER RIDE Mov ax,[cs:bx] Every thing is in segment when we go in Data Window we Do DS: & Code window is CS: Segment are performing there function at there desire places every thing is Related to there Segment Every segment can calculate his her address Now we know about Effective Adresses generally if we use OFFSETS so as we tell you that No address is Complete until we can attach his Segment part. till no meaning Until we attach the segment part that in which segment the offset is . As Every Segment has its own Default Segment IP(instruction pointer) by Default Code Segment (CS) related or Associated & this Default segment cannot be separated and it cannot access any other segment IN data Case is different in direct addressing the OFFSET Form BY DEFAULT Access Data Segment (DS) we cannot Associate it as we can do .as we cannot do it standard goes to DS . And it see that DS relative that in this particular offset what is there SI,DI ,BX these Three REGISTER INDIRECT FORM by default DS Associated BP Cannot Associate By Default DS. It By Default SS Associated SP is also Tied with SS By Default: not Tied it can be used if we want Bx to Associate with ES then Segement overide is Done As Mov ax,[cs:bx] for this Instruction we say that bx is now Associated to Cs instead DS 2E num is called override Byte All the Segment value is Same so the offset from any segment the answer is Same COM File is Single Segment in which code ,data ,stack all are in it the standard in which all 4 segments are present on each other