Algorithm
Algorithm
Load 4Ch into AH to terminate the program and call interrupt 21h.
+---------------------------+
| Start |
+---------------------------+
|
|
v
+---------------------------+
| Initialize Data Segment |
| AX = Data, DS = AX |
+---------------------------+
|
|
v
+---------------------------+
| Set DL = Count - 1 |
+---------------------------+
|
|
v
+---------------------------+
| Outer Loop Start (Up2) |
| CL = DL |
+---------------------------+
|
|
v
+---------------------------+
| Set SI = list |
+---------------------------+
|
|
v
+---------------------------+
| Inner Loop Start (Up1) |
| Load AL = [SI] |
+---------------------------+
|
|
v
+---------------------------+
| Compare AL and [SI+1] |
+---------------------------+
|
+------+------+
| |
| AL <= [SI+1]| AL > [SI+1]
| |
v v
+------------------+ +------------------+
| Increment SI | | Swap AL and |
| Decrement CL | | (SI+1) and AL |
+------------------+ +------------------+
| |
+------+------+
|
v
+---------------------------+
| Inner Loop End (Up1) |
| If CL != 0, Repeat Up1 |
+---------------------------+
|
|
v
+---------------------------+
| Outer Loop End (Up2) |
| Decrement DL |
| If DL != 0, Repeat Up2 |
+---------------------------+
|
|
v
+---------------------------+
| Program Exit |
+---------------------------+