|
主题 : : 搞了一天了,还是没找到bug,调试没问题,但是运行老是有问题。 [待解决] |
回复[ 4次 ]
点击[ 336次 ] | |
荣誉值:0
信誉值:0
注册日期:2010-11-26 22:22 |
在MenuKeyEventInput运行后,即调用int 16h后,后面的打印运行不正常,非常奇怪,但在debug模式却可以打印出来。将MenuKeyEventKeyPressMsg放在int 16h前,倒是没问题。
麻烦各位看看,万分感谢。
;Ver 1.18
codes segment
assume cs:codes
start:
;--------------------Set up boot up, ready to copy to disk----
call BootUp
mov ax,4c00h
int 21h
BootUp:
Message:
jmp Main
MsgMenuInit: db 'Menu is show #'
MsgMenuKeyRemind: db 'Pls press key #'
MsgMenuKeyPress: db 'You have select option: #'
MsgEmpty: db ' #'
Main:
;call InitMenu
call MenuKeyEvent
jmp Main
MOV AH,4CH
INT 21H
;--------------------------Print menu------------------------
InitMenu:
jmp MenuMain
MenuTemplate:
db '1) Reset PC|'
db '2) Start DOS|'
db '3) Show time|'
db '4) Edit time|'
db '#'
MenuMain:
push ax
push si
push cx
push di
push bx
push ds
push es
mov ax,0b800h
mov ds,ax
mov si,0
mov bx,0
mov ax,cs ;@TODO resume to 7c00h
mov es,ax
mov di,offset MenuTemplate
MenuPrint:
cmp byte ptr es:[di],'#'
je InitMenuDone
cmp byte ptr es:[di],'|'
jne MenuCurrentLine
MenuNextLine:
add bx,160
mov si,0
inc di
jmp MenuPrint
MenuCurrentLine:
mov al,es:[di]
mov ah,02h
mov ds:[160 * 10 + si + bx],ax
add si,2
inc di
jmp MenuPrint
InitMenuDone:
;--------------------Debug purpose -------
InitMenuMsg:
mov ax,cs ;@TODO resume to 7c00h
mov ds,ax
mov si,offset MsgMenuInit
mov di,5
call Print
pop es
pop ds
pop bx
pop di
pop cx
pop si
pop ax
ret
InitMenuEnd: nop
;-----------------Print Menu End ------------------
;-----------------Print Method --------------------
;End with #
;@Par ds,si @di, line no.
Print:
push bx
push es
push ax
push si
push di
push dx
mov bx,0b800h
mov es,bx
mov ax,di
mov dx,0
mov di,160
mul di
mov di,ax
PrintMain:
mov cx,25
SubPrint:
mov byte ptr al,ds:[si]
cmp al,'#'
je PrintEnd
mov ah,02
mov es:[di],ax
add di,2
inc si
loop SubPrint
PrintEnd:
pop dx
pop di
pop si
pop ax
pop es
pop bx
ret
nop
;-----------------Menu Key Event -------------------
MenuKeyEvent:
MenuKeyEventMain:
push ax
push bx
push ds
push si
push di
;------Debug purpose ---------
MenuKeyEventClean:
mov ax,cs ;@TODO resume to 7c00
mov ds,ax
mov si,offset MsgEmpty
mov di,5
call Print
MenuKeyEventMsg:
mov ax,cs ;@TODO resume to 7c00
mov ds,ax
mov si,offset MsgMenuKeyRemind
mov di,20
call Print
MenuKeyEventInput:
mov al,0
mov ah,0
int 16h
mov bx,ax
MenuKeyEventKeyPressMsg:
mov ax,cs ;@TODO resume to 7c00
mov ds,ax
mov si,offset MsgMenuKeyPress
mov di,20
call Print
MenuKeyPrintSelOption:
mov ax,0b800h
mov ds,ax
mov bh,02
mov ds:[160 * 20 + 2 * 30 ],bx ;Hardcode no.24 line
MenuKeyEventEnd:
pop di
pop si
pop ds
pop bx
pop ax
ret
EndBootUp: nop
codes ends
end start | | |