-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10_3.ASM
73 lines (64 loc) · 1017 Bytes
/
10_3.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
TITLE TAKE INPUT n AND DISPLAY SUM OF MULTIPLICATION UPTO n
.MODEL SMALL
.STACK 64
.DATA
MAXLEN DB 100
ACTLEN DB ?
SENTENCE DB 100 DUP('$')
COUNT DW ?
RESCOUNT DB 8 DUP('$')
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV DX, OFFSET MAXLEN
MOV AH, 0AH
INT 21H
MOV SI, OFFSET SENTENCE
MOV BX, 00H
CHECK: MOV DL, [SI]
CMP DL, '$'
JE EXIT
CMP DL, ' '
JNE CONTINUE
INC BX
CONTINUE:INC SI
LOOP CHECK
EXIT: INC BX
MOV COUNT, BX
CALL NUM2STR
MOV AX, 0200H
MOV DX, 0DH
INT 21H
MOV DX, 0AH
INT 21H
MOV DX, OFFSET RESCOUNT
MOV AH, 09H
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
NUM2STR PROC NEAR
MOV BX, 10
MOV AX, COUNT
MOV DI, 0080H
NEXT: XOR DX, DX
DIV BX
ADD DX, 30H
MOV [DI], DX
INC DI
CMP AX, 00
JNE NEXT
;REVERSE THE STRING
MOV CX, DI
MOV SI, DI
SUB CX, 80H
MOV DI, OFFSET RESCOUNT
ASCII: DEC SI
MOV AL, [SI]
MOV [DI], AL
INC DI
LOOP ASCII
RET
NUM2STR ENDP
END