WEB开发网
开发学院软件开发汇编语言 汇编源代码之汇编语言制作的光带菜单及源程序(1.0... 阅读

汇编源代码之汇编语言制作的光带菜单及源程序(1.0)

 2009-01-28 09:37:03 来源:WEB开发网   
核心提示:这个是我上大二的时候的汇编语言课程设计,自己做得很满意,汇编源代码之汇编语言制作的光带菜单及源程序(1.0),现在拿出来,给大家看看,就把程序给删掉了,大家也就看不到了 本程序用 tasm 进行编译,我对部分代码又从新做了调整,编译后大小比原来大了一点

这个是我上大二的时候的汇编语言课程设计。自己做得很满意。现在拿出来,给大家看看。我对部分代码又从新做了调整。编译后大小比原来大了一点,不过速度上去了。其实就是一个图形接口。你只要在中间加上自己的实用功能,就可以直接用了。代码我都有注释,读起来应该不会有什么问题。当然,汇编的代码本身就很难读。所以有什么不是很好懂的地方,可以直接同我联系。

我还给同学做过一个C语言版的光带菜单,不过很可惜的是自己做得不是很满意,就把程序给删掉了。大家也就看不到了

本程序用 tasm 进行编译,tlink 进行连接。

menu.asm 主程序

mnmacro.asm 功能调用宏文件

menu.exe 编译后的可执行文件

menu.asm 主程序
include mnmacro.asm
data segment
scrmm db 100 dup(?)
;主菜单名
mainmenu1 db 'File'
mainmenu2 db 'Edit'
mainmenu3 db 'Run'
mainmenu4 db 'Debug'
mainmenu5 db 'Help'
;主菜单File下的子菜单名
submenu11 db 'Save'
submenu12 db 'Open'
submenu13 db 'Exit'
;主菜单Edit下的子菜单名
submenu21 db 'Cut'
submenu22 db 'Past'
submenu23 db 'Copy'
;主菜单Run下的子菜单名
submenu31 db 'Run'
submenu32 db 'Go to'
submenu33 db 'Step'
;主菜单Debug下的子菜单名
submenu41 db 'Call'
submenu42 db 'Find'
submenu43 db 'Source'
;主菜单Help下的子菜单名
submenu51 db 'About'
submenu52 db 'Our'
submenu53 db 'Web'
;欢迎窗口信息
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 ' '
;退出窗口信息 '
over db 'Thank you for uesing...Good buy~~ '
;其他信息
escape db 'Press ESC to exit.'
text1 db 'This is a example showing you how to make a menu with assemble.'
text2 db 'And you could get it for 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 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 to'
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;主菜单序列号
subnum db ?;子菜单序列号
subshow db 0;为0时子菜单未显示
mainindex db ?;主菜单字符长度
data ends
;--------------------------------
code segment
assume cs:code,ds:data,es:data
start:
mov ax,data
mov ds,ax
mov es,ax
;******************* 初始化屏幕开始
mov ah,0
mov al,03h
int 10h
;******************* 初始化屏幕结束
showcur 1 ;隐藏光标
;************************************* 开始主窗口的绘制
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
;***************************************开始主菜单的绘制
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
;*********************************** 结束主窗口和主菜单的绘制
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:;消息接收循环
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;按下ENTER键
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; 按上箭头
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; 按下箭头
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; 按右箭头
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;当子菜单打开时按右箭头
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;按左箭头
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;当子菜单打开时按左箭头
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;退出子过程
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

1 2  下一页

Tags:汇编 源代码 汇编语言

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接