资源描述:
《微机原理编程题集合》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.微机原理编程题1.分支程序设计①.编写一段程序,已知BUF1单元中有一带符号字节数据X,BUF2中有一带符号字节数据Y,根据以下函数关系编写程序求Z的值,结果存入RESULT单元。Z=
2、X-Y
3、;DATASEGMENTBUF1DB05HBUF2DB02HRESULTDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,BUF1MOVBL,BUF2SUBAL,BLJNCGREATNEGALGREAT:MOVRESULT,ALEXIT:MOVAH,4CHINT2
4、1HCODEENDSENDSTART②.编写一段程序,已知BUF单元中有一无符号字节数据X,假设为8,根据以下函数关系编写程序求Y的值,结果存入RESULT单元。Z=5XX<10,X-5X>=10;DATASEGMENTBUFDB8RESULTDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,BUFCMPAL,10JAEGREMOVBL,AL..ADDAL,ALADDAL,ALADDAL,BLJMPDONEGRE:SUBAL,5DONE:MOVRESULT
5、,ALMOVAH,4CHINT21HCODEENDSENDSTART③.在内存单元BUF中存放一个带符号字节数据X,假定为-2,试根据以下函数关系编写程序求Y的值,结果存入RESULT单元。Y=1X>0,0X=0,-1X<0;DATASEGMENTBUFDB-2RESULTDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,BUFCMPAL,0JGEL1MOVAL,-1JMPL3L1:JZL2MOVAL,1JMPL3L2:MOVAL,0L3:MOVRESUL
6、T,ALMOVAH,4CHINT21HCODEENDSENDSTART1.N个数中求最大值、最小值.假定N=10,已知原始数据存放在BUF开始的内存单元中,将结果存入MAX,MIN内存单元中。DATASEGMENTBUFDB3,5,7,8,5,3,9,7,13,1COUNTEQU$-BUF..MAXDB?MINDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVCX,COUNT-1MOVAL,BUFMOVMAX,ALMOVMIN,ALLEASI,BUFAGAIN:
7、MOVAL,[SI+1]CMPAL,MINJGES1MOVMIN,ALS1:CMPAL,MAXJLES2MOVMAX,ALS2:INCSILOOPAGAINMOVAH,4CHINT21HCODEENDSENDSTART1.编写程序求1+2+3+……+N<100时最大的N值,将N值送NUM单元中,同时将1+2+3+……+N的和送到SUM单元中。DATASEGMENTNUMDB?SUMDB?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,0MOVBL,0AGAIN
8、:INCBLADDAL,BL..CMPAL,100JBAGAINSUBAL,BLDECBLMOVNUM,BLMOVSUM,ALMOVAH,4CHINT21HCODEENDSENDSTART1.统计字符,正数,负数,零的个数。①.若自STRING单元开始存放一个字符串,以'$'结尾,试编写程序,统计字符串的长度,并将结果存入COUNT单元。DATASEGMENTSTRINGDB'abcdefg$'COUNTDW?DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXLEASI,S
9、TRINGMOVCX,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:DATAS
10、TART:MOVAX,DATAMOVDS,AXLEASI,BUFMOVCX,10AGAIN:MOVAL,[B