| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 629 人关注过本帖
标题:汇编语言 王爽 17.3的例题修改出错 求助
只看楼主 加入收藏
xbox1994
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-12-2
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
汇编语言 王爽 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
新人求助,都想了半天
搜索更多相关主题的帖子: 源代码 
2012-12-02 18:28
suijishu
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:66
专家分:144
注 册:2012-12-1
收藏
得分:20 
晕,你写肿么长,谁看啊
2012-12-02 18:36
快速回复:汇编语言 王爽 17.3的例题修改出错 求助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019018 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved