-
Notifications
You must be signed in to change notification settings - Fork 0
/
REVERSE.asm
78 lines (64 loc) · 1.91 KB
/
REVERSE.asm
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
Title
.MODEL SMALL
.STACK
.DATA
STR_I DB 31 DUP("$")
STR_O DB 31 DUP("$")
STR_END DB "$"
_LENGTH DW 0000
.CODE
MAIN PROC FAR
MOV AX,@Data
MOV DS,AX
;-----------
CALL READ_STR
CALL STR_LENGTH
LEA SI, STR_I
LEA DI, STR_O
ADD SI,_LENGTH
SUB SI,1
MOV CX,_LENGTH
REVERSE:
MOV DH,[SI]
MOV [DI],DH
INC DI
DEC SI
DEC CX
JNZ REVERSE
MOV AH,09H
LEA DX,STR_O
INT 21H
;-----------
MOV AX,4C00H
INT 21H
MAIN ENDP
;----------------------------
READ_STR PROC NEAR
MOV CX,30 ;LENGTH LIMITS
LEA DI,STR_I
READ_CHAR:
MOV AH,01H
INT 21H
CMP AL,13 ;IS_ENTER_KEY
JE _BREAK
MOV [DI],AL
INC DI
DEC CX
JNZ READ_CHAR
_BREAK:
RET
READ_STR ENDP
;--------------------
STR_LENGTH PROC NEAR
LEA BX,STR_I
MOV DH,STR_END
A1:
CMP [BX],DH
JE _END
INC _LENGTH
INC BX
JMP A1
_END:
RET
STR_LENGTH ENDP
END MAIN