Write an ALP for 8086 to arrange 10 numbers in ascending order
Ajink Gupta Answered question May 25, 2024
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | DATA SEGMENT STRING1 DB 99H, 12H, 56H, 45H, 36H, 78H, 34H, 23H, 67H, 89H DATA ENDS CODE SEGMENT ASSUME CS:CODE, DS:DATA START: MOV AX, DATA MOV DS, AX MOV CH, 09H ; Outer loop counter for 10-1 = 9 iterations UP2: MOV CL, 09H ; Inner loop counter for 10-1 = 9 comparisons LEA SI, STRING1 UP1: MOV AL, [SI] MOV BL, [SI+1] CMP AL, BL JC DOWN MOV DL, [SI+1] XCHG [SI], DL MOV [SI+1], DL DOWN: INC SI DEC CL JNZ UP1 DEC CH JNZ UP2 INT 3 CODE ENDS END START |
Ajink Gupta Answered question May 25, 2024