assume cs:code
code segment
start:mov dh,5
mov dl,0 ;以上2行自己加的,只想看实验实验结果
call short 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 noempty
mov byte ptr es:[di],' '
jmp sret
noempty: 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
程序运行后有时运行几遍都可以稳定运行,有时一运行却崩溃了,一直都未找到原因,请老师指点啊,一直在这里纠结中,结果不停的翻查16章和17章,搞得前段时间16、17章的概念都搞混了。
- [kingsgg] 是不是应该这样理解,通过逻辑扇区号进行读写,其实逻辑扇区号计出来的面、道、扇区,就是要开始进行读写的 04/23 23:21
- [游客] 经多次测试,超过10个字母就崩溃了,真奇怪,不知道是什么问题 04/23 23:05
- [chinatree] 认真看下309页,al=要操作扇区数,ah=读/写,cl=扇区号,dh=驱动器号,dl=面号。参数不 04/23 22:35
- [tomato] 应该没有博主说的那么难。前面的困难博主都克服了,最后两章肯定没有问题的。博主具体看到哪里不明白? 04/21 22:16
- [tomato] http://www.asmedu.net/bbs/pasteinfo.jsp?part=1&lev 04/18 23:24
- [tomato] 没问题。 04/15 21:53
- [tomato] 可以将间隔符也写到数据段,然后,从数据段中读取,这样,就可以统一处理,而不是单独具体处理。 04/13 22:25
- [tomato] 完成地没问题。 04/12 09:54
- [tomato] 就是很简单滴! 04/12 09:50
- [tomato] 做对了。 04/12 09:50
- [kingsgg] 十分感谢tomato老师的评价晚会努力的! 03/20 12:39
- [tomato] 博主加油!不要想那么多,只要肯努力,看重行动,看重一点行动的结果,贵在行动和心智!不要轻易放弃! 03/20 10:52
[ 游客 发表于 2012-04-23 23:05 ]
经多次测试,超过10个字母就崩溃了,真奇怪,不知道是什么问题