您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 电子设计/PCB > 微机原理实验讲义答案
微机原理与接口技术部分实验讲义答案1、从键盘输入两个一位十进制数,计算这两个数之和,并将其结果在屏幕上显示出来。答:DATASEGMENTINFOR1DB‘PleaseInputtheFirstData(10):$’INFOR2DBOAH,0DH,’PleaseInputtheSecondData(10):$’INFOR3DB0AH,0DH,’TheResultis:$’DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVDX,OFFSETINFOR1MOVAH,09HINT21HMOVAH,01HINT21HSUBAL,30HMOVBL,ALMOVDX,OFFSETINFOR2MOVAH,09HINT21HMOVAH,01HSUBAL,30HXORAH,AHADDAL,BLAAAPUSHAXMOVDX,OFFSETINFOR3MOVAH,09HINT21HPOPAXPUSHAXMOVDL,AHADDDL,30HMOVAH,02HINT21HPOPAXMOVDL,ALADDDL,30HMOVAH,02HINT21HMOVAH,4CHINT21HCODEENDSENDSTART2、从键盘输入一字符,判断该字母是小写字母、大写字母、数字或是其他字符。若输入为小写字母,则显示“YouInputaLowercaseLetter!”;若输入是大写字母,则显示“YouInputaUppercaseLetter!”。若输入为数字,则显示“youInputaDigit!”若输入为数字,则显示“YouInputotherLetter!”。DATASEGMENTINFOR1DB0AH,0DH,“PleasePressanyKeytoInputaLetter:$”INFOR2DB0AH,0DH,“YouInputaLowercaseLetter!$”INFOR3DB0AH,0DH,“YouInputaUppercaseLetter!$”INFOR4DB0AH,0DH,“YouInputaDigit!$”INFOR5DB0AH,0DH,“YouInputOtherLetter!$”DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVDX,OFFSETINFOR1MOVAH,09HINT21HMOVAH,01HINT21HCMPAL,’0’JBOTHERCMPAL,’9’JBEDIGITCMPAL,’A’JBOTHERCMPAL,’Z’JBEUPPERCMPAL,’a’JBOTHERCMPAL,’z’JBELOWERJMPPENDLOWER:MOVDX,OFFSETINFOR2MOVAH,09HINT21HJMPPENDUPPER:MOVDX,OFFSETINFOR3MOVAH,09HINT21HJMPPENDDIGIT:MOVDX,OFFSETINFOR4MOVAH,09HINT21HJMPPENDOTHER:MOVDX,OFFSETINFOR5MOVAH,09HINT21HPEND:MOVAH,4CHINT21HCODEENDSENDSTART3、在屏幕上显示如下信息:1、……………………………………Panda2、……………………………………Cat3、……………………………………Rabbit4、……………………………………Pig5、……………………………………EXIT(pleasechoose1,2,3,4or5)若输入1,则显示“ILikePande”后程序结束;若输入2,则显示“ILikeCat”后程序结束;若输入3,则显示“ILikeRabbit”后程序结束;若输入4,则显示“IDon‘tLikePig”后程序结束;若输入5,则程序直接结束;若输入其他字符,则显示“YouPressanErrorKey!”后程序结束。DATASEGMENTINFOR1DB0AH,0DH,“……………………………Panda$”INFOR2DB0AH,0DH,“……………………………Cat$”INFOR3DB0AH,0DH,“………………………………Rabbit$”INFOR4DB0AH,0DH,“……………………………………Pig$”INFOR5DB0AH,0DH,“YouPressanErrorKey!$”DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAH,01HINT21HCMPAL,’1’JZPANADACMPAL,’2’JZCATCMPAL,’3’JZRABBITCMPAL,’4’JZPIGCMPAL,’5’JZPENDMOVDX,OFFSETINFOR5MOVAH,09HINT21HJMPPENDPANADA:MOVDX,OFFSETINFOR1MOVAH,09HINT21HJMPPENDCAT:MOVDX,OFFSETINFOR3MOVAH,09HINT21HJMPPENDRABBIT:MOVDX,OFFSETINFOR4MOVAH,09HINT21HJMPPENDPIG:MOVDX,OFFSETINFOR5MOVAH,09HINT21HPEND:MOVAH,4CHINT21HCODEENDSENDSTART4、在屏幕上显示信息“AreYouReallyWanttoExit?”,然后从键盘输入一个字符。若输入“Y”或“y”,则显示“ThankYouforYourUsing!”后程序结束;若输入“N”或“n”,则显示“Let‘sContinue!”后程序结束;若输入其他字符,则显示“YouPressanErrorKey!”后程序结束。DATASEGMENTINFOR1DB0AH,0DH,“AreYouReallyWanttoExit?$”INFOR2DB0AH,0DH,ThankYouforYourUsing!$”INFOR3DB0AH,0DH,“Let‘sContinue!$”INFOR4DB0AH,0DH,“YouPressanErrorKey!$”DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVDX,OFFSETINFOR1MOVAH,09HINT21HMOVAH,01HINT21HCMPAL,’y’JZTK1CMPAL,’Y’JZTK1CMPAL,’N’JZLT1CMPAL,’n’JZLT1MOVDX,OFFSETINFOR4MOVAH,09HINT21HJMPPENDTK1:MOVDX,OFFSETINFOR2MOVAH,09HINT21HJMPPENDLT1:MOVDX,OFFSETINFOR3MOVAH,09HINT21HPEND:MOVAH,4CHINT21HCODEENDSENDSTART5、计算1+2+3+4…+n=?,其中n通过键盘输入的数字,累加和小于216。要求在屏幕上提供如下信息:Pleaseinputanumber(1~361);出现此信息后通过键盘输入一个1~511的无符号整;数,使累加和小于一个16位无符号二进制数所能表;示的范围。1+2+…n=sum;其中n为用户输入的数,sun为所求累加和。DATASEGMENTINF1DB“PleaseInputaNumber(0-65535):$”IBUFDB7,0,6DUP(?)OBUFDB6DUP(?)DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVDX,OFFSETINF1MOVAH,09HINT21HMOVDX,OFFSETIBUF;键入一个十进制数(512)MOVAH,OAHINT21HMOVCL,IBUF+1;十进制数的位数送CXMOVCH,0MOVSI,OFFSETIBUF+2;指向输入的第一个字符(最高位)MOVAX,0AGAIN:MOVDX,10MULDXANDBYTEPTR[SI],0FHADDAL,[SI]ADCAH,0INCSILOOPAGAINMOVCX,AXMOVAX,0MOVBX,1LOOP2:ADDAX,BXINCBXLOOPLOOP2MOVBX,OFFSETOBUF+5MOVBYTEPTR[BX],‘$’MOVCX,10LOOP1:MOVDX,0DIVCXADDDL,30HDECBXMOV[BX],DLORAX,AXJNZLOOP1MOVDX,BXMOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDSTART
本文标题:微机原理实验讲义答案
链接地址:https://www.777doc.com/doc-2435676 .html