| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

countkind.rar (843 Bytes)

```DATA SEGMENT

Counter DB 0,0,0             ;数字,小写,大写...的数量
result db 10,13,'Number('    ;结果字串
N_num db 0,0,'), LowerLetter('    ;数字总量字串
L_num db 0,0,'), UpperLetter('    ;小写总量字串
U_num db 0,0,')',10,13,'\$'    ;大写总量字串
Addr_Off dw offset N_num,offset L_num,offset U_num    ;各总量地址
DATA ENDS
Code SEGMENT
ASSUME CS: Code,DS: DATA
START:

MOV AX, DATA

MOV DS, AX

mov cx,100        ;限制数量
cld            ;正向

mov ah,1        ;读键
int 21h        ;调用dos
cmp al,0dh        ;是否回车
jz Done        ;是,跳
mov bx,0          ;bx = 0,数字数量位置
cmp al,'0'        ;比较'0'
cmp al,'9'        ;比较'9'
jbe Counting        ;少于,0~9内,跳counting
mov bx,2        ;bx = 2,大写数量位置
cmp al,'A'        ;比较'A'
cmp al,'Z'        ;比较'Z'
jbe Counting        ;少于,A~Z内,跳counting
mov bx,1        ;bx = 1,小写数量位置
cmp al,'a'        ;比较'a'
cmp al,'z'        ;比较'z'
Counting:

inc byte ptr Counter[bx]    ;以bx作为索引,加对应(0.1或2)的数量
Done:

mov cx,3        ;=3
mov si,offset Counter    ;元素数量起始
@@:

lodsb            ;al=ds:[si], si+1
aam            ;bcd调整,若al=0Ch,aam后,ax=0102
or ax,3030h        ;转为ascii字符
xchg al,ah        ;交换
mov di,[bx]        ;取相应的数量字串地址
mov [di],ax        ;存入数字符
loop @b        ;回圈,跳到上一个@@:
mov ah,9        ;输出函数
mov dx,offset result    ;结果地址
int 21h        ;调用dos
mov ah,4ch        ;离开
int 21h        ;调用dos

Code ENDS
END START
```

Number(10), LowerLetter(09), UpperLetter(09)

1.Number(     ;之后的位置放数字量
2.LowerLetter(    ;之后的位置放小写量
3.UpperLetter(    ;之后的位置放大写量

I have had my invitation to this world's festival, and thus my life has been blessed.(80bytes,含回车)

Give me the strength lightly to bear my joys and sorrows.
Give me the strength to make my love fruitful in service.
Give me the strength never to disown the poor or bend my knees before insolent might.
Give me the strength to raise my mind high above daily trifles.
And give me the strength to surrender my strength to thy will with love.(342bytes含回车)

sentence01 db 'I have had my invitation to this world's festival, and thus my life has been blessed.(80bytes,含回车)'

sentence02 db 'Give me the strength lightly to bear my joys and sorrows.'
db 'Give me the strength to make my love fruitful in service.'
...
...

sentence03 ....
....
....
....

sentence20
...
...

sentence01 db '... (总长350)
sentence02 db '... (总长350)
..
sentence20 db '... (总长350)

Addr_off dw offset sentence01,offset sentence02.,....,offset sentence20

mov bx,userinput    ;输入值
shl bx,2        ;x2 ,转为word

Addr_Off dw offset N_num,offset L_num,offset U_num 的使用时机,

str db 100,？,100 dup（？）

buffer.rar (656 Bytes)

```DATA SEGMENT
Counter DB 0,0,0             ;数字,小写,大写...的数量
result db 10,13,'Number('    ;结果字串
N_num db 0,0,'), LowerLetter('    ;数字总量字串
L_num db 0,0,'), UpperLetter('    ;小写总量字串
U_num db 0,0,')',10,13,'\$'    ;大写总量字串
Addr_Off dw offset N_num,offset L_num,offset U_num    ;各总量地址
StringInput db 100,?,100 dup (?)            ;输入缓冲

DATA ENDS
Code SEGMENT
ASSUME CS: Code,DS: DATA
START:
MOV AX, DATA
MOV DS, AX
cld            ;正向
lea dx, StringInput    ;取输入缓冲地址
mov ah,0Ah        ;输入字串函式
int 21h        ;调用dos
lea si,StringInput+2    ;实际输入地址
xor cx,cx        ;cx=0
mov cl,[si-1]        ;取实际输入字符数
jcxz exit        ;若cx=0,即无输入,离开
lodsb             ;al=ds:[si], si+1
cmp al,0dh        ;是否回车
jz Done        ;是,跳
mov bx,0          ;bx = 0,数字数量位置
cmp al,'0'        ;比较'0'
cmp al,'9'        ;比较'9'
jbe Counting        ;少于,0~9内,跳counting
mov bx,2        ;bx = 2,大写数量位置
cmp al,'A'        ;比较'A'
cmp al,'Z'        ;比较'Z'
jbe Counting        ;少于,A~Z内,跳counting
mov bx,1        ;bx = 1,小写数量位置
cmp al,'a'        ;比较'a'
cmp al,'z'        ;比较'z'
Counting:
inc byte ptr Counter[bx]    ;以bx作为索引,加对应(0.1或2)的数量

Done:
mov cx,3        ;=3
mov si,offset Counter    ;元素数量起始
@@:
lodsb            ;al=ds:[si], si+1
aam            ;bcd调整,若al=0Ch,aam后,ax=0102
or ax,3030h        ;转为ascii字符
xchg al,ah        ;交换
mov di,[bx]        ;取相应的数量字串地址
mov [di],ax        ;存入数字符
loop @b        ;回圈,跳到上一个@@:
mov ah,9        ;输出函数
mov dx,offset result    ;结果地址
int 21h        ;调用dos
exit:
mov ah,4ch        ;离开
int 21h        ;调用dos

Code ENDS
END START
```

• 8
• 1/1页
• 1