西电微机原理上机作业完整版

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

上机作业(一)指令SRC寻址方式SRC的地址AX推算值AX实际值MOVAX,CX寄存器寻址00050005MOVAX,500H立即寻址05000500MOVAX,TABLE直接寻址1541:0004A5A4A5A4MOVAX,ES:[BX]寄存器间接寻址1542:0004C5C4C5C4MOVAX,[BX+05H]寄存器相对寻址1541:0009AAA9AAA9MOVAX,SS:[BX]+03H寄存器相对寻址153F:0007B8B7B8B7MOVAX,TABLE[BX]寄存器相对寻址1541:0008A9A8A9A8MOVAX,07H[BX]寄存器相对寻址1541:000BACABACABMOVAX,[BP]寄存器间接寻址153F:0003B4B3B4B3MOVAX,TABLE[BP]寄存器相对寻址1541:0007A8A7A8A7MOVAX,08H[BP]寄存器相对寻址153F:000BBCBBBCBBMOVAX,[BP+06H]寄存器相对寻址153F:0009BAB9BAB9MOVAX,DS:[BP+03H]寄存器相对寻址1541:0006A7A6A7A6MOVAX,[BP]+05H寄存器相对寻址153F:0008B9B8B9B8MOVAX,ES:[SI+03H]寄存器相对寻址1542:0005C6C5C6C5MOVAX,[DI+06H]寄存器相对寻址1541:0007A8A7A8A7MOVAX,[DI]+05H寄存器相对寻址1541:0006A7A6A7A6MOVAX,TABLE[SI]寄存器相对寻址1541:0006A7A6A7A6MOVAX,[SI]寄存器间接寻址1541:0002A3A2A3A2MOVAX,TABLE[DI]寄存器相对寻址1541:0005A6A5A6A5MOVAX,[SI]+05H寄存器相对寻址1541:0007A8A7A8A7MOVAX,[BX][DI+01H]基址变址且相对寻址1541:0006A7A6A7A6MOVAX,[BX][SI]+03H基址变址且相对寻址1541:0009AAA9AAA9MOVAX,TABLE[BX][SI]基址变址且相对寻址1541:000AABAAABAAMOVAX,ES:[BX][DI]基址变址寻址1542:0005C6C5C6C5MOVAX,[BP][DI+02H]基址变址且相对寻址153F:0006B7B6B7B6MOVAX,TABLE[BP][DI]基址变址且相对寻址1541:0008A9A8A9A8MOVAX,ES:[BP][SI]基址变址寻址1542:0005C6C5C6C5MOVAX,[BP][SI+05H]基址变址且相对寻址153F:000ABBBABBBAMOVAX,03H[BP][DI]基址变址且相对寻址153F:0007B8B7B8B7MOVAX,[BP][SI]基址变址寻址153F:0005B6B5B6B5MOVAX,[BP+02H][DI+03H]基址变址且相对寻址153F:0009BAB9BAB9MOVAX,TABLE[BP+02H][DI+03H]基址变址且相对寻址1541:000DAEADAEAD1.编写求十进制数12678532和21736543之和的程序,并将和以十进制数的形式送屏幕显示。STACKSEGMENTSTACK'STACK'DW100HDUP(?)TOPLABELWORDSTACKENDS;堆栈段DATASEGMENTADD1DD12678532HADD2DD21736543HSUMDD?DATAENDS;数据段CODESEGMENT;代码段ASSUMECS:CODE,DS:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVAX,STACKMOVSS,AXLEASP,TOPLEASI,ADD1LEADI,ADD2MOVAL,[SI]ADDAL,[DI]DAAMOVBYTEPTRSUM,ALMOVAL,[SI+1]ADCAL,[DI+1]DAAMOVBYTEPTRSUM+1,ALMOVAL,[SI+2]ADCAL,[DI+2]DAAMOVBYTEPTRSUM+2,ALMOVAL,[SI+3]ADCAL,[DI+3]DAAMOVBYTEPTRSUM+3,ALMOVAX,WORDPTRSUM+2CALLDISPAXMOVAX,WORDPTRSUMCALLDISPAXMOVAH,4CHINT21HDISPALPROCNEARPUSHAXPUSHCXPUSHDXPUSHAXMOVCL,4SHRAL,CLCALLCHANGMOVAH,02MOVDL,ALINT21HPOPAXANDAL,0FHCALLCHANGMOVAH,02MOVDL,ALINT21HPOPDXPOPCXPOPAXRETDISPALENDPCHANGPROCNEARCMPAL,10JNGECHANG1ADDAL,7CHANG1:ADDAL,30HRETCHANGENDPDISPAXPROCNEARXCHGAL,AHCALLDISPALXCHGAH,ALCALLDISPALRETDISPAXENDPCODEENDSENDSTART2.有一个首地址为A的N字数组,请编程序使该数组中的数按从大到小的次序排列。STACKSEGMENTSTACKDB256DUP(?)STACKENDSDATASEGMENTDATA1DW7800H,6832H,0000H,87H,1275H,0EC34HSTRING1DB'inputnumber:',0DH,0AH,'$'STRING2DB'Thenumbersfromlargetosmallis:',0DH,0AH,'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVES,AXMOVAX,STACKMOVSS,AXLEADX,STRING1MOVAH,09HINT21HMOVCX,6LEASI,DATA1L1:MOVAX,[SI]ADDSI,2CALLDISPAXCALLDISPCRLOOPL1MOVCX,5LEASI,DATA1ADDSI,10LP1:PUSHCXPUSHSILP2:MOVAX,[SI]CMPAX,[SI-2]JBENOXCHGXCHGAX,[SI-2]MOV[SI],AXNOXCHG:DECSIDECSILOOPLP2POPSIPOPCXLOOPLP1LEADX,STRING2MOVAH,09HINT21HMOVCX,6LEASI,DATA1L2:MOVAX,[SI]ADDSI,2CALLDISPAXCALLDISPCRLOOPL2MOVAH,4CHINT21HDISPALPROCPUSHAXPUSHCXPUSHDXPUSHAXMOVCL,4SHRAL,CLCALLCHANGMOVAH,02HMOVDL,ALINT21HPOPAXANDAX,0FHCALLCHANGMOVAH,02HMOVDL,ALINT21HPOPDXPOPCXPOPAXRETDISPALENDPCHANGPROCCMPAL,10JNGECHANG1ADDAL,7CHANG1:ADDAL,30HRETCHANGENDPDISPAXPROCXCHGAL,AHCALLDISPALXCHGAH,ALCALLDISPALRETDISPAXENDPDISPCRPROCPUSHAXPUSHDXMOVAH,2MOVDL,0AHINT21HMOVAH,2MOVDL,0DHINT21HPOPDXPOPAXRETDISPCRENDPCODEENDSENDSTART3.编写如下程序,并在机器上调试成功。程序采用菜单式选择,可以接收用户从键盘输入的四个命令(1-4),各命令功能分别为:(1)按下“1”键,完成字符串小写字母变成大写字母。(2)按下“2”键,完成找最大值(3)按下“3”键,完成排序(4)按下“4”键,结束程序运行,返回系统提示符。DISPLMACROSTRPUSHDXPUSHAXLEADX,STRMOVAH,09HINT21HPOPAXPOPDXENDMISCONTINUEMACROLDISPS15,10,SMENUMOVAH,08HINT21HCMPAL,1BHJNELJMPMAINENDMCURSORMACROCURX,CURYPUSHAXPUSHBXPUSHDXMOVAH,02HMOVDH,CURXMOVDL,CURYMOVBH,0INT10HPOPDXPOPBXPOPAXENDMDISPSMACROX,Y,STRPUSHAXPUSHBXPUSHDXMOVAH,02HMOVBH,00HMOVDH,XMOVDL,YINT10HLEADX,STRMOVAH,09HINT21HPOPDXPOPBXPOPAXENDMSCROLLMACRON,ULR,ULC,LRR,LRC,ATTPUSHAXPUSHBXPUSHCXPUSHDXMOVAH,06HMOVAL,NMOVCH,ULRMOVCL,ULCMOVDH,LRRMOVDL,LRCMOVBH,ATTINT10HPOPDXPOPCXPOPBXPOPAXENDMPREPMACROTLEASI,INBUF+1LEADI,OUTBUFSCROLL21,2,0,22,79,0FHDISPS3,20,TDISPS6,2,CAPIONDISPS8,2,INCAPMOVAH,0AHINT21HMOVCH,0MOVCL,[SI]INCSIENDMSTACKSEGMENTSTACK'STACK'DB100HDUP(?)TOPLABELWORDSTACKENDSDATASEGMENTBASEDWMAIN,LTC,FMV,SORTS,EXITWELCMDB'Welcometothisprogram!$'MMENUCDB'Pleaseinputthenumber!$'MMENU1DB'1-LowercaseLettersToCapitalLetters$'MMENU2DB'2-FindTheMaximumfigure$'MMENU3DB'3-Sort$'MMENU4DB'4-Exit!$'SMENUDB'PressAnyKeyTorestart,PressESCToReturnToMainMenu!$'WROCAPDB'WRONG!Youhavepresskey!Pleaseinputanumberbetween1and4!$'CAPIONDB'PleaseInputYourStringsandEndWithEnterKey!$'INCAPDB'YourInputIs:$'INBUFDB100DB?DB100DUP(?)OUTCAPDB'MyOutputIs:$'OUTBUFDB100DUP(?)MAXCAPDB'ThecharofmaxASCIIis:.$'ERRINFDB'ERROR!Pleasechecktheformatyouinput!$'TDINVDB'Invalidtimedata!Inputagain!$'NODATCAPDB'Youhaveinputnothing!$'TIMEDB8DUP(':'),12DUP('')DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVES,AXMOVAX,STACKMOVSS,AXLEASP,TOPLEADX,INBUFCLCMAIN:SCROLL0,0,0,24,79,0SCROLL25,0,0,24,79,50HSCROLL21,2,0,22,79,0FHDISPS8,20,MMENUCDISPS10,20,MMENU1DISPS12,20,MMENU2DISPS14,20,MMENU3DISPS16,20,MMENU4ML:CURSOR19,1DHMOVAH,01HINT21HCMPAL,31H

1 / 17
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功