Emu8086检查是否按下了键

时间:2014-12-03 00:24:45

标签: assembly emulation x86-16

我正在尝试检查按键“ESC”是否按下。如果按下,我希望用户能够输入文本并在之后立即打印。

如果用户按ESC键,我希望程序随时检查。

这是我目前的代码:

org 100h
include "emu8086.inc"


;mov ah, 01h
;int 16h

;mov ah, 00h
;int 16h

call cleanScreen

printn "      ___"     
printn "     /\  \"    
printn "    /::\  \"   
printn "   /:/\ \  \"  
printn "  _\:\~\ \  \" 
printn " /\ \:\ \ \__\"
printn " \:\ \:\ \/__/"
printn "  \:\ \:\__\ " 
printn "   \:\/:/  /"  
printn "    \::/  /"   
printn "     \/__/"
printn "Welcome to Sheridan"    

call cleanScreen

printn "      ___"    
printn "     /\__\"    
printn "    /:/ _/_"   
printn "   /:/ /\  \"  
printn "  /:/ /::\  \" 
printn " /:/_/:/\:\__\"
printn " \:\/:/ /:/  /"
printn "  \::/ /:/  /" 
printn "   \/_/:/  /"  
printn "     /:/  /"   
printn "     \/__/" 
printn "Welcome to Sheridan"

call cleanScreen

printn "      ___"     
printn "     /  /\"    
printn "    /  /:/_"   
printn "   /  /:/ /\"  
printn "  /  /:/ /::\" 
printn " /__/:/ /:/\:\"
printn " \  \:\/:/~/:/"
printn "  \  \::/ /:/" 
printn "   \__\/ /:/"  
printn "     /__/:/"   
printn "     \__\/"                       
printn "Welcome to Sheridan"

call cleanScreen

printn "      ___"     
printn "     /  /\"    
printn "    /  /::\"   
printn "   /__/:/\:\"  
printn "  _\_ \:\ \:\" 
printn " /__/\ \:\ \:\"
printn " \  \:\ \:\_\/"
printn "  \  \:\_\:\" 
printn "   \  \:\/:/"  
printn "    \  \::/"   
printn "     \__\/"    
printn "Welcome to Sheridan"  

cleanScreen proc
INT 10h
mov AH,0
cleanScreen endp 

enterText:  ;if ESC is press then get String and Print it
call get_string                
call print_string                                                      
RET                       

hlt
define_print_string
define_get_string
end

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

这段代码毫无意义。

cleanScreen proc
INT 10h
mov AH,0
cleanScreen endp 

如果您想通过重新设置来清洁屏幕,请使用

cleanScreen proc
mov al,3   ;Video mode number
mov ah,0   ;Function number
INT 10h
cleanScreen endp

等待ESC键使用此代码

enterText:  ;if ESC is press then get String and Print it
mov ah,0
int 16h
cmp al,27
jne enterText

P.S。很好的ASCII艺术。