所以,我必须进行文本修正。如果我在文本/字符串中遇到逗号,我需要验证它之前是否有空格以消除它并且逗号后面有空格。如果没有,我需要在逗号之后加上一个。我试图这样做,但只有在逗号工作之前消除空格的部分。当我尝试添加时,我会覆盖某些内容(我在TD中看到过),但我无法弄清楚是什么。
COMMA:
CMP BUFFER[SI],00 ; end of text
JE EXIT
CMP BUFFER[SI],44 ; 44 is the ascii code for comma
JNE NEXTC
CMP BUFFER[SI],44
JE VERIFY
NEXTC:
INC SI
JMP COMMA
VERIFY:
CMP BUFFER[SI-1],20H ; 20 ascii code for space
JNE VERIFY2 ; if it isn't space, I search if the next element after comma is space
CMP BUFFER[SI-1],20H
JE CONDITION
CONDITION:
MOV CL,L
SUB CX,SI
SHR CL,1;
XOR CH,CH;
MOV DI,SI
JMP REMOVESPACE ; I have space before the comma and I eliminate it
REMOVESPACE:
MOV DL, BUFFER[DI]
MOV BUFFER[DI-1],DL ; overwrite the useless space
INC DI
LOOP REMOVESPACE
VERIFY2:
INC SI
CMP BUFFER[SI],20H ; if there is space, I jump to the initial stuff, searching for another comma
JE COMMA
CMP BUFFER[SI],20H
JNE CONDITION2 ; if there isn't, I try to add
CONDITION2:
MOV CL,L ; L is the no of chars in the buffer
SUB CX,SI
SHR CL,1;
XOR CH,CH;
MOV DI,LEN ; LEN also as L but DW
SHR DI,1
JMP ADDSPACE
ADDSPACE:
MOV DL,BUFFER[DI]
MOV BUFFER[DI+1],DL ; here I try to move the elements, obtaining buffer[si+1] free and then move a space to it
DEC DI
LOOP ADDSPACE
MOV BUFFER[SI+1],20H
JMP COMMA
我不知道该怎么做,我认为我无法将所有元素移到右边,因为没有缓冲区[L + 1]或其他东西。< / p>