收藏 分享(赏)

微机接口汇编语言程序设计实例.doc

上传人:dzzj200808 文档编号:2319406 上传时间:2018-09-10 格式:DOC 页数:27 大小:349.50KB
下载 相关 举报
微机接口汇编语言程序设计实例.doc_第1页
第1页 / 共27页
微机接口汇编语言程序设计实例.doc_第2页
第2页 / 共27页
微机接口汇编语言程序设计实例.doc_第3页
第3页 / 共27页
微机接口汇编语言程序设计实例.doc_第4页
第4页 / 共27页
微机接口汇编语言程序设计实例.doc_第5页
第5页 / 共27页
点击查看更多>>
资源描述

1、目录一、设计内容 3一、设计目的 3三、程序流程图 3四、源程序代码 3五、程序截图 .16六、总结 17一设计内容当按下 F1 键时,弹出文件菜单,支持上下任意选择、选中变色、激活与否的功能。当在编辑区输入字符或是有粘贴操作时,修改提示信息都会做相应改动,这关系到当退出时是否提示用户保存文件。如果未做修改则直接退出,否则提示用户保存。当输入字符或是光标有所变动时,提示信息会自动改变。这个行列是经过变换后的行列,当按下新建菜单时编辑区顶部有自动生成的文件名。并且此默认生的文件名随着响应新建菜单而尾数加一,随着退出文件(escape )而减一。本文本编辑器支持上下左右方向键、HOME、END,E

2、NTER、BackSpace、Delete 等等功能键的操作。二设计目的掌握简易文本编辑器、学习各种代码的功能。三程序流程图开始欢迎 并初始化读取 键盘输入判断l 输 入字符如果是F 2如果是F 1调用 文件菜单 显示模块调用音乐播放菜单显示模块如果是调用编辑菜单j 显示 模块调用 帮助显示 模块其他输入结束其他输入四源程序代码滚动窗体宏定义win MACRO lux,luy,rdx,rdy,attrMOVAH,6MOVAL,0MOVBH,attr ;前景背景属性MOVCH,luxMOVCL,luyMOVDH,rdxMOVDL,rdyINT10h ENDM;滚动窗体宏定义 2win2 MACR

3、O lal,lux,luy,rdx,rdy,attrMOVAH,6MOVAL,lalMOVBH,attr ;前景背景属性MOVCH,luxMOVCL,luyMOVDH,rdxMOVDL,rdyINT10hENDM saveE MACROPUSH AXPUSH BXPUSH CXPUSH DXPUSH DSPUSH SIENDMrecover MACROPOP SIPOP DSPOP DXPOP CXPOP BXPOP AXENDM fileIO MACRO X,YLEA DX,XMOV AH,YINT 21HENDMshowM MACRO messMposcur 24,0LEA DX,mess

4、MMOV AH,09HINT 21H ENDM ;-;字符串显示宏定义show MACRO mess LEADX,messMOVAH,09hINT21hENDM;-;光标定位宏定义posget MACRO ;读光标位置MOV AH,03hMOV BH,0INT 10hENDM posgetS MACROsaveEMOV AH,03hMOV BH,0INT 10hMOV row,DHMOV column,DLrecoverENDM poscur MACRO x,yMOVAH,2MOVDH,xMOVDL,yMOVBH,0INT10hENDM;-;读取键盘readChar MACROMOV BH,0

5、MOV AH,8hINT 10hENDMputchar MACRO x MOV DL,xMOV AH,02HINT 21H ENDMgetchar MACROMOV AH,0INT 16h ENDM ;*;*;EXTRN fileProc:NEAR ;数据段定义; .386 data_seg SEGMENTtotalChars DB 0 ;字符总数,以此来控制数据缓冲区,CHar1 DB 0b3h ;常量,是一个竖线tempchar DB ? ;临时字节变量musicInt DB 0 ;文件数量musicIndex DB 30h ;默认文件名的最后一个字符 ,随新建打开而增 1,关闭减 1Sa

6、veAsFlag DB 0 ;已调用过 filesaveas 函数modifyFlag DB 0 ;为 0 时已做修改AsOrIfFlag DB 0 ;为 0 时是 saveas 调用 saveActive DB 78h ;根据 musicInt 来判断是否激活save,saveAs 菜单 copyActive DB 78h ;根据 copyFlag 来判断是否激活copy,cut 菜单 pasteActive DB 78h ;根据 paste 来判断是否激活 paste 菜单 CLearFlag DB 0 ;clearFlag 为 0 时表示不需要处理选择文本,如将反色显示还原pasteFl

7、ag DB 0 ;pasteFlag 为 0 时为不能粘贴,copyFlag DB 0 ;copyFlag 为 0 时为不能复制与剪切,pasteNum DB 0 ;粘贴缓冲区中字符个数.PasteBuffer DB 25 DUP (0)DB $;复制粘贴缓冲区INsertNum DB 1 ;insertNum 为插入字符的个数 save DB 0 ;path DB 30 DUP (0) ;文件名存放缓冲区DB $ buffer DB 2000 DUP(?) ;buffer 为数据缓冲区 bak DB 3850 DUP(0) ;视频缓冲区的备份row DB 2 ;保存行号, column DB

8、 1 ;保存列号.rowBak DB 2columnbak DB 1peak DB 0Dah, 78 DUP(0C4h) ,0BFh,13,10,$ ;顶端横线errormess1 DB can not creat the file,path is wrong! ,$ errormess2 DB can not write to the file! ,$ errormess3 DB the filename is too long! ,$ errormess4 DB can not open the file,filename is wrong,$ errormess5 DB can not

9、read the file! ,$ mess1 DB Please input save file name:,$ mess2 DB Please input open file name:,$mess3 DB *The file is not save! Save it now? (Y/N)*: ,$ mess4 DB please input the filename again ,$ mess5 DB your put is wrong!please input Y/N again,$ mess6 DB 0b3H, row:? column:?,$ mess7 DB Creat a ne

10、w file ,$ mess8 DB loads an exiting file from disk ,$ mess9 DB save current file ,$ mess10 DB save current file with new name ,$ mess11 DB Exits the editor ,$ mess12 DB F1:file menu F2:Play Music F3:help ,$mess21 DB Copy selected text to buffer ,$mess22 DB Deletes selected text and copys it ,$mess23

11、 DB Inserts buffer contents here ,$mess13 DB 0b3H,modified ,$mess14 DB 0b3h,NoModified,$mess15 DB editing. press Esc can escape ,$mess16 DB IBM PC Assemble Language Course Design,13,10,$mess17 DB MusicEdit 1.0 ,13,10,$mess18 DB Made by GuSui etc. ,13,10,$mess19 DB Dec,30,2004 ,13,10,$mess20 DB Press

12、 any keys to return,$musicname DB d:music0,0RF DB 13,10,$ DW 2 DUP(330,349,392)DW 2 DUP(392,440,392,349,330,262)DW 2 DUP(294,196,262),0time DW 8 DUP(4)DW 2 DUP(4,4,8)DW 2 DUP(2,2,2,2,4,4)DW 2 DUP(4,4,8) DW 523,494,440,392,349,330,294,262,0time1 DW 16 DUP(25) ;文件相关数据定义 handler DW 0filename DB e:/tige

13、r.vol,0 CHartemp DB 0 Buffertemp DB 4 DUP(0)Bufferflag DW 0times DW 1bufferIndex DW 0 timeBuffer DW 100 DUP(0) ;菜单数据定义 str_menu DB File(F1) Play(F2) Edit(F3) Help(F10),13,10,$ file_0 DB 0dah , 11 DUP(0C4H),0BFH ,13,10,$ file_1 DB 0B3H, New ,0B3H,13,10,$file_2 DB 0B3H, Open ,0B3H,13,10,$file_3 DB 0B3

14、H, Save ,0B3H,13,10,$file_4 DB 0B3H, Save as ,0B3H,13,10,$file_5 DB 0B3H, Exit ,0B3H,13,10,$ file_6 DB 0c0H, 11 DUP(0c4h),0d9H,13,10,$ play_0 DB 0dah , 10 DUP(0C4H),0BFH ,13,10,$ play_1 DB 0B3H, tiger ,0B3H,13,10,$play_2 DB 0B3H, music2 ,0B3H,13,10,$play_3 DB 0B3H, scale ,0B3H,13,10,$play_4 DB 0B3H,

15、 gun ,0B3H,13,10,$ play_5 DB 0c0H, 10 DUP(0c4h),0d9H,13,10,$ edit_0 DB 0dah , 10 DUP(0C4H),0BFH ,13,10,$ edit_1 DB 0B3H, Copy ,0B3H,13,10,$edit_2 DB 0B3H, cut ,0B3H,13,10,$edit_3 DB 0B3H, Paste ,0B3H,13,10,$ edit_4 DB 0c0H, 10 DUP(0c4h),0d9H,13,10,$ error0 DB Open File failed,13,10,$ error1 DB the f

16、ile have illegal character, 13,10,$ error2 DB the file have illegal character2, 13,10,$ data_seg ENDS;*代码段*8 code_seg SEGMENTASSUME CS:code_seg,DS:data_seg;*主过程开始* start:MOV AX,data_segMOVDS,AX CALL welcomeINit: CALL INitwin GEtchar ;读键盘 CMP AH,3bh ;F1 JZ showFileCMP AH,3ch ;F2JZ showPlayCMP AH,3dhJ

17、Z showECMP AH,3Eh ;F3 JZ showhCMP AH,01hJZ exitfJMP INit showFile: CALL showmenuFJMP INitshowPlay: CALL showMenuPJMP INitshowE: CALL showMenuE JMP INit showh: CALL showmenuhJMP INit exitf: MOV AH, 4chINT 21h ;主执行代码结束,下面都是要调用的函数定义. ;*;*欢迎模块* welcome PROC saveErecover RET welcome ENDP;-;*初始化模块*;功能:初始化

18、屏幕,显示菜单,提示信息,设置工作模式为 3 号字符模式;* INitwin PROC saveE MOV AH,01hMOV CH,03hINT 10h ;设置为字符模式 03 win 0,0,24,79,70h ;清屏win 1,0,23,79,07hwin 2,1,23,78,27H poscur 0,0show str_menu poscur 1,0show peak ;显示上面的横线;两个循环是画左右两条线的.MOV CL,23LOOPf:poscur CL,0putchar CHar1DEC CLCMP CL,1JNZ LOOPf LOOPf2:INC CLposcur CL,79

19、putchar CHar1 CMP CL,23JNZ LOOPf2 poscur 2,1posgetsCALL showRCposcur 24,1show mess12poscur 2,1 recover RET INitwin ENDP;*;*;*文件菜单模块*;功能:当在主过程或编辑状态检测到 F1 而被激活的.根据用户的选择来; 执行相应的菜单命令 ;入口参数有 musicInt:文件数量,以此来判断是激活 save,save as 菜单;先保存视频缓冲区的内容 ,再获取键盘输入,按照输入跳到不同的分支,;每个分支都调用相应的函数来处理. ;to*为当前选中项*的处理分支 ;to*菜单不

20、选中的颜色(白底黑字)win 9,4,9,16,07h ;菜单的阴影win 3,16,9,16,07h ;菜单的阴影 ;显示各个菜单,并设置第一个菜单为默认项, poscur 2,3 show file_0 poscur 3,3 show file_1poscur 4,3 show file_2poscur 5,3 show file_3poscur 6,3 show file_4poscur 7,3 show file_5 poscur 8,3show file_6 ;to*为当前选中项*的处理分支 tonew: win 7,4,7,14,79h ; poscur 7,3 show file

21、_5 win 4,4,4,14,79h poscur 4,3 show file_2 win 3,4,3,14,67h poscur 3,3show file_1 showM mess7 GEtchar CMP AH,50h ;若按下键下方向键JZ toOpen CMP AH,48H JZ toexit1 CMP AH,1ch ;若按了 Enter 键 JZ NEwfile1 JMP exitfile ;其他就返回 toexit1: JMP toexit NEwfile1: JMP NEwfile toOpen: win 3,4,3,14,79hposcur 3,3 show file_1wi

22、n 5,4,5,14,saveActive poscur 5,3 show file_3 win 4,4,4,14,67h poscur 4,3 show file_2 showM mess8 GEtcharCMP AH,50hJZ toSave CMP AH,48HJZ tonew1 JMP tonew3 tonew1: JMP tonew tonew3:CMP AH,1ch JZ openfile1JMP exitfile openfile1: JMP openfile toSave: win 4,4,4,14,79hposcur 4,3 show file_2 win 6,4,6,14,

23、saveActive poscur 6,3 show file_4 win 5,4,5,14,67h poscur 5,3 show file_3 showM mess9GEtcharCMP AH,50hJZ toSaveas CMP AH,48H JZ toOpen1 JMP toopen3toopen1: JMP toopen toopen3: CMP AH,1ch JZ savefile1JMP exitfile savefile1: JMP savefile toSaveas: win 5,4,5,14,saveActiveposcur 5,3 show file_3 win 7,4,

24、7,14,79h poscur 7,3 show file_5 win 6,4,6,14,67h poscur 6,3 show file_4 showM mess10GEtcharCMP AH,50hJZ toExit CMP AH,48hJZ tosave1 JMP tosave3tosave1: JMP tosave tosave3: CMP AH,1ch JZ saveasfile1JMP exitfile saveasfile1: JMP saveasfile tosaveas1: JMP tosaveas toExit: win 6,4,6,14,saveActiveposcur

25、6,3 show file_4 win 3,4,3,14,79h poscur 3,3show file_1 win 7,4,7,14,67h poscur 7,3 show file_5 showM mess11 GEtchar CMP AH,50hJZ tonew2 JMP tonew4tonew2: JMP tonew tonew4: CMP AH,48hJZ tosaveas3 CMP AH,1ch JZ EXITMusicJMP exitfile tosaveas3: JMP tosaveas1 ;*处理不同的分支所调用的不同的函数.*/ NEwfile:CALL filenew J

26、MP exitfile ;播放完毕跳到初始位置 openfile: CALL fileopenJMP exitfilesavefile: CALL filesaveJMP exitfile saveasfile: CALL filesaveasJMP exitfile EXITMusic : CMP modifyFlag,0JNZ exitfile20 CALL IFsave JMPexitMusic exitfile20: MOV AX,4C00hINT 21h exitfile: CALL menuHide CALL BackDisplayrecover poscur row,column

27、 RET showmenuF ENDP ;* ;显示文件菜单;先保存视频缓冲区的内容 ,再获取键盘输入,按照输入跳到不同的分支,;每个分支都调用相应的函数来处理. ;to*为当前选中项*的处理分支 ;to*菜单不选中的颜色(白底黑字)win 8,17,8,28,07h ;菜单的阴影win 2,28,8,28,07h ;菜单的阴影poscur 2,16 show play_0 poscur 3,16 show play_1poscur 4,16 show play_2poscur 5,16 show play_3poscur 6,16 show play_4 poscur 7,16 show p

28、lay_5 tomusic1: win 4,17,4,26,79h poscur 4,16 show play_2 win 6,17,6,26,79h poscur 6,16 show play_4 win 3,17,3,26,67h poscur 3,16show play_1 GEtchar CMP AH,50h ;若按下键下方向键JZ tomusic2 CMP AH,48hJZ togun1 CMP AH,1ch ;若按了 Enter 键 JZ pmusic11 JMP pexit togun1: JMP togun tomusic11: JMP tomusic1pmusic11: JM

29、P pmusic1 tomusic2: win 3,17,3,26,79hposcur 3,16 show play_1win 5,17,5,26,79h poscur 5,16 show play_3 win 4,17,4,26,67h poscur 4,16 show play_2 GEtcharCMP AH,50hJZ toscale CMP AH,48hJZ tomusic11 CMP AH,1ch JZ pmusic21JMP pexit tomusic21: JMP tomusic2 pmusic21: JMP pmusic2 toscale: win 4,17,4,26,79hp

30、oscur 4,16 show play_2win 6,17,6,26,79h poscur 6,16 show play_4 win 5,17,5,26,67h poscur 5,16 show play_3 GEtcharCMP AH,50hJZ togun CMP AH,48hJZ tomusic21 CMP AH,1ch JZ pscale1JMP pexit pscale1: JMP pscale tomusic12: JMP tomusic1 toscale1: JMP toscale togun: win 5,17,5,26,79hposcur 5,16 show play_3w

31、in 3,17,3,26,79h poscur 3,16show play_1 win 6,17,6,26,67h poscur 6,16 show play_4 GEtcharCMP AH,50hJZ tomusic12 CMP AH,48hJZ toscale1 CMP AH,1ch JZ pgunJMP pexit ;*处理不同的分支所调用的不同的函数.*/ pmusic1: CALL music1playJMP pexitpmusic2: CALL music2playJMP pexitpscale: CALL scaleplayJMP pexitpgun: CALL gunplayJ

32、MP pexitpexit: CALL menuHide CALL BackDisplay poscur row,columnrecoverRET showMenuP ENDP showMenuE PROC saveECALL savedisplayCMP copyFlag,0JZ NOTactiveCMOV copyActive,79hJMP activeOKCnotactiveC: MOV CopyActive,78h activeOKC:CMP PasteFlag,0JZ NOTactivePMOV PasteActive,79hJMP activeOKPnotactiveP: MOV

33、PasteActive,78h activeOKP: win 0,31,0,40,07hposcur 0,0 show str_menu win 2,31,6,42,78h ;菜单不选中的颜色(白底黑字)win 7,32,7,43,07h ;菜单的阴影win 2,43,7,43,07h ;菜单的阴影poscur 2,31 show Edit_0 poscur 3,31 show Edit_1poscur 4,31 show Edit_2poscur 5,31 show Edit_3poscur 6,31 show Edit_4 toCopy: win 4,32,4,41,copyActive

34、poscur 4,31 show Edit_2 win 5,32,5,41,pasteActive poscur 5,31 show Edit_3 win 3,32,3,41,67h poscur 3,31show Edit_1showM mess21 GEtchar CMP AH,50h ;若按下键下方向键JZ toCut CMP AH,48hJZ toPaste1 CMP AH,1ch ;若按了 Enter 键 JZ pCopy1 JMP Editexit toPaste1: JMP toPaste pCopy1: JMP pCopy toCut: win 3,32,3,41,copyAc

35、tiveposcur 3,31 show Edit_1win 5,32,5,41,pasteActive poscur 5,31 show Edit_3 win 4,32,4,41,67h poscur 4,31 show Edit_2 showM mess22 GEtcharCMP AH,50hJZ toPaste CMP AH,48hJZ toCopy1 CMP AH,1ch JZ PCut1JMP EditExit toCopy1: JMP toCopy PCut1: JMP PCut toPaste: win 4,32,4,41,copyActiveposcur 4,31 show E

36、dit_2win 3,32,3,41,copyActive poscur 3,31 show Edit_1 win 5,32,5,41,67h poscur 5,31 show Edit_3 showM mess23 GEtcharCMP AH,50hJZ toCopy2 CMP AH,48hJZ toCut1 CMP AH,1ch JZ pPaste1JMP EditExit toCut1: JMP toCut pPaste1: JMP pPaste toCopy2: JMP toCopy ;*处理不同的分支所调用的不同的函数.*/ pCopy: CALL CopyEditJMP EditExitPCut: CALL CutEditJMP EditExitpPaste: CALL PasteEditJMP EditExitEditExit: CALL menuHide

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 大学课件

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报