⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fmenu.asm

📁 实现dos下菜单选择的小程序
💻 ASM
字号:
;***************************************************************
;include menumacro.asm
;SUBTTL Fmenu.asm
;  This programm is a fuction menu ,it include three functions
;they are: 
;1.ASCII:show the ASCII code of the keys you type with the 
;2.Print:show the charactar string you type on the screem.
;3.Make a sound:make a sound when you enter the sub programm.
;4.Exit:exit to the DOS. 
;Copyright(c)
;All copyright reserved Lichao
;****************************************************************
include menumacro.asm
data segment;数据段
charnum db ?
speednum dw ?
mainnum db ?
subprog2num db ?
subprog3num db ?
headchar db '****************************************'
head1 db    '*      Thank you for your use!!!       *'
head2 db    '*           Function Menu              *'
men db      '*                     Made by Lichao   *'          
fill  db    '*                                      *'   
main1 db 'ASCII'
main2 db 'print string'       
main3 db 'make a sound'
main4 db 'exit'
maintime db '8,30,2004'
print db 102 dup(?)
esc_key equ 1bh
win_ulc equ 10
win_ulr equ 18
win_lrc equ 16
win_lrr equ 8
win_width equ 20
subhead db 'Please enter a string(press ESC to return to main menu):'
msg1  db 'This program can show you the ASCII of characters or key combinations',0dh,0ah
msg2  db '     I hope it would help you',0dh,0ah
msg3  db '          press ESC(ASCII 1bh) to exit!',0dh,0ah
msg4  db 'this program can make a sound!'
msg5  db 'this program can display what you type on the screem with keyborad'
msg   db 'press ESC to return to the main menu!!'
         db 0dh,0ah,24h
save  db ?
char db 30 dup (?)
data ends
;
code segment                            ;代码段        
   assume cs:code,ds:data,es:data
main proc far
mov ax,data
mov ds,ax
mov es,ax
mov charnum,1
mov mainnum,1
mov subprog2num,1
mov subprog3num,1
mov speednum,1500
hidecurse 1
;
mainmenu:                              ;主菜单绘制
cls 17h,0,0,24,79
menu 1fh,40,4,20,headchar
menu 1fh,40,5,20,head1
menu 1fh,40,6,20,fill
menu 1fh,40,7,20,head2
menu 1fh,40,8,20,fill
menu 1fh,40,9,20,men
menu 1fh,40,10,20,headchar
menu 1fh,5,13,37,main1
menu 1fh,12,16,34,main2
menu 1fh,12,19,34,main3
menu 1fh,4,22,37,main4
menu 1fh,9,24,67,maintime
;                                 
movemenu1:                           ;判断光标位置                            
cmp mainnum,1
jne movemenu2
changemenu 13,37,5,0fh,main1
movemenu2:
cmp mainnum,2
jne movemenu3
changemenu 16,34,12,0fh,main2
movemenu3:
cmp mainnum,3
jne movemenu4
changemenu 19,34,12,0fh,main3
movemenu4:
cmp mainnum,4
jne waitword
changemenu 22,37,4,0fh,main4
waitword:                                  ;等待输入
mov ah,8
int 21h
;
compare:                                ;比较按键
cmp al,028h
je cmpdown1
cmp al,65h
je cmpup1
cmp al,09h
je cmpdown1
cmp al,0dh
je cmpenter1
cmp al,50h
je cmpdown1
cmp al,48h
je cmpup1
jmp waitword
cmpdown1:                               ;按下下移
cmp mainnum,4
jne cmpdown2
mov mainnum,1
jmp mainmenu;movemenu1
cmpdown2:
down1:
cmp mainnum,1
jne down2
mov mainnum,2
jmp mainmenu;movemenu1
down2:
cmp mainnum,2
jne down3
mov mainnum,3
jmp mainmenu;movemenu1
down3:
mov mainnum,4
jmp mainmenu;movemenu1
cmpup1:                                ;按上上移
cmp mainnum,1
jne cmpup2
mov mainnum,4
jmp mainmenu;movemenu1
cmpup2:
up1:
cmp mainnum,4
jne up2
mov mainnum,3
jmp mainmenu;movemenu1
up2:
cmp mainnum,3
jne up3
mov mainnum,2
jmp mainmenu;movemenu1
up3:
mov mainnum,1
jmp mainmenu;movemenu1
cmpenter1:                                ;按下回车
cmp mainnum,1
jne cmpenter2
jmp subprog1                                 ;subprog1代表扫描ASCII程序
cmpenter2:
cmp mainnum,2
jne cmpenter3
jmp subprog2                               ;subprog2代表print程序
cmpenter3:
cmp mainnum,3                                
jne cmpenter4
jmp subprog3                              ;subprog3代表选择发声程序
cmpenter4:
jmp subprog4                                ;subprog4代表结束(主菜单绘制完成)
;                             
subprog1:
call ascii
subprog2:
call print1

waitword1:
mov ah,8
int 21h
cmp al,1bh
jne waitword1
jmp mainmenu
subprog3:                                      
call sound
subprog4:
call exit
subprog5:
jmp far ptr mainmenu
main endp


sound proc near
cls 1fh,0,0,24,79
menu 1fh,30,3,3,msg4
menu 1fh,38,5,3,msg
push ax
push dx
mov dx,cx
in al,61h
and al,11111100b
trig:
xor al,2
out 61h,al
mov cx,bx
delay:
loop delay
dec dx
jne trig
pop dx
pop ax
jmp waitword1
sound endp

ascii proc near
cls 17h,0,0,24,79
start1:
menu 1fh,78,3,5,msg1
menu 1fh,29,4,5,msg2
menu 1fh,39,5,5,msg3
mov bh,0
mov dh,7
mov dl,3
mov ah,2h
int 10h
loop1:
mov ah,07h           ;输入字符
int 21h
mov save,al
cmp save,01bh          ;是否 ESC
jz done             
cmp save,00h           ;是否组合键
jnz show       
mov ah,07h            
int 21h
mov save,al
show:
mov bl,save       
mov cl,04h          
shr bl,cl    
cmp bl,09h        
jbe changdec      
add bl,07h         
changdec:               
add bl,30h        ;显示
mov dl,bl
mov ah,02h
int 21h
mov al,save
and al,0fh        ;取低四位  
cmp al,09h      
jbe chdec
add al,07h
chdec:
add al,30h
mov dl,al
mov ah,02h
int 21h
mov dl,' '
mov ah,02h
int 21h
loop loop1
done:
jmp mainmenu
ascii endp

print1 proc near
cls 17h,0,0,24,79
menu 1fh,66,3,5,msg5
menu 1fh,56,5,5,subhead
locate:
mov ah,2
mov dh,win_lrr
mov dl,win_ulc
mov bh,0
int 10h
mov cx,win_width
get_char:
mov ah,1
int 21h
cmp al,0dh
jne esc1
mov bh,0
mov ah,3
int 10h
inc dh
mov dl,0
mov ah,2h
int 10h
esc1:
cmp al,esc_key
jne get_char
jmp mainmenu
mov ah,6
mov al,1
mov ch,win_ulr
mov cl,win_ulc
mov dh,win_lrr
mov bh,7
int 10h
jmp locate
mov ah,0
int 16h
print1 endp
exit proc near
cls 07h,0,0,24,79
mov ah,4ch
int 21h
exit endp

code ends
end main

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -