0

I am trying to code bubble sort in assembly language ( 8086 ).

Here is the code :

DATA SEGMENT
STRING1 DB 99H,12H,56H,45H,36H
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX

MOV CH,04H

UP2: MOV CL,04H
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

The code is executing just fine without any error but I'm not able to think how I should print the contents of the array.

I tried debugging and looked at the memory locations at which the array is stored. The memory locations show the correct output but I want to print the array contents before and after the sorting.

0 Answers0