我在汇编程序设计时感到很痛苦,并寻求你的帮助。我不明白的是为什么即使有足够的空间,我也从缓冲区中丢失了字符串的字符?缓冲区没有正确的行为
我的readBuffer大小是32,writeBuffer大小是64,我的程序所做的是在一段时间后添加空格,并使第一个字母为大写。
例:
Good.morning.people hehehe in the jungle the mighty jungle //this is the data
Good. Morning. People hehehe in the jungle the mighty jungle //this is the output
就是我程序做:
Good.morning.people hehehe in the jungle the mighty jungle //this is the data
Good. Morning. People hehehe in e jungle the mighty jungle //this is the output
正如你可以看到我结束了 'E' 而不是 '的'
这里是我的代码做编辑:
Read:
MOV bx, DataHandle
CALL ReadBuffer
CMP ax, 0 ;ax = how many symbols did I read
JE closeWrite ;if 0 then close write file
;Editing the string
MOV cx, ax ;CX FOR LOOPING
MOV si, offset rBuff ;read buffer = si
MOV di, offset wBuff ;write buffer = di
Do_It:
MOV dl, [si]
CMP dl, '.' ;comparing to period
JNE Keep_Going ;if not period put it in di (write buffer)
MOV dh, [si+1] ;put the char after the period in dh
CMP dh, ' ' ;check if space is after it
JNE If_capital ;if not I check if it is a capital letter
MOV dh, [si+2] ;if there was a space I add the char after the space
CMP dh, 'a' ;checking if it is a capital letter
JB Keep_Going
CMP dh, 'z'
JA Keep_Going
SUB byte ptr [si+2], 32 ;turn it into a capital letter
Keep_Going:
MOV [di], dl ;put the char into writebuff
INC si
INC di
LOOP Do_It
JMP Finishin
If_capital:
CMP dh, 'a'
JB Add_Space
CMP dh, 'z'
JA Add_Space
SUB byte ptr [si+1], 32
Add_Space:
MOV [di], '.'
INC di
MOV [di], ' '
INC di
INC si
JMP Do_It
;Write the result
Finishin:
MOV cx, ax
CALL checkOnScreen ;print it to command line
MOV bx, WriteHandle
CALL writeBuffer ;print it
CMP ax, rBuffSize ;compare the size to 32
JE Read ;if it was 32 then read again
难道只是你的输出功能搞乱?据我所见,你将原始长度传递给它。 – 2014-12-02 15:23:43
**通过您的代码逐行执行**步骤**,在**调试器**中 – xmojmr 2014-12-02 16:12:03