资源描述:
《第三章作业整编汇总》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#+1已知一个2维数据表格如下,编制程序实现自动查表功能。X01234…0B0C0D0E0FY111201ADDD…AB244B7CAAMOVDPTR,#0100HMOVCA,@A+DPTRRETDB11HDB12H...DB7CHDBAAH2.已知X被存放在20H(高八位)和21H(低八位)单元,Y被存放在22H,编制程序实现下X+Y。MOVA,21HADDA,22HMOV25H,AMOVA,20HADDCA,#00HMOV24H,AMOVA,#00ADDCA,#00MOV23H,A3.已知两个十进
2、制数:X和Y,X被存放在20H(高位)和21H单元,Y被存放在22H,编制程序实现下X+Y。法一:MOVA,21H法二:MOVR0,#21HADDA,22HMOVR1,#22HDAAMOVA,@R0MOV21H,AADDA,@R1MOVA,20HDAAADDCA,#00MOV@R0,ADAADECR0MOV20H,AMOVA,@R0MOVA,#00ADDCA,#00ADDCA,#00DAADAAMOV@R0,AMOV1FH,AMOVA,#00ADDCA,#00DAADECR0MOV@R0,A#+4.已
3、知X被存放在20H(高八位)21H、22H、23H单元,Y被存放在30H(高八位)31H、32H、33H单元,编制程序实现下X+Y。MOVA,23HADDA,33HMOV44H,AMOVA,22HADDCA,32HMOV43H,AMOVA,21HADDCA,31HMOV42H,AMOVA,20HADDCA,30HMOV41H,AMOVA,#00ADDCA,#00MOV40H,A5.已知X被存放在20H(高八位)、21H和22H单元,Y被存放在32H,编制程序实现下X—Y。MOVA,22HCLRCSUB
4、BA,32HMOV32H,AMOVA,21HSUBBA,#00HMOV31H,AMOVA,20HSUBBA,#00HMOV30H,A6.已知X被存放在20H(高八位)21H、22H、23H单元,Y被存放在30H(高八位)31H、32H、33H单元,编制程序实现下X-Y。MOVA,23HCLRCSUBBA,33HMOV43H,AMOVA,22HSUBBA,32HMOV42H,AMOVA,21HSUBBA,31HMOV41H,AMOVA,20H#+SUBBA,30HMOV40H,A7.已知X被存放在20H
5、(高八位)21H、22H单元,Y被存放在30H单元,编制程序实现下X×Y。MOVA,22HMOVB,30HMULABMOV40H,BMOV41H,AMOVA,21HMOVB,30HMULABMOV42H,BMOV43H,AMOVA,20HMOVB,30HMULABMOV44H,BMOV45H,AMOV53H,41HMOVA,40HADDA,43HMOV52H,AMOVA,42HADDCA,45HMOV51H,AMOVA,#00HADDCA,44HMOV50H,A8.已知一个数X被存放在20H(高八位)
6、21H单元,用移位方法实现2X。MOVA,21HCLRCRLCAMOV21H,AMOVA,20HRLCAMOV20H,AMOVA,#00HRLCAMOV1FH,A9.已知一个数X被存放在20H(高八位)21H单元,用移位方法实现X/2。MOVA,20HCLRC#+RRCAMOV30H,AMOVA,21HRRCAMOV31H,A10.已知一个非正数X被存放在20H(高八位)21H单元,求该数的补码。法一:法二:MOVA,20HMOVA,21HXRLA,#7FHCPLAMOV22H,AMOV23H,AMO
7、VA,21HMOVA,20HXRLA,#0FFHCPLAADDA,#01HORLA,#80HMOV23H,A;低八MOV22H,AMOVA,22HMOVA,23HADDCA,#00HADDA,#01HMOV24H,A;高八MOV23H,A;低八MOVA,22HADDCA,#00HMOV22H,A;高八11.根据X的值分别将程序转移到指定处执行X=0——PROG1;X=1——PROG2;X=2——PROG3;X=3——PROG4法一:法二;CLRCMOVB,#03HRLCAMULABMOVDPTR,#J
8、PTABMOVDPTR,#JPTABJMP@A+DPTRJMP@A+DPTRJPTAB:AJMPPROG1JPTAB:LJMPPROG1AJMPPROG2LJMPPROG2AJMPPROG3LJMPPROG3AJMPPROG4LJMPPROG412.一个显示装置如图1所示,编制程序实现使指示灯依次顺时针点亮——逆时针灭——全亮若干秒全灭,周而复始地重复上述过程。L0~L7分别与P1.0~P1.7相连。图1MAIN:MOVA,#00HMOVP1,A#+MO