华工微机实验报告

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

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

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

资源描述

微机系统与接口实验电子与信息学院电类联合班何俊实验二:将ASCII码表示的十进制数转换为二进制数1.将ASCII码表示的十进制数转换为二进制数。DATASEGMENTORG3500HNUM1DB5DUP(0)ORG3510HNUM2DD5DUP(0)DATAENDSSTACKSEGMENTSTACK'STACK'DB100DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVAX,OFFSETNUM1MOVSI,AXMOVAX,OFFSETNUM2MOVDI,AXMOVCX,5MOVAX,0MOVBH,0CHANGE:MOVBL,[SI]SUBBL,30HMOVDX,10MULDXADDAX,BXADDSI,1LOOPCHANGEEXIT:MOVWORDPTR[DI],AXMOVAH,4CHINT21HCODEENDSENDSTART2.将从键盘输入的五位十进制数的ASCII码已存在3500起始的内存单元中。把它转换成BCD码后,再按位分别存入350A起始的内存单元内。若输入的不是十进制的ASCII码,则显示FF.DATASEGMENTORG3500HNUM1DB5DUP(0);NUM1DB‘12345’ORG350AHNUM2DB5DUP(0)DATAENDSSTACKSEGMENTDB100DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVAX,OFFSETNUM1MOVSI,AXMOVAX,OFFSETNUM2MOVDI,AXMOVCX,5CHANGE:MOVAL,[SI]CMPAL,39HJAERRORCMPAL,30HJBERRORSUBAL,30HMOV[DI],ALADDSI,1ADDDI,1LOOPCHANGEJMPEXITERROR:MOVBX,0FFHMOV[DI],BXEXIT:MOVAH,4CHINT21HCODEENDSENDSTART3.将十六位二进制数转换为ASCII码表示的十进制数。十六进制数的值域为0~65535,最大可转换为五位十进制数。DATASEGMENTORG3500HNUM1DD0ORG3510HNUM2DB5DUP(0)DATAENDSSTACKSEGMENTDB100DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVAX,OFFSETNUM1MOVSI,AXMOVAX,OFFSETNUM2MOVDI,AXADDDI,5MOVCX,5MOVAX,WORDPTR[SI]MOVBX,10CHANGE:MOVDX,0DIVBXADDDL,30HMOV[DI],DLDECDILOOPCHANGEEXIT:MOVAH,4CHINT21HCODEENDSENDSTART4.十六进制数转换为ASCII码DATASEGMENTORG3500HNUM1DD0ORG3510HNUM2DB4DUP(0)DATAENDSSTACKSEGMENTDD100DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVAX,OFFSETNUM1MOVSI,AXMOVAX,OFFSETNUM2MOVDI,AXMOVBL,2MOVCX,4CHOICE:MOVAL,[SI]ANDAL,0FHCMPAL,9JBECHANGE_11JMPCHANGE_12CHANGE_11:ADDAL,30HJMPNEXT_1CHANGE_12:ADDAL,37HNEXT_1:MOV[DI],ALADDDI,1MOVAL,[SI]ANDAL,0F0HSHRAL,CLCMPAL,9JBECHANGE_21JMPCHANGE_22CHANGE_21:ADDAL,30HJMPNEXT_2CHANGE_22:ADDAL,37HNEXT_2:MOV[DI],ALADDDI,1ADDSI,1DECBXJNECHOICEEXIT:MOVAH,4CHINT21HCODEENDSENDSTART5.BCD码转换为二进制码DATASEGMENTORG3500HNUM1DB8DUP(0)ORG3510HNUM2DB4DUP(0)DATAENDSSTACKSEGMENTDB100DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVAX,OFFSETNUM1MOVSI,AXMOVAX,OFFSETNUM2MOVDI,AXMOVCX,4MOVBL,10CHANGE:MOVAL,[SI]MULBLADDSI,1ADDAL,[SI]ADDSI,1MOV[DI],ALADDDI,2LOOPCHANGEEXIT:MOVAH,4CHINT21HCODEENDSENDSTART实验三分支和循环程序设计实验1.设计一数据块间的搬移程序DATASEGMENTORG3500HMESSAGE1DB'HELLOKITTY'COUNTEQU11DATAENDSEXTRASEGMENTORG3510HMESSAGE2DB11DUP(0)EXTRAENDSSTACKSEGMENTDD100DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,ES:EXTRA,SS:STACKSTART:MOVAX,DATAMOVDS,AXMOVAX,OFFSETMESSAGE1MOVSI,AXMOVAX,OFFSETMESSAGE2MOVDI,AXMOVAX,DSMOVES,AXMOVCX,COUNTCLDCOMPARE:CMPSI,DIJBNEXT1JMPNEXT2NEXT1:STDADDSI,COUNT-1ADDDI,COUNT-1REPMOVSBJMPEXITNEXT2:REPMOVSBJMPEXITEXIT:MOVAH,4CHINT21HCODEENDSENDSTART2.编制程序使S=1+2*3+3*4+4*5+……N(N+1),直到N(N+1)项大于200为止。DATASEGMENTORG3500HRESULTDD0DATAENDSCODESEGMENTASSUMECS:CODESTART:MOVDX,1MOVBL,2SUM:MOVAL,BLINCBLMULBLADDDX,AXCMPAX,200JBSUMPRINT:MOVAX,OFFSETRESULTMOVDI,AXMOV[DI],DXEXIT:MOVAH,4CHINT21HCODEENDSENDSTART3.求某个数据区内负数的个数。DATASEGMENTORG3500HNUMDB6H,12H,88H,82H,90H,22H,33HDATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAX,OFFSETNUMMOVSI,AXMOVBL,0MOVCL,[SI]MOVCH,0INCSICHECK:MOVAL,[SI]CMPAL,10000000BJBENEXTINCBLNEXT:INCSILOOPCHECKPRINT:MOV[SI],BLEXIT:MOVAH,4CHINT21HCODEENDSENDSTART实验四子程序设计程序采用菜单式选择,可接收用户输入的命令(1~5),各命令如下:按1键完成字符串小写字母变大写字母用户输入一由英文大小写字母或数字0~9组成的字符串(以回车结束),程序逐个检查字符串中各字符,将原串中小写字母变成大写字母,其它字符不变,并在屏幕上显示。用户按任一键,重做,按ESC键,返回主菜单。按2键完成找最大值(二选一)1、接收用户输入的可显示字符串(以回车结束),程序将其中ASCII码值最大的字符显示出来。2、接收用户输入若干无符号8位数(以空格或逗号为分隔符,以回车结束),程序将其中最大的数显示出来。用户按任一键,重做,按ESC键,返回主菜单。按3键完成排序(二选一)1、接收用户输入的可显示字符串,以回车结束。程序按ASCII码值大小由大到小排序并输出显示。2、接收用户输入若干个有符号8位数(以空格逗号为分隔符,以回车结束)。程序将其中最大的数显示出来。用户按任一键,重做,按ESC键,返回主菜单。按4键显示时间首先提示用户对时,即用户输入时,分,秒(以空格或冒号分隔,以回车结束),然后,在屏幕上不断显示时间,格式为:××(时):××(分):××(秒),最好定点显示。用户按任一键,重新对时,按ESC键,返回主菜单。按5键,结束程序运行,返回系统提示符。DATASEGMENTORG0000H;BUFFERPOOL.BUFFDB100DB0DB100DUP(0)DATAENDSSTACKSEGMENTSTTDB100DUP(0)TOPEQULENGTHSTTSTACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACK;MAINPROCESSSTART:MAINPROCFARFIRST:MOVAX,DATAMOVDS,AXMOVSI,OFFSETBUFFMOVAX,STACKMOVSS,AXMOVSP,OFFSETTOPCHOICE:MOVAH,1INT21HCMPAL,'5'JEEXITCMPAL,'1'JEFUNCTION1CMPAL,'2'JEFUNCTION2CMPAL,'3'JEFUNCTION3CMPAL,'4'JEFUNCTION4CHANGE_LINE:MOVDL,0AHMOVAH,2INT21H;ERRORINPUT,CHOOSEAGAIN.JMPFIRSTFUNCTION1:MOVDL,0AHMOVAH,2INT21HCALLF1JMPCHANGE_LINEFUNCTION2:MOVDL,0AHMOVAH,2INT21HCALLF2JMPCHANGE_LINEFUNCTION3:MOVDL,0AHMOVAH,2INT21HCALLF3JMPCHANGE_LINEFUNCTION4:MOVDL,0AHMOVAH,2INT21HCALLF4JMPCHANGE_LINEEXIT:MOVAH,4CHINT21HRETMAINENDP;SUBPROCESS1F1PROCNEAR;GETSTRINGMOVSI,OFFSETBUFFMOVDX,SIMOVAH,0AHINT21HCALLCHANGE_LINE;GETTHESIZEOFSTRINGINCSIMOVCL,[SI]MOVCH,0INCSI;CHANGETHELETTERSANDPRINTCHANGE:MOVDL,[SI]CMPDL,'Z'JBENEXTSUBDL,20HNEXT:MOVAH,2INT21HINCSILOOPCHANGECALLCHANGE_LINE;RETURNRETF1ENDP;SUBPROCESS2F2PROCNEAR;GETSTRINGMOVDX,SIMOVAH,0AHINT21HCALLCHANGE_LINE;GETTHESIZEOFSTRINGINCSIMOVCL,[SI]MOVCH,0INCSI;GETTHEMAXCHARMOVAL,[SI]INCSICOMPARE:CMPAL,[SI]JANEXTMOVAL,[SI]NEXT:INCSILOOPCOMPAREPRINT:MOVDL,ALMOVAH,2INT21HCALLCHANGE_LINE;RETURNRETF2ENDP;SUBPROCESS3F3PROCNEAR;GETSTRINGMOVSI,OFFSETBUFFADDSI,2MOVDX,SIMOVAH

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

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

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

×
保存成功