您好,欢迎访问三七文档
微机原理编程题1.分支程序设计①.编写一段程序,已知BUF1单元中有一带符号字节数据X,BUF2中有一带符号字节数据Y,根据以下函数关系编写程序求Z的值,结果存入RESULT单元。Z=|X-Y|;DATASEGMENTBUF1DB05HBUF2DB02HRESULTDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,BUF1MOVBL,BUF2SUBAL,BLJNCGREATNEGALGREAT:MOVRESULT,ALEXIT:MOVAH,4CHINT21HCODEENDSENDSTART②.编写一段程序,已知BUF单元中有一无符号字节数据X,假设为8,根据以下函数关系编写程序求Y的值,结果存入RESULT单元。Z=5XX10,X-5X=10;DATASEGMENTBUFDB8RESULTDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,BUFCMPAL,10JAEGREMOVBL,ALADDAL,ALADDAL,ALADDAL,BLJMPDONEGRE:SUBAL,5DONE:MOVRESULT,ALMOVAH,4CHINT21HCODEENDSENDSTART③.在内存单元BUF中存放一个带符号字节数据X,假定为-2,试根据以下函数关系编写程序求Y的值,结果存入RESULT单元。Y=1X0,0X=0,-1X0;DATASEGMENTBUFDB-2RESULTDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,BUFCMPAL,0JGEL1MOVAL,-1JMPL3L1:JZL2MOVAL,1JMPL3L2:MOVAL,0L3:MOVRESULT,ALMOVAH,4CHINT21HCODEENDSENDSTART2.N个数中求最大值、最小值.假定N=10,已知原始数据存放在BUF开始的内存单元中,将结果存入MAX,MIN内存单元中。DATASEGMENTBUFDB3,5,7,8,5,3,9,7,13,1COUNTEQU$-BUFMAXDB?MINDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVCX,COUNT-1MOVAL,BUFMOVMAX,ALMOVMIN,ALLEASI,BUFAGAIN:MOVAL,[SI+1]CMPAL,MINJGES1MOVMIN,ALS1:CMPAL,MAXJLES2MOVMAX,ALS2:INCSILOOPAGAINMOVAH,4CHINT21HCODEENDSENDSTART3.编写程序求1+2+3+……+N100时最大的N值,将N值送NUM单元中,同时将1+2+3+……+N的和送到SUM单元中。DATASEGMENTNUMDB?SUMDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,0MOVBL,0AGAIN:INCBLADDAL,BLCMPAL,100JBAGAINSUBAL,BLDECBLMOVNUM,BLMOVSUM,ALMOVAH,4CHINT21HCODEENDSENDSTART4.统计字符,正数,负数,零的个数。①.若自STRING单元开始存放一个字符串,以'$'结尾,试编写程序,统计字符串的长度,并将结果存入COUNT单元。DATASEGMENTSTRINGDB'abcdefg$'COUNTDW?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEASI,STRINGMOVCX,0NEXT:MOVAL,[SI]CMPAL,'$'JZDONEINCCXINCSIJMPNEXTDONE:MOVCOUNT,CXMOVAH,4CHINT21HCODEENDSENDSTART②.自BUF单元开始存放10个带符号字节数据,将其中的正数、负数和零选出来,并统计其个数,分别存入PLUS、MINUS和ZERO单元中。DATASEGMENTBUFDB5,-2,0,-1,4,0,-4,8,0,-7PLUSDB?MINUSDB?ZERODB?DATAENDSCODESEGMENTASSUMECS:DATA,DS:DATASTART:MOVAX,DATAMOVDS,AXLEASI,BUFMOVCX,10AGAIN:MOVAL,[BX]INCBXANDAL,ALJSM1JZM2INCPLUSJMPNEXTM1:INCMINUSJMPNEXTM2:INCZEROJMPNEXTNEXT:LOOPAGAINMOVAH,4CHINT21HCODEENDSENDSTART5.求压缩BCD码的和。已知从BUF1和BUF2单元开始,存放两个各为10个字节的BCD数,求这两个数的和,并将结果存入BUF3单元中。DATASEGMENTBUF1DB01H,01H,01H,01H,01H,01H,01H,01H,01H,01HBUF2DB03H,03H,03H,03H,03H,03H,03H,03H,03H,03HBUF3DB11DUP(?)DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVCX,10LEASI,BUF1LEADI,BUF2LEABX,BUF3AGAIN:MOVAL,[SI]ADCAL,[DI]DAAMOV[BX],ALINCSIINCDIINCBXLOOPAGAINADCAH,0MOV[BX],AHMOVAH,4CHINT21HCODEENDSENDSTART6.8255编程题:(课后实验)8255工作于方式0,此时PA、PB、PC均为可独立输入/输出的并行口。8255的各寄存器对应的口地址为:PA口:200H,PB口:202H,PC口:204H,控制口:206H。要求8255工作于方式0,PA口设置为输入,PC口设置为输出。DATASEGMENTC8255EQU206HP8255AEQU200HP8255CEQU204HDATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVDX,C8255;设置为A口输入,C口输出MOVAL,90HOUTDX,ALBG:MOVDX,P8255A;将A口状态从C口输出INAL,DXMOVDX,P8255COUTDX,ALJMPBGCODEENDSENDSTART
本文标题:微机原理编程题
链接地址:https://www.777doc.com/doc-7037489 .html