Sorting of numbers using 8086 hardware kit




Arrange the following 16-bit numbers in ascending order using 8086-kit (Hardware experiment).

0075H,0072H,0080H,0018H,0076H,0009H    (Total SIX 16-bit numbers)

Enter these numbers in the memory locations starting from 2000
Type SB 2000 from the keyboard
Replace existing numbers with the given numbers in the memory locations. (MSB in even location and LSB in odd location)
 For example 0075 can be entered as

2000 75
2001 00



Similarly, enter all the numbers.

Press interrupt after entering all the given numbers.

To assemble the program, type A and give starting address e.g. 1000. 





Start typing the following program. (Few images are appended after the program)

             MOV DX, 05  //Should be one less than the total numbers//
LOOP1: MOV CX,DX // Note the address of this line//
        MOV SI,2000
LOOP2:MOV AX,[SI] // Note the address of this line//
              MOV DI,SI
              ADD DI,02
            CMP AX,[DI]
            JC END1 // Note address of  this line for future editing and write  temporary address 1050 in place of label END1//
             ADD SI,02
            XCHG [SI],AX
             SUB SI,02
            XCHG [SI],AX
END1: ADD SI,02H // Note the address of this line to be replaced the temp location 1050 used earlier//
        LOOP LOOP2 // address of LOOP2 in place of label LOOP2//
        DEC DX
        JNZ LOOP1 // address of LOOP1  inplace of label LOOP1//
       HLT // LAST ADDRESS//













To replace temp address in the line of JC END1.

Type A and start address i.e 1014 of the line to be edited. Type JC 1022 (new address i.e. actual address). And press enter twice.

Press interrupt


To check full program, type U via keyboard. For a quick review watch the video below.




Run the program

GB 1000 10XX(i.e.HLT address)


Brk pt reached



Press interrupt and verify the sorted numbers.

DB 2000 200B








Numbers are arranged in increasing order.

Comments for any clarification



Comments

Popular posts from this blog

Design equations of Rectangular Microstrip Patch Antenna

Spotters in "Hospital Waste Management" for CFM & MPH students

ORS : A boon in dehydration

Spotters in "Environment and Health: Mosquitoes- Anopheles" for CFM & MPH students

Spotters in "Environment and Health: Water" for CFM & MPH students

Spotters in "Environment and Health: Insecticides" for CFM & MPH students

Spotters in "Nutrition and Health: Balanced diet models" for CFM & MPH students

Spotters in "Environment and Health: Mosquito control Measures" for CFM & MPH students