Docsity

Addressing Modes in Assembly: Understanding Arrays, Operators, and Data Access, Slides of Assembly Language Programming

Partial preview of the text

Download Addressing Modes in Assembly: Understanding Arrays, Operators, and Data Access and more Slides Assembly Language Programming in PDF only on Docsity!

Addressing Modes

Lab 7

Topics

 Arrays  Addressing Modes  Operators  Assignment

Arrays-dup operator

 Dup operator  Array1 Db 20 dup(0)  Array2 Db 20 dup(?)  Array3 Db 4 dup(“ABC”)  Array4 DW 4 dup(0)

 How to access them??

Addressing Modes

 Register Addressing:  MOV AX,BX

 Immediate Addressing:  MOV AX,

Direct Addressing

 Form 2: Displacement Addressing  Mov al,[1234H]  By default the address is in data segment but we can override that  Mov al, cs:[1234h]

Direct addressing

 Data db 0  Mov Al, data

 How to access data db 0,1,2,3,

 Mov al, data

 Mov al, data+

 Mov al, data+

 Exercise: data dw 0,1,2,3,

Operators

 OFFSET operator  TYPE operator  Returns the size,in bytes, of a single element of a variable  Var1 db?  Var2 db 10,20,30,  Mov ax, type var  Mov ax, type var

Operator

 Length operator  Counts the number of individual elements in a variable that has been defined using DUP. If dup is not used then it returns value of 1  Val1 dw 1000h  Val2 db 10,20,  Val3 db 32 dup(0)  Val1, val2 have length 1, val3 has length 32

Addressing Modes

 Register Indirect  Offset is held in BX, DI, SI, BP  Mov AX,[BX]  BX=1000H, DS =0100H which memory locations are accessed?  0100*10H+ 1000H =2000, 2001H

Addressing Modes

 Segment defaults  If BX,DI, SI is used DS is the default register  If BP is used then stack segment register  Overriding  Mov al, cs:[si]

Programs

 Other section lab:  To find if a number is even or odd

 Input a string  Input a multiple digit number  Output a multiple digit number

Assignment

 Write a program that takes 10 numbers from user and allocate it to the array  Write a program to copy one array to another  Write a program to sum all the array elements  Write a program to find the average of an array