现有一组字符串为data,name,time,file,code,path,user,exit,quit,text,请编写程序从键盘输入4个字符的字符串,若存在将其修改为disk, 并将结果在显示器上显示。
DATAS SEGMENT
; 此处输入数据段代码
data db 'data,name,time,file,code,path,user,exit,quit,text,$'
replace db 'disk'
buf db 5 , ? , 5 dup ( ? )
string db 'please input the word:$'
DATAS ENDS
STACKS SEGMENT
; 此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS: CODES, DS: DATAS, SS: STACKS
START:
MOV AX, DATAS
MOV DS, AX
; 此处输入代码段代码
lea dx, string
mov ah, 09 h
int 21 h
lea dx, buf
mov ah, 0 ah
int 21 h
mov dl, 0 ah
mov ah, 02 h
int 21 h
mov si, 0
mov cx, 10
edg:
push cx
mov di, 2
mov cx, 4
lng:
mov al, data[ si]
mov ah, buf[ di]
cmp al, ah
jnz fpx
inc si
inc di
loop lng
pop cx; 换或者删除
mov ax, 10
sub ax, cx
mov bl, 5
mul bl
mov di, ax
add ax, 5
mov si, ax
mov ax, cx
dec ax
mul bl
push cx
mov cx, ax
rng:
mov al, data[ si]
mov data[ di] , al
inc si
inc di
loop rng
fpx: ; 不等则比较下一个字符串
pop cx
mov ax, 11
sub ax, cx
mov bl, 5
mul bl
mov si, ax
loop edg
lea dx, data
mov ah, 0 ah
int 21 h
MOV AH, 4 CH
INT 21 H
CODES ENDS
END START