0% found this document useful (0 votes)
116 views12 pages

Exp 04 Ascending & Descending Order

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views12 pages

Exp 04 Ascending & Descending Order

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Department of ECE

23EC2106R
PROCESSORS AND CONTROLLERS
Lab Experiment - 4

ARRANGING NUMBERS IN ASCENDING &


DESCENDING ORDER
Exp 4: Ascending & Descending order using 8086

Aim

● To Develop an Assembly Language Program (ALP) to arrange a 16-bytes long string


data from the starting offset location of 0400H in the segment 5000H in ascending
and descending order.

Software used: 8086 Emulator


Exp 4: Ascending & Descending order using 8086

Theory:
• Write a paragraph about control transfer instructions in 8086 microprocessor.
Exp 4: Ascending & Descending order using 8086

Input Data:
• The 16 bytes of data stored in offset location 0200H of segment
location 7000H is
37H, 53H, 2BH, A1H,
42H, 20H, 61H, 71H,
0CH, 91H, 15H, BFH,
27H, D0H, EFH, 4CH
Exp 4: Ascending & Descending order using 8086
Program Table: (a) Ascending Order
Address Program Comment
0100:0000 MOV AX, 5000H Move the value 2000H into AX register (loading segment address)
0100:0003 MOV DS, AX Move the contents of AX into DS register (data segment register)
0100:0005 MOV CL, 0FH Load CL register with the number of iterations (0FH or decimal 15)
0100:0007 BACK1: MOV DL, CL Load DL register with the number of iterations (0FH or decimal 15)
0100:0009 MOV SI, 0400H loading the source data offset address into SI register
0100:000C MOV AL, [SI] Move the data from source address into AL register
0100:000E BACK2: INC SI Increase the source data offset address by 1
0100:000F CMP AL, [SI] Compare the contents of AL register with the contents of SI location
0100:0011 JC NEXT If CF=1, jump to NEXT address (that is if carry generated, second number is
larger than first number)
0100:0013 XCHG AL, [SI] If CF=0, exchange the data from source address and AL register (that is if carry
not generated, first number is larger than second number)
0100:0015 XCHG AL, [SI-1] exchange the data from source address-1 and AL register
Exp 4: Ascending & Descending order using 8086
Program Table: (a) Ascending Order (continuation)
Address Program Comment
0100:0018 NEXT: MOV AL, [SI] If CF=1, load the data from source address into AL register (that is if CF=1, the
numbers are in correct order but second number should be in AL)
0100:001A DEC DL Decrease DL contents by 1
0100:001C JNZ BACK2 If ZF=0, jump to BACK2 address (that is if count (DL) is not zero, repeat the
process from BACK2 address)
0100:001E DEC CL Decrease CL contents by 1
0100:0020 JNZ BACK1 If ZF=0, jump to BACK1 address (that is if count (CL) is not zero, repeat the
process from BACK1 address)
0100:0022 HLT Halt (stop) the processor.
Exp 4: Ascending & Descending order using 8086

Observation Values: Input Data: Output Data:

Memory Data Memory Data


Location Byte Location Byte
0400H 37 0400H 0C
0401H 53 0401H 15
0402H 2B 0402H 20
. .
. .
. .
. .
. .
. .
040EH EF 040EH D0
040FH 4C 040FH EF
Exp 4: Ascending & Descending order using 8086
Program Table: (a) Descending Order
Address Program Comment
0100:0000 MOV AX, 5000H Move the value 2000H into AX register (loading segment address)
0100:0003 MOV DS, AX Move the contents of AX into DS register (data segment register)
0100:0005 MOV CL, 0FH Load CL register with the number of iterations (0FH or decimal 15)
0100:0007 BACK1: MOV DL, CL Load DL register with the number of iterations (0FH or decimal 15)
0100:0009 MOV SI, 0400H loading the source data offset address into SI register
0100:000C MOV AL, [SI] Move the data from source address into AL register
0100:000E BACK2: INC SI Increase the source data offset address by 1
0100:000F CMP AL, [SI] Compare the contents of AL register with the contents of SI location
0100:0011 JNC NEXT If CF=0, jump to NEXT address (that is if no carry generated, first number is
larger than second number)
0100:0013 XCHG AL, [SI] If CF=1, exchange the data from source address and AL register (that is if carry
not generated, second number is larger than first number)
0100:0015 XCHG AL, [SI-1] exchange the data from source address-1 and AL register
Exp 4: Ascending & Descending order using 8086
Program Table: (a) Descending Order (continuation)
Address Program Comment
0100:0018 NEXT: MOV AL, [SI] If CF=0, load the data from source address into AL register (that is if CF=0, the
numbers are in correct order but second number should be in AL)
0100:001A DEC DL Decrease DL contents by 1
0100:001C JNZ BACK2 If ZF=0, jump to BACK2 address (that is if count (DL) is not zero, repeat the
process from BACK2 address)
0100:001E DEC CL Decrease CL contents by 1
0100:0020 JNZ BACK1 If ZF=0, jump to BACK1 address (that is if count (CL) is not zero, repeat the
process from BACK1 address)
0100:0022 HLT Halt (stop) the processor.
Exp 4: Ascending & Descending order using 8086

Observation Values: Input Data: Output Data:

Memory Data Memory Data


Location Byte Location Byte
0400H 37 0400H EF
0401H 53 0401H D0
0402H 2B 0402H BF
. .
. .
. .
. .
. .
. .
040EH EF 040EH 15
040FH 4C 040FH 0C
Exp 2: MOVING ARRAY OF DATA USING 8086
Result:

Write result on your own based on aim (refer first 3 experiment’s results and aims)
THANK YOU

N L PRASAD

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy