• 313.00 KB
  • 2022-04-22 11:25:35 发布

《微机原理及接口技术》典型习题参考答案.doc

  • 15页
  • 当前文档由用户上传发布,收益归属用户
  1. 1、本文档共5页,可阅读全部内容。
  2. 2、本文档内容版权归属内容提供方,所产生的收益全部归内容提供方所有。如果您对本文有版权争议,可选择认领,认领后既往收益都归您。
  3. 3、本文档由用户上传,本站不保证质量和数量令人满意,可能有诸多瑕疵,付费之前,请仔细先通过免费阅读内容等途径辨别内容交易风险。如存在严重挂羊头卖狗肉之情形,可联系本站下载客服投诉处理。
  4. 文档侵权举报电话:19940600175。
'《微机原理及接口技术》典型习题参考答案第2章2.14,2.27,2.40,2.46,2.49,2.52第5章5.10,5.14,5.17,第6章6.2,6.10,6.12,6.14第7章7.9,7.11第10章10.4,10.5第2章2.9(1)读操作占一次总线周期(4个时钟+1个时钟的等待周期)共5个时钟周期每个时钟周期=1/4MHz=0.25us,所以共需要0.25us*5=1.25us(2)复位至少需要4个时钟周期,4*0.25us=1us复位后内部除CS=FFFFH外,其它寄存器清0。第一条指令的地址FFFF0H2.10T1:地址锁存T2:地址撤销,准备数据T3:数据稳定到总线上T4:读写总线上的数据2.1(1)数据段首地址DS*16=01500H,堆栈段首地址=SS*16=02500H,所以数据段中存放信息不能与堆栈段重合,故数据段末地址=0250H-1=024FFH即数据段范围:01500H~024FFH(2)堆栈段末地址=SS*16+SP=02500H+1200H=03700H大小为1200H字节=4608字节,可存放16位的字4608/2=2304个(3)代码段由于下限没有其它限制,故最大64KB首地址=06400H,末地址=06400H+64KB-1=06400H+FFFFH=163FFH所以代码段地址范围:06400H~163FFH(4)现在SP=0300H,则原来SP+12=0300H+0CH=030CH15 《微机原理及接口技术》典型习题参考答案2.40处理器主要参数80888086802868038680486PentiumPentiumProPentiumIIPentiumIIIPentium4通过寄存器位数16161632323232323232段寄存器位数16161616161616161616外部数据线条数8161632326464646464外部地址线条数20202432323236363636存储器空间1MB1MB16MB4GB4GB4GB64GB64GB64GB64GB寻址范围0~FFFFFH0-FFFFFH0-FFFFFFH0~FFFFFFFFH0~FFFFFFFFH0~FFFFFFFFH0~FFFFFFFFFH0~FFFFFFFFFH0~FFFFFFFFFH0~FFFFFFFFFH有符号数表示范围-215~215-1-215~215-1-215~215-1-231~231-1-231~231-1-231~231-1-231~231-1-231~231-1-231~231-1-231~231-1注:数的表示范围仅与内部通用寄存器的位数(字长)有关,与外部数据线条数无关。相同颜色,表示之间有决定关系2.46(1)G=0段界以字节为单位,地址范围:089C0000H~089C003FH大小为3FH+1=40H=64,可容纳64/2=32个汉字(2)G=1段大小=(界+1)*4K=40H*4K=40000H段的最后一页起始地址=089C0000H+40000H=089A0000H,一页有4KB大小,因此段的末地址=089A0000H+FFFH=089A0FFFH注:书上P.64个末地址小加了FFFH(一页的界),结果为0048FFFFH(不是48F000H)2.48(1)DS*16+EAX=20000H+00003000H=00023000H(2)DS*16+ESI=1A000H+00002000H=0001C000H(3)SS*16+ESP=C0000H+0000A000H=000CA000H(4)DS*16+EDI=12390H+0000A000H=0001C390H2.49(1)访问权=11110010B=F2H,段基地址=03000000H,段界=末地址-首地址=1FFFH<10000H所以G=0,D=1,AVL=1,段描述符=0350F20000001FFFH(2)访问权=11110010B=F2H,段基地址=01000000H,段界=末地址-首地址=01800FFF>10000H,所以G=1,D=1,AVL=1,段界=大小/4K=1800H=1800H段描述符=01D0F20000001800H2.51(1)DS=0000000000001011B选中(TI=0)GDT表15 《微机原理及接口技术》典型习题参考答案GDTR=001000001FFFH,GDT首地址=00100000H,段描述符界=1FFFH,可容纳8KB,因此可放8KB/8=1K个描述符。(2)段描述符首地址=00100000H+1*8=00100008H,段描述符=0240F210000003FFH段首地址=02100000H,段界=03FFH,所以末地址=021003FFH段的地址范围:02100000H~021003FFH(3)物理地址=段基地址+偏移地址=02100000H+00000002H=02100002H(4)EAX中的内容为02100002开始的4个字节,故EAX=32303031H(5)可从段描述符的应该说访问权字节及选择子分析:RPL=11,访问权=F2H=11110010B,该段是用户访问的存在物理存储器中的未被访问过的向上增长的可写数据段。2.52(1)CR0=60000010H,PG=0,PE=0为实地址方式,所以:物理地址=10030H+1230H=11260H,EAX=75392A00H(2)CR0=60000011H,PG=0,PE=1分段的保护方式,所以:段描述符首地址=0+1000H=00001000H,段描述符=0040F20100001FFFH段基地址=00010000H,物理地址=00010000H+1230H=00011230HEAX=32303034H段大小=段界+1=1FFFH+1=2000H,可容纳8KB数据,访问权=F2=11110010H,该段是存在物理存储器中的未被访问过的向上增长的可写数据段。(3)CR0=E0000011H,PG=1,PE=1分段且分页的保护方式,但线性地址已经给出:线性地址=00000004H,页目录索引=0页索引=0CR3=00001000H,页目录描述符首地址=00010000H,页描述符=00001FFFH所以页表基地址=00001000H,页描述符首地址=00010000H,页描述符=00001FFFH所以页基地址=00001000H,物理地址=00010000H+4H=00010004H第5章5.4SRAM引脚考虑(1)数据线条数(2)地址线条数(3)读信号和写控制信号、片选信号条数(4)电源,地线8K*8表明,地址线条数=log28K=log2213=13条,数据线8条,读写信号线1条,片选项1条,电源和地2条,共计25条,但为了成对,因此至少26条引脚。5.108K*8=213*8,ROM首地址=末地址-大小+1=5800H-8K+1=5800H-1FFFH=3801H16KB=214*8,末地址=RAM首地址+大小-1=5801H-3FFFH=9800H5.12由图知,地址线m=16,数据线=8条,容量=2m*n=216*8=64KB(实际为27512)5.14需要8K*8/(2K*4)=8片,2片一组进行位扩展,然后对4组进行字扩展,即采用字位全扩展方法。15 《微机原理及接口技术》典型习题参考答案地址范围:(I):Y0=0:A13A12=00,A11~A1从全0到全1变化,但A0=0,所以范围:0000H~0FFEH(全为偶地址),共2KB(II):Y0=0:A13A12=00,A11~A1从全0到全1变化,但A0=1,所以范围:0001H~0FFFH(全为奇地址),共2KB(III):Y1=0:A13A12=01,A11~A1从全0到全1变化,但A0=0,所以范围:1000H~1FFEH(全为偶地址),共2KB(IV):Y1=0:A13A12=01,A11~A1从全0到全1变化,但A0=0,所以范围:1001H~1FFFH(全为奇地址),共2KB5.17题图改动:M/IO加一非门后再接G2B。(1)地址:1#(Y0=0)A19A18A17A16A15=10000,A14~A0全0到全1变化所以以范围:80000H~87FFFH2#(Y1=0)A19A18A17A16A15=10001,A14~A0全0到全1变化所以以范围:88000H~8FFFFH3#(Y2=0)A19A18A17A16A15=10010,A14~A0全0到全1变化所以以范围:90000H~97FFFH4#(Y3=0)A19A18A17A16A15=10011,A14~A0全0到全1变化所以以范围:98000H~9FFFFH5#(Y4=0)A19A18A17A16A15=10011,A14~A0全0到全1变化所以以范围:98000H~9FFFFH6#(Y5=0)A19A18A17A16A15=10101,A14~A0全0到全1变化所以以范围:A8000H~AFFFFH7#(Y6=0)A19A18A17A16A15=10110,A14~A0全0到全1变化所以以范围:B0000H~B7FFFH(2)MOVAX,9800H;4#首地址98000H,取段地址9800H偏移地址0MOVDS,AXMOVSI,0MOVCX,1024*2;2KBMOVAX,0B000H;7#首地址0B0000H,取段地址B000H,偏移地址0MOVES,AXMOVDI,015 《微机原理及接口技术》典型习题参考答案CLD;DF=0REPMOVSB;串操作或MOVAX,9800H;4#首地址98000H,取段地址9800H偏移地址0MOVDS,AXMOVSI,0MOVCX,1024*2;2KBMOVAX,0B000H;7#首地址0B0000H,取段地址B000H,偏移地址0MOVES,AXMOVDI,0LP1:MOVAL,[SI]MOV[DI],ALINCSIINCDILOOPLP1第6章6.2(a)A9A8A7A6A5A4A3A2A1A0=0001111111=7FH(b)A9A8A7A6A5A4A3A2A1A0=1001010XXX所以地址:250H~257H6.6MOVAL,80H;设置波特率MOVDX,373H;A1A0=11的地址(线路控制寄存器)OUTDX,ALMOVAL,30;1843200/(38400*16)除数MOVDX,370HOUTDX,AL;写除数低字节MOVAL,0INCDXOUTDX,AL;写除数高字节MOVAL,00010010BMOVDX,3F3HOUTDX,AL6.7MOVAL,80HMOVDX,3FBHOUTDX,ALMOVAL,10H;波特率7200的除数值=10HMOVDX,3F8HOUTDX,ALINCDXMOVAL,0OUTDX,AL15 《微机原理及接口技术》典型习题参考答案MOVAL,00000011BMOVDX,3FBHOUTDX,ALSEND:MOVDI,OFFSETTRANSMOVCX,WORDPTRTLENGTH+4MOVSI,OFFSETTRANS-2MOVBYTEPTR[DI-2],55HMOVBYTEPTR[DI-1],0AAHMOVAX,DIADDAX,WORDPTRTLENGTHMOVDI,AXMOVBYTEPTR[DI+1],0AAHMOVBYTEPTR[DI+2],55HSWAIT:MOVDX,3FBHINAL,DX;取线路状态TESTAL,00100000B;THRE发送保持寄存器空=1JZSWAIT;不空等待MOVAL,[SI];取数据MOVDX,3F8HOUTDX,AL;发送INCSILOOPSWAITMOVDI,OFFSETRECIVMOVCX,WORDPTRRLENGTHMOVBL,0;计接收数据个数RECEIVE:MOVDX,3FBHINAL,DX;取线路状态参数,判断接收有数据否TESTAL,80H;超时退出JNZEXITPTESTAL,01H;接收数据继续JZRECEIVE;串口无数据等待MOVDX,3F8HINAL,DXINCBL;接收一个数据,计数器加1LOOPRWAITEXITP:MOVAL,CLCMPAL,BLJNZERR_DELMOVERROR,0FFHJMPRET1ERR_DEL:MOVERROR,0RET1:NOP.EXIT6.915 《微机原理及接口技术》典型习题参考答案(1)MOVAL,10011010BOUT63,AL(2)MOVAL,11000100BOUT63,AL(3)MOVAL,10100100BOUT63,AL6.10(1)MOVAL,10011000BMOVDX,0FEFFH;控制口OUTDX,AL(2)MOVDX,0FEFEH;C口WAITL:INAL,DX;ReadyMOVDX,0FEFCH;A口INAL,DXTESTAL,00100000B;PC5JZWAITL;未准备好等待MOVDX,0FEFCH;A口INAL,DX;读输入设备数据MOVES:[DI],AL;写入指定内存单元(3)MOVDX,0FEFEH;C口WAITP:INAL,DXTESTAL,01000000B;PC6(BUSY)JNZWAITPMOVAL,DS[SI]MOVDX,0FEFDH;B口OUTDX,AL;数据输出(4)START:MOVDX,0FEFEHINAL,DXTESTAL,80H;判断PC7JNZBEEPMOVDX,0FEFFHMOVAL,0;PC0=0置复位命令字OUTDX,AL;取消报警JMPSTARTBEEP:MOVDX,0FEFFHMOVAL,1;PC0=1OUTDX,AL;报警MOVSI,OFFSETSTRINGSMOVCX,18;18个字符WAITB:MOVDX,0FEFFHINAL,DXTESTAL,01000000B;BUSY=1?JNZWAITBMOVAL,[SI]15 《微机原理及接口技术》典型习题参考答案MOVDX,OFEFDH;B口OUTDX,ALINCSILOOPWAITBSTRINGSDB‘Grasptheburglar!’6.11MOVAL,1000100BOUT0F3H,AL;方式选择控制字MOVSI,OFFSETPDATAMOVCX,PNUMMOVAL,00000010B;PC1=0置复位命令字OUTDX,ALREPEAT:MOVAL,[SI];取数据MOVBL,AL;暂存BLANDAL,0F0H;取高4位PUSHCXMOVCL,4SHRAL,CLADDAL,30H;转换成ASCII码POPCXCALLSUBPMOVAL,BL;取回原来的数据ANDAL,0FH;取低4位ADDAL,30H;转换成ASCII码CALLSUBPINCSI;指向下一个单元LOOPREPEAT.EXIT;打印一个字符的子程序SUBPPROCNEARMOVDX,0F1H;B口地址OUTDX,AL;待打印字符(ASCII码)送B口(打印机端口)INCDXWAITP:INAL,DX;判BUSY=PC5TESTAL,00100000B;BUSY=PC5JNZWAITPMOVDX,0F3HMOVAL,00000011BOUTDX,AL;PC1=1命令(/STB=1)NOPDECALOUTDX,AL;PC1=0命令(/STB=0)RETSUBPENDP15 《微机原理及接口技术》典型习题参考答案6.11.MODELSMALL.CODE.STARTUPMOVAL,00110110B;CTC0命令字:方波信号发生器方式MOVDX,9F0FH;8254控制口地址OUTDX,ALMOVDX,9F0CH;CTC0通道地址MOVAX,2000;计数常数=2MHz*1000us=2000OUTDX,AL; 实际收入低8位初值MOVAL,AH;取高8位OUTDX,AL;写高8位初值MOVAL01010100B;CTC1命令字:速率发生器方式MOVDX,9F0FH;8254控制口地址OUTDX,ALMOVDX,9F0DH;CTC1通道地址MOVAL,2;计数常数=2(最快)OUTDX,AL;写初值MOVAL10110010B;CTC2命令字:负脉冲信号发生器方式MOVDX,9F0FH;8254控制口地址OUTDX,ALMOVDX,9F0EH;CTC2通道地址MOVAL,0;计数常数=0000(最大值)OUTDX,AL;写初值OUTDX,AL.EXITEND6.14(1)由地址:280H~283H知:(地址不重叠,即全译码,I/O端口16条地址线全部要参与译码)A15A14A13A12A11A10A9A8A7A6A5A4A3A2=00000010100000xxB电路如下:15 《微机原理及接口技术》典型习题参考答案(2)OUT0产生2ms定时中断信号(方波)MOVAL,00110110B;ctc0控制字MOVDX,0283HOUTDX,ALMOVAX,20000;初值=5MHz*(2ms*2)=5000*4=20000;注意:2ms仅为负脉冲宽度,因此一个周期=4msMOVDX,280H;CTC0通道OUTDX,AL;写低字节初值MOVAL,AHOUTDX,AL;写高字节初值(3)将OUT0连接到CLK1,CTC1初值=1S/4ms=1000/4=250MOVAL,01010110B;ctc1控制字MOVDX,0283HOUTDX,ALMOVAX,250;初值=1S/4ms=250MOVDX,281H;CTC1通道OUTDX,AL;写初值第7章7.9(1);主片初始化MOVAL,00010001B;ICW1OUT20H,ALMOVAL,0FH;中断类型号(ICW2)OUT21H,ALMOVAL,00000100B;ICW3OUT20H,ALMOVAL,00010101B;ICW4OUT21H,AL15 《微机原理及接口技术》典型习题参考答案;从片初始化MOVAL,00010001B;ICW1OUT0A0H,ALMOVAL,71H;中断类型号(ICW2)OUT0A1H,ALMOVAL,00000010B;ICW3OUT0A0H,ALMOVAL,00000001B;ICW4OUT0A1H,AL(2)MOVAL,00101000B;主片OCW1OUT21H,ALMOVAL,00100000B;从片OCW1OUT0A1H,AL(3)MOVSI,1000MOVDI,2000MOVAL,0AHOUT20H,AL;读主片IRR命令INAL,20H;读IRR进AL中MOVBL,AL;主片IRR暂存BLMOVDS:[SI],AL;主片IRR存入内存INCSIMOVAL,0BHOUT20H,AL;读主片ISR命令INAL,20H;读主片ISR进AL中MOVDS:[SI],AL;主片ISR存入内存INCSIINAL,21H;读主片IMRMOVDS:[SI],AL;主片IMR存入内存MOVAL,0AHOUT0A0H,AL;读从片IRR命令INAL,0A0H;读从IRR进AL中MOVBL,AL;从片IRR暂存BHMOVES:[DI],AL;从片IRR存入内存INCDIMOVAL,0BHOUT0A0H,AL;读从片ISR命令INAL,0A0H;读从片ISR进AL中MOVES:[DI],AL;从片ISR存入内存INCDIINAL,0A1H;读从片IMRMOVES:[DI],AL;从片IMR存入内存MOVAL,BL;取主片IRRMOVCX,815 《微机原理及接口技术》典型习题参考答案MOVDL,0;计1的个数LP10:SHRAL,1ADDCDL,0LOOPLP10CMPDL,2;>=2?JAELP11JMPLRETLP11:MOVAL,BH;取从片IRRMOVCX,8MOVDL,0;计1的个数LP20:SHRAL,1ADDCDL,0LOOPLP20CMPDL,1;>=2?JZEIOPJMPLRETEIOP:MOVAL,20H;EOI命令OUT20H,AL;OCW3OUT0A0H,ALMOVAL,BLNOTAL;对主片IRR取反OUT21H,AL;屏蔽主片未申请的中断MOVAL,BHNOTAL;对从片IRR取反OUT0A1H,AL;屏蔽从片未申请的中断LRET:NOP.EXIT(4)INSTR:PUSHAXPUSHDXMOVDX,3C0HINAX,DXMOVWORDPTRDATABUF,AXCMPAX,2005HJASTOPCMPAX,0JZWRITEAASTOP:MOVAL,55HMOVDX,3C1HOUTDX,ALJMPRET0WRITEAA:MOVBYTEPTRDATABUF+5,0AAHRET0:MOVAL,20H;EOI命令OUT20H,ALOUT0A0H,AL15 《微机原理及接口技术》典型习题参考答案POPDXPOPAXIRET(5)INSTALL:CLIMOVDX,OFFSETINSTRMOVAX,2577H;中断类型号77H(对应从片的IR7)INT21HINAL,0A1H;读IMRANDAL,01111111B;打开从片IR7中断OUT0A1H,ALSTIMOVDX,OFFSETINSTALLINT27H7.10(1)电路改动(a)系统地址线A1接8259的A0,其它地址不变(b)U3的1脚原来接A1的改接A0GAL编程:U4不变GAL16V8;U3AddressCodingforInterruptVER2005ByMaWHA0A2A3A4A5A6A7A8A9GNDA10I1I2I3I4NCNCCS2CS1VCC/CS1=/A0*/A2*/A3*/A4*A5*/A6*/A7*/A8*/A9*/A10*I1/CS2=/A0*/A2*/A3*/A4*A5*/A6*A7*/A8*/A9*/A10*I1DESCRIPTION(2)MOVAL,50HMOVDX,302H;主片A0=1的地址OUTDX,ALMOVAL,98HMOVDX,306H;从片A0=1的地址OUTDX,AL(3)循环优先方式MOVAL,10000000BMOVDX,300H;主片A0=0的地址OUTDX,ALMOVDX,304H;从片A0=0的地址OUTDX,AL(4)特殊循环优先MOVAL,11000101B;IR5最先优先MOVDX,300H;主片A0=0的地址OUTDX,ALMOVDX,304H;从片A0=0的地址OUTDX,AL7.11CR0=60000001H知PG=0,PE=1保护方式中断描述符首地址=IDT表首地址+中断类型号*8=65000000H+11H*8=65000088H15 《微机原理及接口技术》典型习题参考答案所以中断描述符=0042EE0081132012H其中描述的偏移地址=00422012H,段选择子=8113H因此段描述符首地址=GDT首地址+索引*8=00100000H+8110H=00108110H段描述符=0144F20070001FFFH,其描述符的段基地址=01007000H,因此中断服务程序入口地址=段基地址+偏移地址=01007000H+00422012H=01429012H第10章10.4.1V对应的数字量:由1=5/256*D得,D1V=256/5=51.2=51=33H同理4V对应的数字量D4V=256/5*4=204.8=205=CDHDLVEQU51DHVEQU205MOVDX,3A9HMOVAL,DLVREPLP1:OUTDX,ALCMPAL,DHVJBINCDVREPLP2DECALOUTDX,ALCMPAL,DLVJAREPLP2INCDV:INCALJMPREPLP110.5入口:8255口地址320H~323H出口:转换后的12位数字量在BX中ADCSPROCNEARMOVDX,323H;8255控制寄存器端口MOVAL,10010011B;8255A,B方式0输入.PC上半口输出,下半口输入MOVDX,AL;8255控制字写入控制寄存器MOVAL,00001010BOUTDX,AL;PC5=0,使为低电平MOVAL,00001100BOUTDX,AL;PC6=0,使为低电平MOVAL,00001111BOUTDX,AL;PC7=1,使CE为高电平,启动A/D转换MOVAL,00001011BOUTDX,AL;PC5=1,使为高电平DECDX;指向端口CTWAIT:INAL,DXTESTAL,01;PC0=STSJNZTWAIT;STS=1等待INCDX;指向控制口MOVAL,00001100;15 《微机原理及接口技术》典型习题参考答案OUTDX,AL;使=0MOVAL,00001111;使CE=1允许读OUTDX,ALMOVDX,321H;指向B口INAL,DX;取高4位数据(PB3~PB0)ANDAL,0FH;屏蔽无效位MOVBH,AL;A/D转换值高4位暂存BH中DECDX;指向A口INAL,DXMOVBL,AL;读低8位数据暂存BL中MOVDX,323H;指向控制口MOVAL,00001110B;使CE=0无效OUTDX,ALMOVAL,00001101B;使=1无效OUTDX,AL;结束读取操作RETADCSENDP15'