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

## Presentation on theme: "Lecture 05-07 By SHERY KHAN sherykhan186@gmail.com Assembly Language Lecture 05-07 By SHERY KHAN sherykhan186@gmail.com."— Presentation transcript:

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

Register offset Addressing HOW MANY WAYS TO ACCESS MEM Segment Association ASSEMBLY LANGUAGE

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

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

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]