This is my sophomore time in the assembly language course design. I am satisfied with what I have done. Now take it out and show it to everyone. I've changed some of the code again. The size of the compiler is a bit larger than the original, but the speed is up. is actually a graphical interface. As long as you add your own practical function in the middle, you can use it directly. I have annotations to the code, and there should be no problem reading it. Of course, the assembly code itself is very difficult to read. So what is not very understood place, you can contact me directly.
I also made a C-language version of the light with the menu, but it is a pity that they do not very satisfied with the program to delete the. And everyone's going to be out of sight.
This program uses TASM to compile, tlink to connect.
Menu.asm Main Program
Mnmacro.asm function calls macro file
Menu.exe the compiled executable file
Menu.asm Main Program
Include Mnmacro.asm
Data segment
SCRMM db DUP (?)
; main Course Single-name
MAINMENU1 db ' File '
MAINMENU2 db ' Edit '
MAINMENU3 db ' Run '
Mainmenu4 db ' Debug '
Mainmenu5 db ' help '
; The submenu under the main menu file Single-name
Submenu11 db ' Save '
Submenu12 db ' Open '
Submenu13 db ' Exit '
; the submenu under Edit of Main Menu Single-name
Submenu21 db ' Cut '
Submenu22 db ' past '
Submenu23 db ' Copy '
; main Menu Run sub-dish single-name
SUBMENU31 db ' Run '
Submenu32 db ' Go to '
SUBMENU33 db ' Step '
; main Menu The submenu under Debug Single-name
SUBMENU41 db ' call '
Submenu42 db ' Find '
submenu43 db ' Source '
; The submenu under the main menu help Single-name
submenu51 db ' About '
submenu52 db ' Our '
submenu53 db ' Web '
; Welcome window Information
Msgtitle db ' Assemble design '
MSG1 DB ' please press alt+f,alt+e,alt+r,alt+d,alt+h or ', 19h, ' to open the submenu. '
MSG2 DB ' Please press Enter (', 11h,0c4h,0d9h, ') to close the submenu. '
MSG3 db ' Please press ', 1bh, ' or ', 1ah, ' to select the MainMenu. '
MSG4 db ' Please press ', 18h, ' or ', 19h, ' to select the submenu. '
MSG5 DB ' Copyright 2002 Mikespook '
MSG6 db ' Press any key to continue ... '
Msg7 DB '
; Exit Window Info '
Over DB ' Thank for uesing ... Good buy~~ '
; Other information
Escape db ' Press ESC to exit. '
Text1 db ' This is a example showing for you/make a menu with assemble. '
Text2 db ' and you could get it to free from http://lucky7.yeah.net. '
Text3 db ' You could use it in your software freely. '
TEXT4 db ' But please send me a copy of the Your software. '
TEXT5 db ' Thank you. Have a good time. '
Text6 db '--yours truly Mikespook '
SUB11 db ' Select Save '
SUB12 db ' Select Open '
Sub13 db ' Select Exit '
Sub21 db ' Select cut '
Sub22 db ' Select past '
Sub23 db ' Select Copy '
Sub31 db ' Select Run '
SUB32 db ' Select go '
Sub33 db ' Select step '
SUB41 db ' Select call '
Sub42 db ' Select find '
Sub43 db ' Select Source '
SUB51 db ' Select about '
Sub52 db ' Select our '
Sub53 db ' Select Web '
;-------------------------
Mainnum DB 1; main Menu serial number
Subnum db?; Sub-menu Serial number
Subshow db 0 0 O'Clock submenu not displayed
Mainindex db?; Main Menu Character length
Data ends
;--------------------------------
Code segment
Assume Cs:code,ds:data,es:data
Start
MOV Ax,data
MOV Ds,ax
MOV Es,ax
; ******************* Initialize screen start
MOV ah,0
MOV al,03h
int 10h
; ******************* Initialization Screen End
Showcur 1; Hide cursor
; ************************************* start drawing of main window
Drawwindow 1eh,0,0,24,79
Outputstr msgtitle,15,10,30,13h
Outputstr msg1,68,15,5,17h
Changemenu 15,18,5,1eh
Changemenu 15,24,5,1eh
Changemenu 15,30,5,1eh
Changemenu 15,36,5,1eh
Changemenu 15,42,5,1eh
Changemenu 15,51,1,1eh
Outputstr msg2,46,16,5,17h
Changemenu 16,18,11,1eh
Outputstr msg3,43,17,5,17h
Changemenu 17,18,1,1eh
Changemenu 17,23,1,1eh
Outputstr msg4,42,18,5,17h
Changemenu 18,18,1,1eh
Changemenu 18,23,1,1eh
Outputstr MSG5,24,13,5,1FH
Outputstr Msg6,28,20,40,9eh
Outputstr msg7,19,9,28,93h
Outputstr msg7,19,11,28,93h
SetPos 10,28
Outputchar ', 93h,1
SetPos 10,46
Outputchar ', 93h,1
MOV ah,07h
int 21h
Drawwindow 1eh,0,0,24,79
Drawwindow 70h,0,0,0,79
Drawwindow 70h,24,0,24,79
SetPos 1,0
Windowtandb 0d5h,0cdh,0b8h,1,0,80,1eh
MOV al,2
Draw
Windowlandr 0b3h,al,0,80,1eh
Inc AL
CMP al,17h
Jne Draw
Windowtandb 0c0h,0c4h,0d9h,23,0,80,1eh
Outputstr escape,18,24,3,70h
; *************************************** start drawing of main Menu
SetPos 0,3
Outputstr MAINMENU1,4,0,3,0FH
Outputstr mainmenu2,4,0,13,70h
Changemenu 0,13,1,74h
Outputstr mainmenu3,3,0,23,70h
Changemenu 0,23,1,74h
Outputstr mainmenu4,5,0,33,70h
Changemenu 0,33,1,74h
Outputstr mainmenu5,4,0,43,70h
Changemenu 0,43,1,74h
SetPos 0,3
; *********************************** end Main window and main Menu drawing
Outputstr msg1,68,15,5,17h
Changemenu 15,18,5,1eh
Changemenu 15,24,5,1eh
Changemenu 15,30,5,1eh
Changemenu 15,36,5,1eh
Changemenu 15,42,5,1eh
Changemenu 15,51,1,1eh
Outputstr msg2,46,16,5,17h
Changemenu 16,18,11,1eh
Outputstr msg3,43,17,5,17h
Changemenu 17,18,1,1eh
Changemenu 17,23,1,1eh
Outputstr msg4,42,18,5,17h
Changemenu 18,18,1,1eh
Changemenu 18,23,1,1eh
Outputstr Text1,63,3,5,1ah
Outputstr Text2,58,4,5,1ah
Outputstr Text3,41,5,5,1ah
Outputstr Text4,43,6,5,1ah
Outputstr Text5,28,7,5,1ah
Outputstr Text6,23,9,25,1ah
Input:; message receive loop
MOV ah,0
int 16h
CMP ah,01h
Jne continue1
Call exit
JMP input
Continue1:
CMP AH,4BH
Jne continue2
Call Prsleft
JMP input
Continue2:
CMP AH,4DH
Jne Continue3
Call Prsright
JMP input
CONTINUE3:
CMP ah,50h
Jne Continue4
Call Prsdown
JMP input
Continue4:
CMP ah,21h
Jne Continue5
MOV ah,02h
int 16h
and AL,0FH
CMP al,08h
Jne Continue5
Call Falt
JMP input
Continue5:
CMP ah,12h
Jne Continue6
MOV ah,02h
int 16h
and AL,0FH
CMP al,08h
Jne Continue6
Call Ealt
JMP input
Continue6:
CMP ah,13h
Jne Continue7
MOV ah,02h
int 16h
and AL,0FH
CMP al,08h
Jne Continue7
Call Ralt
JMP input
Continue7:
CMP ah,20h
Jne Continue8
MOV ah,02h
int 16h
and AL,0FH
CMP al,08h
Jne Continue8
Call Dalt
JMP input
Continue8:
CMP ah,23h
Jne Continue9
MOV ah,02h
int 16h
and AL,0FH
CMP al,08h
Jne Continue9
Call HAlt
JMP input
CONTINUE9:
CMP ah,48h
Jne Continue10
Call Prsup
JMP input
Continue10:
CMP ah,1ch
Jne Continue11
Call Prsenter
JMP input
CONTINUE11:
JMP input
;-----------------
Prsenter proc near; Press the ENTER key
CMP subshow,0
Jne Enter1
Call Prsdown
Ret
Enter1:
MOV al,mainnum
Push AX
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
Dec mainnum
WRITESCR MAINNUM,SCRMM
Inc Mainnum
SetPos 0,mainnum
Pop ax
MOV Mainnum,al
Drawwindow 13h,22,4,22,50
CMP mainnum,1
Jne Prsenter1
CMP subnum,2
Jne ENTERSUB12
Outputstr sub11,11,22,5,13h
ENTERSUB12:
CMP subnum,3
Jne Entersub13
Outputstr sub12,11,22,5,13h
Entersub13:
CMP subnum,4
Jne Prsenter1
Outputstr sub13,11,22,5,13h
Call exit
Prsenter1:
CMP mainnum,2
Jne Prsenter2
CMP subnum,2
Jne entersub22
Outputstr sub21,10,22,5,13h
Entersub22:
CMP subnum,3
Jne entersub23
Outputstr sub22,11,22,5,13h
ENTERSUB23:
CMP subnum,4
Jne Prsenter2
Outputstr sub23,11,22,5,13h
Prsenter2:
CMP mainnum,3
Jne Prsenter3
CMP subnum,2
Jne Entersub32
Outputstr sub31,10,22,5,13h
ENTERSUB32:
CMP subnum,3
Jne entersub33
Outputstr sub32,12,22,5,13h
Entersub33:
CMP subnum,4
Jne Prsenter3
Outputstr sub33,11,22,5,13h
Prsenter3:
CMP mainnum,4
Jne Prsenter4
CMP subnum,2
Jne entersub42
Outputstr sub41,11,22,5,13h
ENTERSUB42:
CMP subnum,3
Jne entersub43
Outputstr sub42,11,22,5,13h
ENTERSUB43:
CMP subnum,4
Jne Prsenter4
Outputstr sub43,13,22,5,13h
Prsenter4:
CMP mainnum,5
Jne Prsenter5
CMP subnum,2
Jne entersub52
Outputstr sub51,12,22,5,13h
Entersub52:
CMP subnum,3
Jne entersub53
Outputstr sub52,10,22,5,13h
ENTERSUB53:
CMP subnum,4
Jne Prsenter5
Outputstr sub53,10,22,5,13h
PRSENTER5:
MOV subshow,0
Ret
Prsenter ENDP
;----------------
Halt proc near; H+alt
MOV al,mainnum
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
CMP subshow,1
Jne Hshow
Dec mainnum
WRITESCR MAINNUM,SCRMM
Inc Mainnum
Hshow:
READSCR 42,SCRMM
submenu 42,submenu51,5,submenu52,3,submenu53,3,9
Changemenu 0,mainnum,5,70h
Changemenu 0,mainnum,1,74h
MOV mainnum,05h
Changemenu 0,43,4,0FH
Changemenu 2,44,6,0FH
MOV subnum,2
MOV subshow,1
SetPos 0,43
Ret
Halt ENDP
;----------------
Dalt proc Near;d+alt
MOV al,mainnum
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
CMP subshow,1
Jne DShow
Dec mainnum
WRITESCR MAINNUM,SCRMM
Inc Mainnum
DShow
READSCR 32,SCRMM
submenu 32,submenu41,4,submenu42,4,submenu43,6,9
Changemenu 0,mainnum,5,70h
Changemenu 0,mainnum,1,74h
MOV mainnum,04h
Changemenu 0,33,5,0FH
Changemenu 2,34,6,0FH
MOV subnum,2
MOV subshow,1
SetPos 0,33
Ret
Dalt ENDP
;----------------
Ralt proc near; R+alt
MOV al,mainnum
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
CMP subshow,1
Jne Rshow
Dec mainnum
WRITESCR MAINNUM,SCRMM
Inc Mainnum
Rshow:
READSCR 22,SCRMM
submenu 22,submenu31,3,submenu32,5,submenu33,4,9
Changemenu 0,mainnum,5,70h
Changemenu 0,mainnum,1,74h
MOV mainnum,03h
Changemenu 0,23,3,0FH
Changemenu 2,24,6,0FH
MOV subnum,2
MOV subshow,1
SetPos 0,23
Ret
Ralt ENDP
;----------------
Ealt proc near; E+alt
MOV al,mainnum
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
CMP subshow,1
Jne Eshow
Dec mainnum
WRITESCR MAINNUM,SCRMM
Inc Mainnum
Eshow:
READSCR 12,SCRMM
submenu 12,submenu21,3,submenu22,4,submenu23,4,9
Changemenu 0,mainnum,5,70h
Changemenu 0,mainnum,1,74h
MOV mainnum,02h
Changemenu 0,13,4,0FH
Changemenu 2,14,6,0FH
MOV subnum,2
MOV subshow,1
SetPos 0,13
Ret
Ealt ENDP
;----------------
Falt proc near; F+alt
MOV al,mainnum
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
CMP subshow,1
Jne Fshow
Dec mainnum
WRITESCR MAINNUM,SCRMM
Inc Mainnum
Fshow:
READSCR 2,SCRMM
submenu 2,submenu11,4,submenu12,4,submenu13,4,9
Changemenu 0,mainnum,5,70h
Changemenu 0,mainnum,1,74h
MOV mainnum,01h
Changemenu 0,3,4,0FH
Changemenu 2,4,6,0FH
MOV subnum,2
MOV subshow,1
SetPos 0,3
Ret
Falt ENDP
;----------------
Prsup proc near; Press the UP ARROW
CMP subshow,0
Jne prsup2
Ret
PRSUP2:
MOV al,mainnum
Push AX
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
Changemenu subnum,mainnum,8,70h
Inc Mainnum
Changemenu subnum,mainnum,1,74h
Pop ax
MOV Mainnum,al
CMP subnum,02h
Jne Prsuptop
MOV subnum,04h
JMP Prsup1
Prsuptop:
Dec subnum
Prsup1:
MOV al,mainnum
Push AX
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
Changemenu SUBNUM,MAINNUM,8,0FH
Pop ax
MOV Mainnum,al
Ret
Prsup ENDP
;----------------
Prsdown proc near; Press the Arrow
CMP subshow,0
Jne PRSDOWN2
CMP mainnum,1
Jne prsdown3
Call Falt
JMP prsdown7
PRSDOWN3:
CMP mainnum,2
Jne PRSDOWN4
Call Ealt
JMP prsdown7
PRSDOWN4:
CMP mainnum,3
Jne prsdown5
Call Ralt
JMP prsdown7
PRSDOWN5:
CMP mainnum,4
Jne prsdown6
Call Dalt
JMP prsdown7
PRSDOWN6:
Call Halt
PRSDOWN7:
Ret
PRSDOWN2:
MOV al,mainnum
Push AX
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
Changemenu subnum,mainnum,8,70h
Inc Mainnum
Changemenu subnum,mainnum,1,74h
Pop ax
MOV Mainnum,al
CMP subnum,04h
Jne Prsdownbot
MOV subnum,02h
JMP Prsdown1
Prsdownbot:
Inc Subnum
PRSDOWN1:
MOV al,mainnum
Push AX
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
Changemenu SUBNUM,MAINNUM,8,0FH
Pop ax
MOV Mainnum,al
Ret
Prsdown ENDP
;----------------
Prsright proc near; Press RIGHT Arrow
CMP subshow,0
Je prsright1
Call Prsrgtsub
Ret
PRSRIGHT1:
MOV al,mainnum
Push AX
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
Changemenu 0,mainnum,5,70h
Changemenu 0,mainnum,1,74h
Pop ax
MOV Mainnum,al
CMP mainnum,05h
Jne prsright2
MOV mainnum,01h
JMP PRSRIGHT3
Prsright2:
Inc Mainnum
PRSRIGHT3:
CMP mainnum,1
Je prsright4
CMP mainnum,2
Je prsright4
CMP mainnum,5
Je prsright4
CMP mainnum,3
Je prsright5
CMP mainnum,4
Je prsright6
PRSRIGHT4:
MOV mainindex,4
JMP PRSRIGHT7
PRSRIGHT5:
MOV mainindex,3
JMP PRSRIGHT7
PRSRIGHT6:
MOV mainindex,5
PRSRIGHT7:
MOV al,mainnum
Push AX
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
Changemenu 0,MAINNUM,MAININDEX,0FH
Pop ax
MOV Mainnum,al
Ret
Prsright ENDP
;----------------
Prsrgtsub proc near; Press RIGHT arrow when submenu is open
CMP mainnum,1
Jne PRSRGT1
Call Ealt
JMP PRSRGT5
PRSRGT1:
CMP mainnum,2
Jne PRSRGT2
Call Ralt
JMP PRSRGT5
PRSRGT2:
CMP mainnum,3
Jne PRSRGT3
Call Dalt
JMP PRSRGT5
PRSRGT3:
CMP mainnum,4
Jne PRSRGT4
Call Halt
JMP PRSRGT5
PRSRGT4:
Call Falt
PRSRGT5:
Ret
Prsrgtsub ENDP
;----------------
Prsleft proc near; Press LEFT Arrow
CMP subshow,0
Je prsleft1
Call Prslftsub
Ret
PRSLEFT1:
MOV al,mainnum
Push AX
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
Changemenu 0,mainnum,5,70h
Changemenu 0,mainnum,1,74h
Pop ax
MOV Mainnum,al
CMP mainnum,01h
Jne prsleft2
MOV mainnum,05h
JMP prsleft3
PRSLEFT2:
Dec mainnum
PRSLEFT3:
CMP mainnum,1
Je prsleft4
CMP mainnum,2
Je prsleft4
CMP mainnum,5
Je prsleft4
CMP mainnum,3
Je prsleft5
CMP mainnum,4
Je prsleft6
PRSLEFT4:
MOV mainindex,4
JMP Prsleft7
PRSLEFT5:
MOV mainindex,3
JMP Prsleft7
PRSLEFT6:
MOV mainindex,5
PRSLEFT7:
MOV al,mainnum
Push AX
MOV cl,0ah
MUL CL
Sub ax,07h
MOV Mainnum,al
Changemenu 0,MAINNUM,MAININDEX,0FH
Pop ax
MOV Mainnum,al
Ret
Prsleft ENDP
;----------------
Prslftsub proc near; Press LEFT arrow when submenu is open
CMP mainnum,1
Jne PRSLFT1
Call Halt
JMP PRSLFT5
PRSLFT1:
CMP mainnum,2
Jne prslft2
Call Falt
JMP PRSLFT5
PRSLFT2:
CMP mainnum,3
Jne prslft3
Call Ealt
JMP PRSLFT5
PRSLFT3:
CMP mainnum,4
Jne PRSLFT4
Call Ralt
JMP PRSLFT5
PRSLFT4:
Call Dalt
PRSLFT5:
Ret
Prslftsub ENDP
;----------------
Exit proc near; Quit child process
Drawwindow 1eh,0,0,24,79
Outputstr msgtitle,15,10,30,13h
Outputstr over,34,15,21,15h
Outputstr msg7,19,9,28,93h
Outputstr msg7,19,11,28,93h
SetPos 10,28
Outputchar ', 93h,1
SetPos 10,46
Outputchar ', 93h,1
MOV ah,07h
int 21h
MOV ah,0
MOV al,03h
int 10h
MOV ah,4ch
int 21h
Ret
Exit ENDP
;-----------------
Code ends
;-----------------------
End Start