汇编scasb问题,字符串查找问题

题目要求:
1) 把从LIST 到LIST+316中的字符串传送到BLK到BLK+316 中去;
2) 在BLK到BLK+100中查找字符“cqu”字符串,并记下“CQU”字符串出现的起始位置到BX中。
说明,LIST 到LIST+100的内容(from:http://study.cqu.edu.cn/IndexOfEnglish/Index)为:
Chongqing University (CQU) is a key national university and a member of the “Excellence League”, located in Chongqing, Southwest China. It is also one of the “211 Project" and "985 Project” universities with full support in construction and development from the central government and Chongqing Municipal Government.

我是这样写的:

 data segment
     LIST   db   'Chongqing University (CQU) is a key national university and a member of the “Excellence League”,'
                db  'located in Chongqing, Southwest China. It is also one of the “211 Project" '
                 db   'and "985 Project” universities with full support in construction and develop'
                 db       ' ment from the central government and Chongqing Municipal Government.$'
     CQU   db   'CQU'
data ends
extra segment
     BLK    db    316 dup(?)
extra ends
stack segment
stack ends
code segment
     assume cs:code,ds:data,ss:stack
start:
     mov ax, data
     mov ds, ax
     mov ax, extra
     mov es, ax
     lea    si, LIST
     lea    di, BLK
     mov cx, 316
     cld
     rep   movsb
     mov al, 'C'
     lea   si, LIST-1
find:
     inc si
     repne   scasb
     jnz  check
check:
     mov cx, 3
     repz cmpsb
     jz     stop
     jnz   find
stop:
     mov bx, si
     mov ah, 4ch
     int 21h
code ends
end start

字符串的传递没有问题,但是查找字符串就出问题。
我的思路是,在find中,先将每一个字符与C判断,如果字符是C的话,就跳转到check中,在check中在与字符串CQU判断,如果不是CQU的话则返回到find中。现在的问题是scasb查找到C时,返回的结果不为0。
求大神解答,另外我的思路有问题吗?求更好的思路。

查看全部
HeiGe__
HeiGe__
2016/11/09 16:48
  • 汇编
  • scasb
  • 查找
  • 字符串
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复