Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Microprocessors and Programming (17431) Experiment No.

09

EXPERIMENT NO.09

(To be performed by group of 1-2 students)


1.0 Title:

To Write and execute assembly language program

to perform block transfer of Data

1] Using String instructions

2] Without using String Instructions

2.0 Prior Concepts:

Algorithm, flowchart, Instruction set of 8086, Physical address Calculations.

3.0 New Concepts:

Proposition 1: Non-Overlapped Block Transfer

This refers to transferring the block of data from source memory locations to destination
memory locations. Counter is set, whose value is equal to the block length and on each
transfer of data from source to destination, the counter is decremented by one and the
memory pointer is incremented by one. This process is repeated till the counter
becomes zero.

Concept Structure 1:

Before Block Transfer After Block Transfer

Source Block Destination Block Source Block Destination Block

C001 12 D001 15 C001 12 D001 12


C002 24 D002 30 C002 24 D002 24
C003 36 D003 45 C003 36 D003 36
C004 48 D004 60 C004 48 D004 48
C005 60 D005 75 C005 60 D005 60
C006 72 D006 90 C006 72 D006 72

136
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

Proposition 2: Overlapped Block Transfer

This refers to exchanging the block of data between one-memory location to other.
Here, the counter is set whose value is equal to block length and on each transfer of
data from source to destination, the counter is decremented by one and the memory
pointer is incremented by one. This process is repeated till counter becomes zero.

Concept Structure 1:

Before Block Transfer After Block Transfer

Source Block Destination Block Source Block Destination Block

C001 12 D001 15 C001 15 D001 12


C002 24 D002 30 C002 30 D002 24
C003 36 D003 45 C003 45 D003 36
C004 48 D004 60 C004 60 D004 48
C005 60 D005 75 C005 75 D005 60
C006 72 D006 90 C006 90 D006 72

Proposition 3: instruction LEA SI, BLOCK1 and LEA DI, BLOCK2:

This instruction will load the starting address of BLOCK1 into SI and Address of
BLOCK2 into DI of the data segment register.

Proposition 4: instruction INC SI and INC DI:

This instruction will increment the contents of SI and DI registers.

4.0 Learning Objectives:

Intellectual skills:
 Understand program development steps like: Problem definition, Analysis,
Design of Logic, Coding, Testing and Maintenance (Modification, error
Correction etc.)
 Use of programming Language constructs in assembly language program
implementation.
 To apply different logics/ approaches to solve the given problem.
 Understand the tools available for assembly language programming of 8086
such as Editor (Edit), Assembler (TASM /MASM/ NASM, Linker (TLINK

137
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

/LINK /NLINK and Debugger (TD, Debug) and to identify/locate different types
of errors as syntactical semantics, fatal, linker and logical.
 To understand the execution of Assembly Language Program.
Motor skills:
 Ability of proper handling of the computer system.
 Ability to switch between and operate the different tools of assembling.
 Ability to draw the flowchart.
 Ability to check the status of flags and memory registers during execution of
the programs.

5.0 Equipment:
Hardware:
A Personal computer with Pentium onwards, with minimum 1GHZ processor,
1GB RAM, 80GB HDD (minimum 1 per student or two)
Software:
Assemblers (MASM Macro Assembler from Microsoft Corp or TASM Turbo
Assembler from Borland Inc. or NASM),
 Linker (TLINK, LINK or NLINK),
 Debugger (TD, Debug) and any other
 Editor like EDIT, Norton Editor, and Notepad etc.
Teachers shall make the students aware of the use of 8086 simulator for writing
and executing assembly language programs.

6.0 Stepwise Procedure:

Problem Statement 1 :

The source block is at address 2000H and Destination Block is at address 3000H. Write
an assembly Language program to move block of N bytes from source location to a
destination location. (N= 10)

STEP1:

Analyze the given problem and develop the algorithm.

Algorithm for transfer block of data from one memory block to other.

1. Initialize the Data Segment with address of Source and Destination block.

2. Load effective address of BLOCK1 to SI and BLOCK2 to D1.

138
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

3. Enter data in to source block.

4. Initialize S1 = Start of destination block

5. Initialize counter = N =10

6. Transfer contents from source location to destination location and vise versa.

7. Decrement the counter.

8. Increment SI and DI.

9. Is count =0? NO- go to step 6

10. Display the contents and stop.

STEP2: Draw the Flowchart to implement the above algorithm.

139
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

Flow Chart for transfer block of data from one memory block to other.

Students can draw a similar flowchart


Start for Block Transfer of Word type of Data.
(Hint: Word occupies two memory
locations. Increment SI and DI pointers
by 2 and initialize blocks to 20 locations
each.)
Initialize arrays Block1 and Block2 of length 10 bytes

Load effective address of BLOCK1 and 2 in SI and DI


Block1 to SI and Block2 to D1.

Enter data into source Block.

Initialize counter register to 0AH and DF=0


value 10 (length of block)

Execute String Instruction:-Transfer data pointed by SI to location pointed by DI

By String instruction:-SI=SI+1, DI=DI+1, CX=CX-1

NO If Counter=0

YES
Stop

140
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

Step3:

Assembly Language program to transfer block of data from source locations to


the Destination locations.

Mnemonics Comments
DATA SEGMENT Start of data segment
BLOCK1 DB 10 DUP(10H) Declare array BLOCK1 of size 10 bytes.
BLOCK2 DB 10DUP(0) Declare array BLOCK2 of size 10 bytes.
DATA ENDS End of data segment:
CODE SEGMENT Start of code segment
ASSUME CS:CODE ,DS:DATA ,ES:EXTRA

START: MOV DX,DATA


Initialization of Data Segment register
MOV DS, DX

MOV DX,EXTRA Initialization of Extra Segment register


MOV ES,DX

LEA SI, BLOCK1 Load effective address of Block1 to SI


LEA DI, BLOCK2 Load effective address of Block2 to 01
Initialize the counter to Block length =
MOV CX, OOOAH
10 .
CLD Clear DF
Move the contents of memory location
REP MOVSB
pointed by SI to location pointed by DI
MOV AH, 4CH

INT 21H

CODE ENDS End of code segment


END START

7.0 Results obtained:

141
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

Before Execution After Execution

Block 1 Data Block 2 Data Block 1 Data Block 2 Data


address address address address

8.0 Questions for confirmation of learning:

1. Whether string instructions increase or decrease the size of a programme?

2. If CLD instruction is instruction is omitted, will the program run correctly? Why?

3. Which flags are affected during MOVSB execution?

4. Perform alteration in program a) If 10 bytes are to be transferred from 2000 to

3000. B) If block size is 20 instead of 10

9.0 Student’s activity:

142
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

[Teacher should form groups of 8 students and allocate different activities to each
group]

Student’s activity1:

Problem statement:

Write an assembly Language Program to transfer data between Block1 and Block2
without using string instructions.

Step1:

Algorithm for transferring block of data without using string instructions.

Step2:

143
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

Student’s activity2:
Flow Chart for block transfer without using string instructions.

Student’s activity 3:
Step3: Assembly Language Coding Sheet for block transfer without
data using string instructions.

Mnemonics Comments

144
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

Results obtained:

Before Execution After Execution

Block 1 Data Block 2 Data Block 1 Data Block 2 Data


address address address address

10.0 Questions:

Write answers to Q… Q…. Q… Q…. (Questions to be allotted by teacher)

145
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

1. Draw the flow chart showing how the block of N bytes are read into memory using

programmed I/O.

2. Explain how the address of block1 and block 2 is obtained in SI and DI registers?

3. What are the use of source Index and Destination Index registers?

4. Explain what operation is performed by following instructions.

a. MOV [BX] ,AX

5. Given that VARIABLE1 and VARIABLE2 are word variables and LABEL is a label.

Find the errors in following instructions.

a. ADD DX

b. SUB AL, BX

c. JNZ VARIABLE1

d. JMP NEAR LAB

6. What are the uses of SI and DI registers in the program?

7. State the use of LOOP BACK statement executed?

8. Write Industrial applications of Block transfer program.

9. List the string instructions.

10. List all string instructions of 8086.Explain each with suitable example.

(Space for Answers)

(Space for Answers)

146
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

(Space for Answers)

147
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Microprocessors and Programming (17431) Experiment No. 09

Signature of
C(4) P(4) A(2) Total
Subject Teacher

148
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

You might also like