To write an 8085 assembly language program to arrange the given array 5 data bytes stored in the memory location starting from 8100 in ascending order.
ALGORITHM:
STEP 1: Load the D register with the data 05.
STEP 2: Decrement the content of D register.
STEP 3: Load the C register with the data 05.
STEP 4: Decrement the content of C register.
STEP 5: Load the HL register pair with the address 8100.
STEP 6: Move the data in the location 8100, which is addressed by HL
register pair.
STEP 7: Increment the address of HL register pair.
STEP 8: Move the data from M to B register.
STEP 9: Compare the data in B register with the accumulator.
STEP 10: If there is carry, move the data from M to B register.
STEP 11: Decrement the address of HL register-pair.
STEP 12: Move the data from M to B register.
STEP 13: Increment the address of HL register pair.
STEP 14: Decrement the content of C register.
STEP 15: If count is not equal to zero go to step 6.
STEP 16: Decrement the contents of contents of D register.
STEP 17: Stop the execution.
PROGRAM:
MEMORY ADDRESS HEXA- CODE LABEL MNEMONICS COMMENTS
8000 16 MVI D, 05H Move the data 05H to D register.
8001 05
8002 15 DCR D Decrement the contents of D register.
8003 0E L3 MVI C, 05H Move the contents 05H to C register.
8004 05
8005 0D DCR C Decrement the contents of the C register.
8006 21 LXI H, 8100H Load the HL register-pair with the address 8100H.
8007 00
8008 81
8009 7E L2 MOV A,M Move the data from M to A.
800A 23 INX H Increment the address of HL register-pair.
800B 46 MOV B,M Move the data from M to A.
800C B8 CMP B Compare the contents of B with the accumulator.
800D DA JC 8014(L1) If there is carry.
800E 14 L2
800F 80
8010 77 MOV M,A Move the data from A to M.
8011 2B DCX H Decrement the address of HL register-pair.
8012 70 MOV M,B Move the data from B to M.
8013 23 INX H Increment the address of HL register-pair.
8014 0D L1 DCR C Decrement the content of C register.
8015 C2 JNZ 8009H(L2) IF the carry is not zero then jump to location 8009H.
8016 09
8017 80
8018 15 DCR D Decrement the contents of D register.
8019 C2 JNZ 8009H(L2) If the carry is not zero then jump to location 8003H.
801A 03
801B 80
801C 76 HLT Stop the execution.
____________________________________________________________________________________________________
