汇编语言 王爽 17.3的例题修改出错 求助
书上的源代码:assume cs:code
code segment
start:
call getstr
mov ax,4c00h
int 21h
getstr:push ax
getstrs:mov ah,0
int 16h
cmp al,20h
jb nochar
mov ah,0
call charstack
mov ah,2
call charstack
jmp getstrs
nochar:cmp ah,0eh
je backspace
cmp ah,1ch
je enter
jmp getstrs
backspace:mov ah,1
call charstack
mov ah,2
call charstack
jmp getstrs
enter:mov al,0
mov ah,0
call charstack
mov ah,2
call charstack
pop ax
ret
charstack:jmp short charstart
table dw charpush,charpop,charshow
top dw 0
charstart:push bx
push dx
push di
push es
cmp ah,2
ja sret
mov bl,ah
mov bh,0
add bx,bx
jmp word ptr table[bx]
charpush:mov bx,top
mov [si+bx],al
inc top
jmp sret
charpop:cmp top,0
je sret
dec top
mov bx,top ;不懂这里一行以及下一行的意思,删了没有影响
mov al,[si+bx]
jmp sret
charshow:mov bx,0b800h
mov es,bx
mov al,160
mov ah,0 ;这里可以去掉吗
mul dh
mov di,ax
add dl,dl
mov dh,0
add di,dx
mov bx,0
charshows:cmp bx,top
jne noenpty
mov byte ptr es:[di],' ' ;这行删了也可以
jmp sret
noenpty:mov al,[si+bx]
mov es:[di],al
mov byte ptr es:[di+2],' '
inc bx
add di,2
jmp charshows
sret:pop es
pop di
pop dx
pop bx
ret
code ends
end start
自己想把输入字符之后自动产生的一个空格这个功能给去掉
assume cs:code
code segment
start:
call getstr
mov ax,4c00h
int 21h
getstr:push ax
push cx ;
getstrs:mov ah,0
int 16h
cmp al,20h
jb nochar
mov ah,0
call charstack
mov ah,2
call charstack
jmp getstrs
nochar:cmp ah,0eh
je backspace
cmp ah,1ch
je enter
jmp getstrs
backspace:mov cl,ah ;
mov ah,1
call charstack
mov ah,2
call charstack
jmp getstrs
enter:mov al,0
mov ah,0
call charstack
mov ah,2
call charstack
pop cx ;
pop ax
ret
charstack:jmp short charstart
table dw charpush,charpop,charshow
top dw 0
charstart:push bx
push dx
push di
push es
cmp ah,2
ja sret
mov bl,ah
mov bh,0
add bx,bx
jmp word ptr table[bx]
charpush:mov bx,top
mov [si+bx],al
inc top
jmp sret
charpop:cmp top,0
je sret
dec top ;
jmp sret
charshow:mov bx,0b800h
mov es,bx
mov al,160 ;
mul dh
mov di,ax
add dl,dl
mov dh,0
add di,dx
mov bx,0
cmp cl,0eh ;
je charback ;
charshows:cmp bx,top
jne noenpty ;
jmp sret
noenpty:mov al,[si+bx]
mov es:[di],al
inc bx ;
add di,2
jmp charshows
charback:mov di,top ;
add di,di ;
mov byte ptr es:[di],' ' ;
sret:pop es
pop di
pop dx
pop bx
ret
code ends
end start
新人求助,都想了半天