-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpgms11_5.asm
127 lines (114 loc) · 1.3 KB
/
pgms11_5.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
.model small
.stack 100h
.data
string db 80 dup(0)
vowels db 'AEIOU'
const db 'BCDFGHJKLMNPQRSTVWXYZ'
out1 db 0dh,0ah,'vowels = $'
out2 db 0dh,0ah,'Consonants = $'
vowct dw 0
constct dw 0
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
lea DI,string
CLD
CALL read_str
lea si,string
REPEAT1:
LODSB
LEA DI,vowels
mov cx,5
REPNE SCASB
JNE CK_const
inc vowct
jmp until
CK_const:
lea DI,const
mov cx,21
REPNE scasb
jne until
inc const
until:
dec bx
jne REPEAT1
mov ah,9
lea dx,out1
int 21h
mov ax,vowct
call out_dec
mov ah,9
lea dx,out2
int 21h
mov ax,constct
call out_dec
mov ah,4ch
int 21h
main endp
OUT_DEC PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
OR AX,AX ;ax<0
JGE END_IF1
PUSH AX
MOV DL,'-'
MOV AH,2
INT 21H
POP AX
NEG AX
END_IF1:
;GET DECIMAL DIGITS
XOR CX,CX
MOV BX,10D
REPEA:
XOR DX,DX
DIV BX
PUSH DX;remainder
INC CX
;UNTIL
OR AX,AX
JNE REPEA
; CONVERT DIGIT TO CHARACTER AND PRINT
MOV AH,2
PRINT_LOOP:
POP DX
ADD DL,30H
INT 21H
LOOP PRINT_LOOP
POP AX
POP BX
POP CX
POP DX
RET
OUT_DEC ENDP
read_str proc near
push ax
push di
cld
xor bx,bx
mov ah,1
int 21h
while1:
cmp al,0dh
je end_while
cmp al,8h
jne else1
DEC DI
DEC BX
JMP read
else1:
stosb
inc bx
read:
int 21h
jmp while1
end_while:
pop DI
POP AX
RET
read_str endp
end main