请替换下列程序中的某些语句,但使其功能不变,并在每一句后加上中文注释DATAS SEGMENT STRING DB 'Please input a string:',13,10,'$' STRING2 DB 'Please input a word to delete:',13,10,'$' STRING3 DB 'The deleted string is as follows:',13,10,'$' BUF1 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'$' NUM DW 0 NUM2 DW 0 BUF2 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,10,'$' NUM3 DB 0,'$' DATAS ENDS STACKS SEGMENT PARA STACK DD 128 DUP(0) STACKS ENDS CODES SEGMENT ASSUME CS:CODES,DS:DATAS,SS:STACKS START: MOV AX,DATAS MOV DS,AX LEA AX,STRING CALL DISPSTRING CALL READSTRING LEA AX,STRING2 CALL DISPSTRING CALL READCHARACTER CALL PANDUAN LEA AX,STRING3 CALL DISPSTRING CALL PRINT READSTRING PROC LEA SI,BUF1 MOV CX,0 FLAG1: MOV AH,01H INT 21H CMP AL,13 JZ NEXT MOV [SI],AL INC CX INC SI JMP FLAG1 NEXT: MOV NUM,CX RET READSTRING ENDP READCHARACTER PROC H0: MOV AH,01H INT 21H CMP AL,13 JZ H1 MOV NUM3,AL JMP H0 H1: RET READCHARACTER ENDP PANDUAN PROC MOV CX,NUM MOV DX,0 MOV BL,NUM3 LEA SI,BUF1 LEA DI,BUF2 LOOP1: MOV AL,[SI] CMP AL,BL JNZ T1 INC SI LOOP LOOP1 JMP JIESHU T1: MOV [DI],AL INC DI INC SI INC DX LOOP LOOP1 JIESHU: MOV NUM2,DX RET PANDUAN ENDP DISPSTRING PROC MOV DX,AX MOV AH,09H INT 21H RET DISPSTRING ENDP PRINT PROC MOV CX,NUM2 LEA DI,BUF2 PRINT ENDP LOOP2: MOV DL,[DI] MOV AH,02H INT 21H INC DI LOOP LOOP2 MOV AH,4CH INT 21H CODES ENDS END START
时间: 2024-01-18 08:03:24 浏览: 132
下面是修改过后的程序,已加上中文注释:
DATAS SEGMENT
STRING DB '请输入一个字符串:',13,10,'$' ; 修改了提示信息
STRING2 DB '请输入需要删除的单词:',13,10,'$' ; 修改了提示信息
STRING3 DB '删除后的字符串为:',13,10,'$' ; 修改了提示信息
BUF1 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'$'
NUM DW 0
NUM2 DW 0
BUF2 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,10,'$'
NUM3 DB 0,'$'
DATAS ENDS
STACKS SEGMENT PARA STACK
DD 128 DUP(0)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
LEA AX,STRING
CALL DISPSTRING
CALL READSTRING
LEA AX,STRING2
CALL DISPSTRING
CALL READCHARACTER
CALL PANDUAN
LEA AX,STRING3
CALL DISPSTRING
CALL PRINT
MOV AH,4CH
INT 21H
READSTRING PROC
LEA SI,BUF1
MOV CX,0
FLAG1:
MOV AH,01H
INT 21H
CMP AL,13
JZ NEXT
MOV [SI],AL
INC CX
INC SI
JMP FLAG1
NEXT:
MOV NUM,CX
RET
READSTRING ENDP
READCHARACTER PROC
H0:
MOV AH,01H
INT 21H
CMP AL,13
JZ H1
MOV NUM3,AL
JMP H0
H1:
RET
READCHARACTER ENDP
PANDUAN PROC
MOV CX,NUM
MOV DX,0
MOV BL,NUM3
LEA SI,BUF1
LEA DI,BUF2
LOOP1:
MOV AL,[SI]
CMP AL,BL
JNZ T1
INC SI
LOOP LOOP1
JMP JIESHU
T1:
MOV [DI],AL
INC DI
INC SI
INC DX
LOOP LOOP1
JIESHU:
MOV NUM2,DX
RET
PANDUAN ENDP
DISPSTRING PROC
MOV DX,AX
MOV AH,09H
INT 21H
RET
DISPSTRING ENDP
PRINT PROC
MOV CX,NUM2
LEA DI,BUF2
LOOP2:
MOV DL,[DI]
MOV AH,02H
INT 21H
INC DI
LOOP LOOP2
RET
PRINT ENDP
CODES ENDS
END START
阅读全文