您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 机械/模具设计 > 东华大学微机课程设计
图形的移动旋转可以分几步进行:(1)先在屏幕上显示某个图形(自定义图形);(2)延时适当时间(3)清除这个图形;(4)改变图形显示的行列坐标及倾角(5)返回第(1)步,重复上述过程。按下回车结束。可自定义上、下、左、右移动键及顺时针、逆时针旋转键,还可以直接给出移动坐标、旋转角等。;includeMyMacro.h;*****************************宏文件包含*********************************;MyMacro.inc-macrodefinitionsdefinedbyforeasyinput/output;writtendate:2014/1/5;——————声明——————;以下创建一些程序中经常用到的功能的宏,其中一部分引用EMU8086环境内置宏文件emu8086.inc或;经本人修改后完成。为了省掉链接过程,这里将该部分不另存为一个文件,而是直接包含在此。;*********************输出字符串******************;thismacroprintsastringthatisgivenasaparameter,example:;PRINT'helloworld!';newlineisNOTadded.PRINTMACROsdatLOCALnext_char,s_dcl,printed,skip_dclPUSHAX;storeregisters...PUSHSI;PUSHBXJMPskip_dcl;skipdeclaration.s_dclDBsdat,0skip_dcl:LEASI,s_dclMOVBX,3next_char:MOVAL,CS:[SI]CMPAL,0JZprintedINCSIMOVAH,0Eh;teletypefunction.INT10hJMPnext_charprinted:POPBXPOPSI;re-storeregisters...POPAX;ENDM;************************************************;*****************设置光标位置********************;setscurrentcursor;position:GOTOXYMACROcol,rowPUSHAXPUSHBXPUSHDXMOVAH,02hMOVDH,rowMOVDL,colMOVBH,0INT10hPOPDXPOPBXPOPAXENDM;************************************************;******************单字符的输出*******************;thismacroprintsacharinALandadvances;thecurrentcursorposition:PUTCMACROcharPUSHAXPUSHBXMOVBX,01MOVAL,charMOVAH,0EhINT10hPOPBXPOPAXENDM;************************************************;*********************清屏函数******************;thismacrodefinesproceduretoclearthescreen,;(donebyscrollingentirescreenwindow),;andsetcursorpositiontotopofit:DEFINE_CLEAR_SCREENMACROLOCALskip_proc_clear_screen;protectfromwrongdefinitionlocation:JMPskip_proc_clear_screenCLEAR_SCREENPROCNEARPUSHAX;storeregisters...PUSHDS;PUSHBX;PUSHCX;PUSHDI;MOVAX,40hMOVDS,AX;forgettingscreenparameters.MOVAH,06h;scrollupfunctionid.MOVAL,0;scrollalllines!MOVBH,10H;attributefornewlines.MOVCH,0;upperrow.MOVCL,0;uppercol.MOVDI,84h;rowsonscreen-1,MOVDH,[DI];lowerrow(byte).MOVDI,4Ah;columnsonscreen,MOVDL,[DI]DECDL;lowercol.INT10h;setcursorpositiontotop;ofthescreen:MOVBH,0;currentpage.MOVDL,0;col.MOVDH,0;row.MOVAH,02INT10hPOPDI;re-storeregisters...POPCX;POPBX;POPDS;POPAX;RETCLEAR_SCREENENDPskip_proc_clear_screen:DEFINE_CLEAR_SCREENENDM;*************************************************************************;*************************************************************************datasegmentflagdw0;临时标志位tempchardb0,0,0tendb10ten1dw10bufferdb5,?,5dup(0);用于AH=0AH,INT21H功能的缓冲区,存放输入数据x1dw?y1dw?x2dw?y2dw?diffxdw?diffydw?diffx2dw?diffy2dw?incxdw?incydw?;用于计算旋转角度的三角函数表cosdxdw100,97,87,71,49,24,0,-24,-49,-71,-87,-97,-100,-97,-87,-71,-49,-24,0,24,49,71,87,97sindxdw0,-24,-49,-71,-87,-97,-100,-97,-87,-71,-49,-24,0,24,49,71,87,97,100,97,87,71,49,24dataendsstacksegmentdw128dup(0);堆栈,主要用于保护现场和函数参数传递stackendscodessegmentassumecs:codes,ds:data,ss:stack;***************正式程序段**********************start:DEFINE_CLEAR_SCREENmovax,datamovds,ax;数据段和附加段同段moves,axmoval,12h;设置图形模式640*480*16Smovah,0int10hmovah,0bh;设置背景色movbh,0movbl,7chint10hGOTOXY38,0;设置光标位置PUTC02PUTC02PUTC02GOTOXY8,1PRINT'|-_-------------------------WELCOME-----------------------------_-|'GOTOXY8,2PRINT'|Moveorrotatethefigureasthefollowingtips|'GOTOXY8,3PRINT'|Up(W)|Rotate|'GOTOXY8,4PRINT'|Left(S)Right(D)|Counterclockwise(J)Clockwise(K)|'GOTOXY8,5PRINT'|Down(S)||'GOTOXY8,6PRINT'|||'GOTOXY8,7PRINT'|Youcanenterthesettingmodewhenyouinput'i',thenyou|'GOTOXY8,8PRINT'|cansettheparameterseachtimewitha'enter'keyended.|'GOTOXY8,9PRINT'||'GOTOXY8,10PRINT'|-_--------ALLRIGHTSRESERVED----------_-|'GOTOXY2,11PRINT'PRESSANYKEYTOSHOWTHEFIGURE...(YOUCANEXITANYTIMEWHENYOUINPUTENTER.)'GOTOXY5,5movsi,200movdi,200movah,8int21hxorbx,bxjmppress_wget_key:movah,8;识别按键,进入对应的处理过程int21hcmpal,'w'jepress_wcmpal,'s'jepress_scmpal,'a'jepress_acmpal,'d'jepress_dcmpal,'j'jepress_jcmpal,'k'jepress_kcmpal,27cmpal,'i'jepress_icmpal,0dhjequit_jmpget_key;jepress_escquit_:;按回车键退出系统时设置提示符确认,防止误操作退出系统GOTOXY4,8PRINT'Doyouwanttoexit?'GOTOXY4,9PRINT'Inputytoexit,andinputntocancel...'chooseexit:movah,8int21hcmpal,'y';按y确认退出,按n取消退出,过滤其它输入jeexit_systemcmpal,'n'jecancel_exitjmpchooseexitcancel_exit:callshow_figurejmpget_keyexit_system:movax,4c00h;程序返回操作系统int21h;*************上下左右平移和旋转操作**************press_w:decdicalljudge_range;移动图形之前,先判断是否移出界movax,flagcmpax,1jnzgo_wcallshow_figurejmpget_keygo_w:incdijmpget_keypress_s:incdicalljudge_rangemovax,flagcmpax,1jnzgo_scallshow_figurejmpget_keygo_s:decdijmpget_keypress_a:decsicalljudge_rangemovax,flagcmpax,1jnzgo_acallshow_figurejmpget_keygo_a:incsijmpget_keypress_d:incsicalljudge_rangemovax,flagcmpax,1jnzgo_dcallshow_figurejmpget_keygo_d:decsijmpget_keypress_j:cmpbx,44jnarotatebackmovbx,-2rotateback:incbx;BX自增2,寻址三角函数表incbxcalljudge_rangemovax,flagcmpax,1jnzgo_jcallshow_figurejmpget_keygo_j:decbxdecbxjmpget_keypress_k:cmpbx,2jnlrotateback1movbx,48rotateback1:decbxdecbxcalljudge_rangemovax,flagcmpax,1jnzgo_kcallshow_figurejmpget_keygo_k:incbxincbxjmpget_key;****************************************************;*******************交互输入参数值*******************press_i:pushbxpushdipushsiGOTOXY60,
本文标题:东华大学微机课程设计
链接地址:https://www.777doc.com/doc-5969883 .html