-
Notifications
You must be signed in to change notification settings - Fork 1
/
1 reverseString.asm
62 lines (46 loc) · 942 Bytes
/
1 reverseString.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
; write an assembly language program that will read a string and then make the string in it's
; reverse form
.MODEL SMALL
.STACK 100H
.DATA
VAR1 DB 40 DUP(?)
VAR2 DB ?
NEWLINE DB 0AH,0DH,'$'
.CODE
MAIN PROC
mov ax,@DATA
mov ds,ax
MOV AH,1
MOV SI,0
GETSTRING:
MOV AH,1
INT 21H
CMP AL,0DH
JE END_GETSTRING
MOV VAR1+SI,AL
INC SI
JMP GETSTRING
END_GETSTRING:
MOV VAR1+SI,'$'
CALL PRINTLINE
MOV CX,SI
MOV AH,2
PRINTSTRING:
DEC SI
MOV DL, VAR1[SI]
INT 21H
LOOP PRINTSTRING
MOV AH,4CH
INT 21H
MAIN ENDP
PRINTLINE PROC
PUSH DX
PUSH AX
LEA DX,NEWLINE
MOV AH,9
INT 21H
POP AX
POP DX
RET
PRINTLINE ENDP
END MAIN