我写的这段代码是死循环,但我找不到错误,请各位帮忙
将text2的内容加到text1的结尾
BUFFERLEN = 8
DATA SEGMENT
FILENAME1 DB 'TEXT1.TXT',0
FILENAME2 DB 'TEXT2.TXT',0
BUFFER DB BUFFERLEN DUP (0)
ERROR1 DB 'CANNOT OPEN FILE',07H,'$'
ERROR2 DB 'CANNOT READ FILE',07H,'$'
ERROR3 DB 'CANNOT WRITE TO FILE',07H,'$'
HANDLE1 DW 0
HANDLE2 DW 0
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
STARTTT:MOV AX,DATA
MOV DS,AX
MOV DX,OFFSET FILENAME1 ;以只写打开text1
MOV AL,01H
MOV AH,3DH
INT 21H
JC OPEN_ERROR ;打开文件失败
MOV HANDLE1,AX
MOV DX,OFFSET FILENAME2 ;以只读打开text2
MOV AL,00H
MOV AH,3D
INT 21H
JNC OPENED2 ;打开文件2成功
MOV BX,HANDLE1 ;如果打开text2失败则先关闭text1
MOV AL,0
MOV AH,3EH
INT 21H
JMP OPEN_ERROR
OPENED2:MOV HANDLE2,AX
MOV BX,HANDLE1 ;将text1的文件指针移动到文件尾
XOR CX,CX
XOR DX,DX
MOV AX,4202H
INT 21H
CONT:MOV BX,HANDLE2 ;读取text2的内容
MOV CX,BUFFERLEN
MOV DX,OFFSET BUFFER
MOV AH,3FH
INT 21H
JC READ_ERROR
OR AX,AX ;判断是否读完了
JZ CLOSEFILE
MOV BX,HANDLE1 ;写入text1中
MOV CX,AX
MOV AH,40H
INT 21H
JNC CONT ;如果写成功则继续
MOV DX,OFFSET ERROR3 ;如果写失败则显示错误信息,并跳转到关闭文件
MOV AH,9
INT 21H
JMP CLOSEFILE
OPEN_ERROR:MOV DX,OFFSET ERROR1
MOV AH,9
INT 21H
JMP OVER
READ_ERROR:MOV DX,OFFSET ERROR2
MOV AH,9
INT 21H
JMP OVER
CLOSEFILE:MOV BX,HANDLE1
MOV AH,3EH
INT 21H
MOV BX,HANDLE2
MOV AH,3EH
INT 21H
OVER:MOV AH,4CH
INT 21H
CODE ENDS
END STARTTT
这个是清华那本教材的例题,我只改动了一点就不行了