-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOUNTING.ASM
159 lines (133 loc) · 1.76 KB
/
COUNTING.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
dataseg segment
letter db 0
digit db 0
other db 0
input label byte
smax db 80
slen db ?
string db 80 dup(?)
mess1 db 'Please input the string: ','$'
mess2 db 'The number of letter is ','$'
mess3 db 'The number of digit is ','$'
mess4 db 'The number of other is ','$'
dataseg ends
codeseg segment
assume cs:codeseg, ds:dataseg, es:dataseg
main proc far
push ds
sub ax,ax
push ax
mov ax,dataseg
mov ds,ax
mov es,ax
start:
lea dx,mess1
mov ah,09
int 21h
lea dx,input
mov ah,0ah
int 21h
mov ah,02h
mov dl,0dh
int 21h
mov ah,02h
mov dl,0ah
int 21h
mov ch,0
mov cl,slen
mov si,0
next:
mov dx,0
mov dl,string[si]
cmp dl,30h
jb others
cmp dl,3ah ; <='9'
jb digits
cmp dl,41h; <'A'
jb others
cmp dl,5bh ;<='Z'
jb letters
cmp dl,61h;<'a'
jb others
cmp dl,7bh;<='z'
jb letters
others:
inc other
jmp last
letters:
inc letter
jmp last
digits:
inc digit
last:
inc si
loop next
lea dx,mess2
mov ah,09
int 21h
mov bh,0
mov bl,letter
call change
mov ah,02h
mov dl,0dh
int 21h
mov ah,02h
mov dl,0ah
int 21h
lea dx,mess3
mov ah,09
int 21h
mov bh,0
mov bl,digit
call change
mov ah,02h ;回车
mov dl,0dh
int 21h
mov ah,02h
mov dl,0ah
int 21h
lea dx,mess4
mov ah,09
int 21h
mov bh,0
mov bl,other
call change
mov ah,02h
mov dl,0dh
int 21h
mov ah,02h
mov dl,0ah
int 21h
ret
main endp
;
change proc near
push ax
push bx
push cx
push dx
mov ch,4
mov cl,4
rotate:
rol bx,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl printit
add al,7h
printit:
mov dl,al
mov ah,2
int 21h
dec ch
jnz rotate
pop dx
pop cx
pop bx
pop ax
ret
change endp
;
codeseg ends
end main