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
81
;--------------------------------------------
DATA SEGMENT
BUF DB 10H, 25H, 32H, 13H, 43H
DATA ENDS

;--------------------------------------------
STACK SEGMENT STACK 'STACK'
SB DB 100 DUP(?)
STACK ENDS

;--------------------------------------------

CODE SEGMENT
ASSUME CS:CODE, DS:DATA, SS:STACK

START:
MOV AX, STACK
MOV SS, AX
MOV AX, DATA
MOV DS, AX
LEA DI, BUF
MOV BL, 5

AGN:
MOV SI, DI
MOV CL, BL

AGN2:
MOV AL, [SI]
CMP AL, [SI + 1]
JNC AGN3
XCHG [SI + 1], AL
MOV [SI], AL

AGN3:
INC SI
DEC CL
JNZ AGN2
DEC BL
JNZ AGN

;-------------------------
MOV CH, 06H
MOV CL, 04H
MOV AH, 02H

NEXT:
MOV DL, [DI]
ROL DL, CL
AND DL, 0FH
CMP DL, 0AH
JB STORE
ADD DL, 07H

STORE:
ADD DL, 30H
INT 21H

;---------------
MOV DL, [DI]
AND DL, 0FH
CMP DL, 0AH
JB STORE2
ADD DL, 07H

STORE2:
ADD DL, 30H
INT 21H
MOV DL, ' '
INT 21H
INC DI
DEC CH
JNE NEXT

;-------------------------
MOV AH, 4CH
INT 21H
CODE ENDS

;--------------------------------------------
END START