Вы находитесь на странице: 1из 4

Microprocessor Lab 10ECL68

Sambhram Institute of Technology, Department of ECE 1 | P a g e




Program No: 01
ILLUSTRATION OF BASE-INDEXED ADDRESSING MODE

AIM: To write and execute an ALP to move a data from location-1 to location-2
using base-indexed addressing mode.

THEORY:

The based indexed addressing modes are simply combinations of the register
indirect addressing modes. These addressing modes form the offset by adding
together a base register (bx or bp) and an index register (si or di). The allowable
forms for these addressing modes are:
mov al, [bx][si]
mov al, [bx][di]
mov al, [bp][si]
mov al, [bp][di]

Suppose that bx contains 1000h and si contains 0880h. Then the
instruction mov al,[bx+si] would load al from location DS:1880h.
Likewise, if bp contains 1598h and di contains 1004, mov ax,[bp+di]
will load the 16 bits in ax from locations SS:259C and SS:259D.
The addressing modes that do not involve bp use the data segment by
default. Those that have bp as an operand use the stack segment by default.

ALGORITHM:

1) Load the effective address of the data in bx.
2) Load the displacement value in si.
3) Move the data into cl using base-indexed addressing mode.
4) Load the new displacement value in si.
5) write the data into new destination using base-indexed addressing mode.


Microprocessor Lab 10ECL68
Sambhram Institute of Technology, Department of ECE 2 | P a g e



PROGRAM:

.MODEL SMALL ; few locations of cs & ds are reserved for program
.DATA ; access ds to store the data
X DB 5 DUP(?)
DB 90H
DB 20 DUP(?)
.CODE ; access cs to store program code
MOV AX, @DATA ;copy base address of data to ax
MOV DS, AX ;move the contents of ax to ds
LEA BX, X ;load effective address of data to bx
MOV SI, 05H ;initialize value for si
MOV CL, [BX+SI] ;move the data to cl using base-indexed a.m.
MOV SI, 11H ;initialize new value to si
MOV [BX+SI], CL ;move data from cl to destination using base-indexed a.m.
MOV AH, 4CH ;terminate the program
INT 21H ;processor is interrupted
END ;end of .model small


==========================================================================
OUTPUT:
BEFORE EXECUTION
==================
D DS:0000
3DD3:0000 B4 4C 00 00 00 90 00 00 - 00 00 00 00 00 00 00 00 .
3DD3:0010 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 .

AFTER EXECUTION
=================
D DS:0000
3DD3:0000 B4 4C 00 00 00 90 00 00 - 00 00 00 90 00 00 00 00 .
3DD3:0010 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 .
==========================================================================



Microprocessor Lab 10ECL68
Sambhram Institute of Technology, Department of ECE 3 | P a g e


Program No: 02 (a)
BLOCK DATA TRANSFER WITHOUT OVERLAP

AIM: To write and execute an ALP to move a block of data from location-1 to
location-2 without overlap of data.

ASSUMPTIONS:
BEFOR EXECUTION AFTER EXECUTION
Address content Address content









PROGRAM:

.MODEL SMALL ;few locations of cs & ds are reserved
.DATA ;access ds to store data
X DB 46H, 28H, 16H, 20H, 68H
Y DB 10 DUP(?)
.CODE ;access cs to store program code
MOV AX, @DATA ;initialization of ds
MOV DS, AX ;i.e. load base address of data to ds
LEA SI, X ;load effective address of source
LEA DI, Y ;load effective address of destination
MOV CX, 0004H ;load the counter
LOC1:MOV AX, [SI] ;read data from source through address pointed by si
MOV [DI], AX ;write the data to destination through address pointed by di
INC SI ;increment si
INC DI ;increment di
DEC CX ;decrement counter
JNZ LOC1 ;jump to loc1 if counter is not zero
MOV AH, 4CH ;terminate program
INT 21H ;processor is interrupted
END ;end of .model small

1000H 46
1001H 28
1002H 16
1003H 20
1004H 68
1005H 46
1006H 28
1007H 16
1008H 20
1009H 68
1000H 46
1001H 28
1002H 16
1003H 20
1004H 68
1005H 00
1006H 00
1007H 00
1008H 00
1009H 00
Microprocessor Lab 10ECL68
Sambhram Institute of Technology, Department of ECE 4 | P a g e


ALGORITHM:

1) Load the effective address of source into si and effective address of destination
into di(load value of di such that NO overlap of data occurs).
2) Load the count value into cx.
3) Move the data from source to destination memory location through ax involving
si & di.
4) Increment both si & di, decrement cx and repeat step 3 till cx becomes
zero.


==========================================================================
OUTPUT:
BEFORE EXECUTION
==================
D DS:0000
3DD3:0000 46 28 16 20 68 00 00 00 - 00 00 00 00 00 00 00 00 .
3DD3:0010 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 .

AFTER EXECUTION
=================
D DS:0000
3DD3:0000 46 28 16 20 68 46 28 16 - 20 68 00 00 00 00 00 00 .
3DD3:0010 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 .

Вам также может понравиться