資源描述:
《《單片機》讀程序題題庫答案.pdf》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、《單片機原理及應用》讀程序題題庫答案2、ORG0LJMPSTART;跳轉(zhuǎn)到(PC)=0030H處四、閱讀下列程序,注釋并填寫指令執(zhí)行后的結(jié)果(每題10分)1、ORG0ORG30HLJMPSTART;跳轉(zhuǎn)到(PC)=0030H處START:MOVSP,#50H;#50H->SP(SP)=50HORG30HMOVR2,#10H;#10H->R2(R2)=10HSTART:MOVR0,#20H;#20H->R0(R0)=20HMOVDPTR,#3000H;#3000H->DPTR(DPTR)=3000HMOVR1,#30H;#30H->R1(R
2、1)=30HCRLA;0->A(A)=0MOVA,R0;(R0)->A(A)=20HLOOP:MOVX@DPTR,A;(A)->(DPTR)ADDA,#36H;(A)+#36H->A(A)=56HINCDPTR;(DPTR)+1->DPTRMOVP1,A;(A)->P1(P1)=56HDJNZR2,LOOP;(R2)-1->R2若(R2)不等于零則轉(zhuǎn)移到LOOP處INCR0;(R0)+1->R0(R0)=21HINCDPH;(DPH)+1->DPH(DPH)=31H(R2)=00H(DPL)=10HINCR1;(R1)+1->R0(R1)
3、=31HINCDPH;(DPH)+1->DPH(DPH)=32HANLA,R1;(A)&(R1)->A(A)=10HMOV20H,#36H;#36H->(20H)(20H)=36HSWAPA;累加器A的高低4位交換(A)=01HSETB00H;位地址00H置120H.0=1(20H)=37HPUSHACC;累加器A內(nèi)容壓棧MOVA,20H;(20H)->A(A)=37HMOVP1,A;(A)->P1(P1)=01HMOVX@DPTR,A;(A)->(DPTR)(DPTR)=3210H(3210H)=37HPOPB;堆棧內(nèi)容出棧到B寄存器(
4、B)=01HINCA;(A)+1->A(A)=38HMOVR0,A;(A)->R0(R0)=01HINCA;(A)+1->A(A)=39HMOVDPTR,#2200H;#2200H->DPTR(DPTR)=2200HPUSHACC;累加器A內(nèi)容壓棧(SP)=51HSETBC;1->Cy(Cy)=1XCHA,R2;累加器A的內(nèi)容與R2內(nèi)容互換(A)=00H(R2)=39HADDCA,#0;(A)+0+(Cy)->A(A)=02HPOPDPH;堆棧內(nèi)容彈到DPH(DPH)=39HMOVX@DPTR,A;(A)->(DPTR)(2200H)=0
5、2HADDA,#55H;(A)+#55H->A(A)=55HENDPUSHACC;累加器A內(nèi)容壓棧(R0)=01H(R1)=31H(P1)=01HEND(B)=01H(2200H)=02H(A)=55H(R2)=39H(20H)=37H(DPTR)=3910H(SP)=51H第1頁共36頁3、ORG04、ORG0LJMPSTART;跳轉(zhuǎn)到(PC)=0030H處LJMPSTART;跳轉(zhuǎn)到(PC)=0030H處ORG30HORG30HSTART:MOVR0,#30H;#30H->R0(R0)=30HSTART:MOVSP,#50H;#50H-
6、>SP(SP)=50HMOVA,#12H;#12H->A(A)=12HMOVDPTR,#3000H;#3000H->DPTR(DPTR)=3000HSETBC;(Cy)=1MOVR0,#20H;#20H->R0(R0)=20HADDCA,R0;(A)+(R0)+Cy->A(A)=43HMOVA,#23H;#23H->A(A)=23HMOV@R0,A;(A)->(R0)(30H)=43HMOVR2,#0FH;#0FH->R2(R2)=0FHSWAPA;累加器A高低4位交換(A)=34HSETB01H;置位20H.1(20H.1)=1INCA
7、;(A)+1->A(A)=35HSETBC;置位Cy(Cy)=1MOVDPTR,#2000H;#2000H->DPTR(DPTR)=2000HADDCA,@R0;(A)+((R0))+Cy->A(A)=26HINCDPH;(DPH)+1->DPH(DPH)=21HINCR0;(R0)+1->R0(R0)=21HMOVP1,A;(A)->P1(P1)=35HMOV@R0,A;(A)->((R0))(21H)=26HINCA;(A)+1->A(A)=36HLOOP:DJNZR2,LOOP;(R2)-1->R2若R2內(nèi)容不等于零則轉(zhuǎn)移MOVX@
8、DPTR,A;(A)->(DPTR)(2100H)=36HSWAPA;累加器A內(nèi)容的高低4位交換(A)=62HXCHA,R0;(A)?R0(A)=30H(R0)=36HPUSHACC;累加器A