0% found this document useful (0 votes)
11 views

maximum, minimum, ascending and descending

The document outlines an experiment using the 8085 microprocessor to find the maximum and minimum numbers from a set of 10 numbers, as well as to arrange these numbers in ascending and descending order. It includes the necessary apparatus, algorithms, and assembly code for executing the tasks. The results demonstrate the successful identification of the maximum and minimum values and their sorted arrangements.

Uploaded by

SARAVANAN B S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

maximum, minimum, ascending and descending

The document outlines an experiment using the 8085 microprocessor to find the maximum and minimum numbers from a set of 10 numbers, as well as to arrange these numbers in ascending and descending order. It includes the necessary apparatus, algorithms, and assembly code for executing the tasks. The results demonstrate the successful identification of the maximum and minimum values and their sorted arrangements.

Uploaded by

SARAVANAN B S
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Exp. No.

: Name:
Date: Roll no.:
Batch:
Maximum number, Minimum number, Ascending & Descending number order using
8085
AIM
To find the maximum number and minimum number (using 8085 microprocessor) among 10 numbers and
ascending and descending order of an array
APPARATUS REQUIRED
 8085 microprocessor
 Power supply
ALGORITHM
1) To find maximum and minimum number
 Initialize the HL pointer to the memory  The contents of the memory are
location pointer compared with the accumulator
 Load the data in the counter variable  Specify the opcode to find maximum
 Decrement counter variable at C number
 Now the counter of the memory are  Specify opcode to find minimum
moved to accumulator for completing number
functions  After completing functions store data
 The register is incremented to next and then processing of instruction is
number stopped
2) Ascending order
 Initialize HL pair at memory pointer  Decrement D by 1
 Get the counter at 5000H in C register  Repeat steps 4,5 and 6 till D becomes
 Copy it in D register for bubble sort zero
 Get the first value in A register  Decrement C by 1
 If they are out as order, exchange  Repeat steps 3 and 9 till C value
contents of memory and accumulator becomes zero
3) Descending order
 Initialize HL pair as memory pointer  Decrement D by 1
 Get the count of 6000H into C register  Repeat steps 5 and 6 till D register
 Copy it in D-register for bubble sort becomes zero
 Get the first value in a register  Decrement C by 1
 Compare it with value in A register  Repeat step 3-9 until C value becomes
 If they are out of order, exchange zero
contents as memory and accumulator
MAXIMUM NUMBER

ADRESS OPCODE MNEMONICS COMMENTS


4100 21 LX1H,4115 Points to location containing
4101 15 10 numbers
4102 41
4103 0E MVI C, 0A Counter variable
4104 0A
4105 0D DRC C Decrement counter
4106 7E MOV A, M Move contents of memory to
A
4107 23 INX H Increment the reg pair
4108 BE CMP M
4109 D2 JNC 410D Jump on no carry(cy=0)
410A 0D
410B 41
410C 7E MOV A, M
410D 0D DRC C
410E C2 JNZ 4107 Jump on no zero(Z=0)
410F 07
4110 41
4111 32 STA 4125 Storing the data
4112 25
4113 41
4114 76 HLT Stop the program

Input (maximum number)


4115:00
4116:01
4117:0A
4118:05
4119:0F
411A:2A
411B:0B
411C:0E
411D:03
411E:07
Output: maximum number 4125:2A
MINIMUM NUMBER

ADDRESS OP CODES MNEMONICS COMMENTS


4200 21 LX1H,4215 Point to location containing
4201 15 10 numbers
4202 42
4203 0E MVI C,0A Counter variable
4204 0A
4205 0D DCR C Decrement counter variable
4206 7E MOV A,M Contents of memory moved
to A
4207 23 INX H Increment register pair
4208 BE CMP M
4209 DA IC 4200 Jump if carry(cy=1)
420A 0D
420B 42
420C 7E MOV A,M
420D 0D DCR C
420E C2 INZ 4207 Jump of zero(z=1)
420F 07
4210 42
4211 32 STA 4225 Stores address in specified
4212 25 location’s address
4213 42
4214 76 HLT End of the program

Input (minimum number)


4215:00
4216:01
4217:0A
4218:05
4219:07
421A:2A
421B:0B
421C:0E
421D:03
421E:07

Output: minimum number 4285:00


ASCENDING ORDER

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4300 21 LXIH, 5000H Initialize the memory
4301 00
4302 50
4303 4E MOV C, M Move memory contents to
c
4304 0D DCR C Decrement C register
4305 51 LOOP 2 MOV D, C Move C to D
4306 21 LXIH, 5000H Load the address
4307 01
4308 50
4309 7E LOOP 1 MOV A, M Move memory contents to
A
430A 23 INX H Increment register pair
430B BE CMPM Compare memory with A
430C DA IC L OOP If cy=1 move to loop
430D 14
430E 43
430F 46 MOV B, M Move memory contents to
B
4310 77 MOV M, A Move A to memory
4311 2B DCXH Decrement memory
counter
4312 70 MOV M, B Move B to memory
4313 03 INX H
4314 15 LOOP FVT F
4315 C2 JNZ LOOP 1 If D≠0, jump to loop 1
4316 09
4317 43
4318 15 DCR D
4319 C2 JNZ LOOP 2 If C≠0, jump to loop 2
431A 05
431B 43
431C 76 HLT Stop the program

Input 5005:02 Output 5005:05


5000:0A 5006:01 5000:0A 5006:06
5001:0E 5007:05 5001:01 5007:08
5002:03 5008:06 5002:02 5008:09
5003:0B 5009:09 5003:03 5009:0B
5004:0F 500A:08 5004:04 500A:0E
DESCENDING ORDER

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4400 21 LX1H,6000H Initialize memory pointer
4401 00
4402 60
4403 4E MOV C, M Move memory to C
4404 0D DCR C Decrement counter
4405 51 LOOP 2 MOV D, C Move C register to D
4406 21 LX1H,6000H Load the address
4407 01
4408 60
4409 7E LOOP 1 MOV A, M Move memory to accumulator
440A 23 INX M Increment register pointer
440B BE CMP M Compare M and A register
440C D2 JNC LOOP If cy=0, jump to loop
440D 14
440E 44
440F 46 MOV B, M Move memory to B register
4410 77 MOV M, A Move accumulator to memory
4411 2B DCX H Decrement memory position
4412 70 MOV M, B move B register to memory
4413 23 INX H
4414 15 LOOP DCR D Decrement D register
4415 C2 JNZ LOOP 1 If D≠0, jump to loop 1
4416 09
4417 44
4418 0D DCR C
4419 C2 INZ LOOP If C≠, jump to loop
441A 05
441B 44
441C 76 HLT Stop the program

Input Output
6000:00 6006:06 6000:00 6005:06
6001:01 6007:07 6001:0C 6006:05
6002:02 6008:0A 6002:0B 6007:04
6003:03 6009:0B 6003:0A 6008:03
6004:04 600A:0C 6004:07 6009:02
6005:05

RESULT:
Thus, maximum and minimum number from a set of 10 numbers is determined and the numbers are
arranged om ascending order descending order

You might also like