及其不严谨的统计单词之汇编语言

问题引入:
编写程序,统计字符串STRING中某个单词的个数,字符串以’$‘作为结束符,要统计的单词放在C_WORD中,统计结果存放在COUNT中。
例如:字符串为’adding that this is because of the large infrastructure investment, high operational and maintenance costs, and the old regulations governing prices.’

由于仅考虑了某一个单词在下一个字符是空格时被统计的情况,但像是逗号,句号,下一个字符是字母等情况因水平有限无法实现,还望慎重参考。

代码如下:

DATA  segment
PARA DB "adding that this is because of the large infrastructure investment, high operational and maintenance costs, and the old regulations governing prices. $"

PARALEN = $-PARA	
COUNT DB 0 
DATA ENDS

CODE SEGMENT
    ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV CX,PARALEN
MOV BX,OFFSET PARA

alp:
MOV AL,[BX]
CMP AL,'a'
JNZ next
INC BX
MOV AL,[BX]
CMP AL,'n'
JNZ next
INC BX
MOV AL,[BX]
CMP AL,'d'
JNZ next
INC BX
MOV AL,[BX]
CMP AL,' '
JNZ next
JZ next1

next1:
INC COUNT
INC BX
LOOP alp

next:
INC BX
LOOP alp




MOV AH,4CH
INT 21H
code ends
end START

应付作业算是足够了吧 - -

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值