-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6-Sort.asm
More file actions
80 lines (60 loc) · 1.32 KB
/
Copy path6-Sort.asm
File metadata and controls
80 lines (60 loc) · 1.32 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
include 'emu8086.inc'
name "SORT"
org 100h
jmp start
m1:
array db 8, 3, 6, 2, 5, 4, 9, 1, 17, 12
str1 db 0dh,0ah
A_size = 10
db 0Dh,0Ah,'$'
DEFINE_SCAN_NUM
DEFINE_PRINT_STRING
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS
DEFINE_PTHIS
buffer db 0
start:
MOV AH, 1
INT 21h
sort:
mov cx,10
dec cx
outer_loop:
mov bx,cx
mov si,0
inner_loop:
mov ah,array[si]
mov dl,array[si+1]
cmp al, 'A'
jne DDDD
jmp AAAA
AAAA:
cmp ah, dl
jle noswap
jg swap
DDDD:
cmp ah, dl
jge noswap
jl swap
swap:
mov array[si],dl
mov array[si+1],ah
noswap:
inc si
dec bx
jnz inner_loop
loop outer_loop
jmp Exit
Exit:
PrintArr:
PRINT 'Sorted array: '
MOV BL, 000h
MOV AH, 000h
next:
MOV AL, array[BX]
INC BL
call print_num
PRINT ', '
CMP BL, 10
JL next
RET