我在为我的任务编写代码时遇到了问题。该程序应该做的是:在句子的末尾,当我遇到句号(。)时,我应该检查句点之后是否有空格,以及下一句的第一个字母是否为大写。所以这是我的代码的一部分,它完成了这项工作。但是,当我运行程序时它没有做任何事情,光标只是闪烁,程序没有关闭或显示编辑的句子。
MOV cx, ax
MOV si, offset readBuff ;read buffer
MOV di, offset writeBuff ;write buffer
MOV bl, 97 ;lowercase 'a'
MOV bh, 122 ;lowercase 'z'
work:
MOV dl, [si] ;
CMP dl, '.' ;check if symbol is a period
JNE continue ;if no, then just print the symbol
MOV dh, [si+1] ;if it is a period move next symbol to dh
CMP dh, ' ' ; check if it is a space
JNE add_space ;if no, then go to add space
MOV dh, [si+2] ;put the first letter of the sentence to dh
cmp dh, bl ;compare it to 'a'
jb continue ;if below then print the symbol
cmp dh, bh ;compare it to 'z'
ja continue ;if above then print the symbol
sub byte ptr [si+2], 32 ;if lowercase, then make it uppercase
continue:
MOV [di], dl ;write symbol to writeBuffer
INC si
INC di
LOOP work
add_space:
MOV [di], '.' ;first add a period
INC di
MOV [di], ' ' ;then a space; argument needs type override error
INC di
INC si
CMP cx, 0
JNE work ;go back to work