Based and indexed addressing

JaveriaYaqoob2 772 views 9 slides Jan 17, 2018
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

Base and index addressing mode in Assembly language


Slide Content

Based and Indexed Addressing Mode Addressing Mode Types of Addressing Mode Based Addressing Mode and displacement Example Indexed Addressing Mode Example Difference between based and indexed addressing mode

Addressing Mode The addressing mode deal with the source and destination of the data required by the instruction. This can be either a register or a location in memory or even a port.

Types of Addressing Modes Register Addressing Immediate and Direct Addressing Indirect Addressing Indexed Addressing Based Addressing Based-Indexed Addressing

Based Addressing Mode The operand field of the instruction contains a base register (bx or bp) and an 8-bit (or 16-bit) constant (displacement) .it is used in one dimensional address. Displacement: the operand’s offset address is obtained by adding a number called a displacement to contents of a register. The syntax of an operand is any of the following:- [ register + displacement ] [ displacement + register ] [register ] + displacement Displacement + [ register ] Displacement[register ]

Examples of based addressing mode Mov ax , w[bx] it can also be written as:- Mov ax ,[w+bx] Mov ax, [bx+w] Mov ax, w+[bx] Mov ax,[bx]w

Example 10.5 write some code to sum in ax using base mode the elements of the 10-element array w defined by w dw 10,20,30,40,50,60,70,80,90,100 solution: xor ax , ax xor bx,bx mov cx,10 addnos : add ax,w[bx ] add bx,2 loop addnos

Indexed addressing mode The effective address of the operand is generated by adding a constant value to the contents of the register. Its used may be either a special function register or general purpose register ,the register which we use here is known as “index register". We indicate the index mode symbolically as x(ri).this is useful in dealing with lists and arrays. For example :- add ax , [ di + 20 ] add ax , table1 [ si ]

Example 10.7:- replace each lower case letter in the following string by its upper case equivalent. Use index addressing mode msg db ‘this is a message’ Mov cx,17 Xor si,si Top: cmp msg [ si ], ’ ’ je next and msg [ si ], 0dfh Next: inc si loop top