《单片机习题答案.pdf》由会员分享,可在线阅读,更多相关《单片机习题答案.pdf(47页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、230 何宏单片机原理与接口技术习题解答第 4章习题解答4-1 简述以下基 本概念。答指 令:CPU根据人的 意图来执行某种操作的命令。指令 系统:一台电脑所能执行的全部指令集合。机器 语言:用二进制编码表示,电脑能直接识别和执行的语言。汇编 语言:用助记符、符号和数字来表示指令的程序语言。高级 语言:独立 于 机器的,在编 程时不需 要对机器结构及其指令系统有深入了解的通用性语言。4-2 什么是电脑 的指令 和指 令系 统?答见 1题。4-3 简述 80C51汇编 指令 格式。答操作 码 目的操纵 数 ,源 操作数 4-4 简述 80C51的寻 址方 式和 所能 涉及的寻址空间。答立 即数寻
2、址:程序 存储器ROM。直接 寻址:片内 RAM 低 128B 和 特殊功能寄存器。寄存 器寻址:R0 R7,A,AB,Cy,DPTR。寄存 器间接 寻址:片内 RAM 低 128B,片外RAM。变址 寻址:程序存储器 64KB。相对 寻址:程序存储器 256B范围。位寻 址:片 内 RAM 的 20H 2FH字节地址,部分特殊功能寄存器。4-5 要访问特殊 功能寄 存器 和片 外数据 存储器,应 采用 哪些寻址方式?答 SFR:直接寻址,位 寻址,寄存器寻址;片外 RAM:寄存器间接寻址。4-6 在 80C51 片 内 RAM 中,已知(30H)=38H,(38H)=40H,(40H)=48
3、H,(48H)=90H。请 分析 下面 各是什么指令,说 明源 操作数 的寻址方式 及按 顺序执 行后的结果。答 MOV A,40H 直接 寻址 MOV R0,A 寄存器寻址 MOV P1,#0F0H 立即数寻址 MOV R0,30H 直接寻址 MOV DPTR,#3848H 立即数 寻址 MOV 40H,38H 直接 寻址 MOV R0,30H 直接寻址 MOV P0,R0 寄存器寻址 MOV 18H,#30H 立即数寻址 MOV A,R0 寄存器间接寻址 MOV P2,P1 直接寻址231 均为 数据传 送指令,结果(参见以下图)为RAM 30H 38H 38H 40H 40H 48H 4
4、8H 90H (18H)=30H,(30H)=38H,(38H)=40H(40H)=40H,(48H)=90H R0=38H,A=40H,P0 38H,P1 FOH,P2=FOH,DPTR=3848H 4-7 对 80C51 片 内 RAM 高 128B 的地 址空 间寻址要注意 什么?答用 直接寻址,寄存 器寻址,位寻址。4-8 指出以下指 令的本 质区 别。答 MOV A,data 直接 寻址 MOV A,#data 立即数寻址 MOV data1,data2 直接寻址 MOV 74H,#78H 立即数寻址4-9 设 R0的 内 容 为 32H,A的 内 容 为 48H,片 内 RAM 的
5、 32H内 容 为 80H,40H的 内容 为 08H。请 指出 在执行以下 程序 段后各单元内容的 变化。MOV A,R0;(R0)=80H A MOV R0,40H;(40H)=08H (R0)MOV 40H,A;(A)=80H 40H MOV R0,#35H;35H R0 解 (R0)=35H(A)80H(32H)08H (40H)=80H 4-10 如何 访问 SFR,可 使用 哪些 寻址方 式?答访问 SFR:直 接寻 址,位寻址,寄存器寻址。4-11 如何 访问 片外 RAM 单元,可使用哪 些寻址方式?答只能 采用寄存器间接寻址(用 MOVX 指令)。4-12 如何 访问 片内
6、RAM 单元,可使用哪 些寻址方式?答低 128B:直 接寻址,位寻址,寄存器间接寻址,寄存器寻址(R0 R7)。高 128B:直 接寻址,位寻址,寄存器寻址。4-13 如何 访问 片内外程序存 储器,采用哪 些寻 址方 式?答采用 变址寻址(用 MOVC 指令)。4-14 说明 十进 制调整的原因 和方 法。答压缩 BCD码在 进行 加法运算时本应逢十进一,而电 脑只 将其当作 十六进制数处理,此时得到的结果不正确。用 DAA指令 调整(加 06H,60H,66H)。4-15 说明 80C51 的布尔 处理 机功 能。答用来进行位操 作。文档编码:CB10G1K4G4O7 HJ7A2M1O1
7、C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X
8、3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K
9、4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1
10、O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q
11、6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G
12、1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2
13、M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3232 4-16 已 知(A)=83H,(R0)=17H,(17H)=34H,请 指 出 在 执 行 以 下 程 序 段 后 A的 内容。解 ANL A,#17H ;83H 17H=03H A ORL 17H,A;34H 03H=37H 17H XRL A,R0;03H异 或 37H=34H CPL A;34H求 反
14、等于 CBH 所以(A)=CBH 4-17 使用 位操 作指令实现以 下逻 辑操作。要求不得 改变 未涉及位的内容。SETB ACC.0 或 SETB EOH (2)清 除累加器高 4位4-18 编写 程序,将片内RAM R0 R7的 内容 传送 到 20H 27H单 元。解 MOV 27H,R7 MOV 23H,R3 MOV 26H,R6 MOV 22H,R2 MOV 25H,R5 MOV 21H,R1 MOV 24H,R4 MOV 20H,R0 4-19 编 写 程 序,将 片 内 RAM 的 20H,21H,22H三 个 连 续 单 元 的 内 容 依 次 存 入2FH,2EH,2DH中
15、。解 MOV 2FH,20H MOV 2EH,21H MOV 2DH,22H 4-20 编 写程序,进行两个 16位数 的减 法:6F5DH一 13B4H,结果存入片 内 RAM的 30H和 31H单元,30H存 差的 低 8位。解 CLR C MOV A,#5DH;被 减数低 8位 A MOV R2,#B4H;减 数低 8位 R2 SUBB A,R2;被 减数减去减数,差 A MOV 30H,A;低 8位结果 30H MOV A,#6FH;被 减数高 8位 A MOV R2,#13H;减 数高 8位 R2 SUBB A,R2;被 减数减去减数,差 A MOV 31H,A;高 8位结果 31H
16、 文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K
17、4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1
18、O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q
19、6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G
20、1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2
21、M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I
22、9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3233 4-21 编 写程 序,假设累加器 A的内 容分 别满足以下 条件 时,则程 序转 至 LABEL存 储单 元。设 A中 有的是无符 号数。解 (1)A 10 CJNE A,#10,L1 ;(A)与 10比较,不等转 L1 L2:LJMP LABEL;相
23、等转LABEL L1:JNC L2 ;(A)大 于 10,转 LABEL (2)A10 CJNE A,#10,L1 ;(A)与 10比较,不等转 L1 SJMP L3 ;相等转L3 L1:JNC L2;(A)大 于 10,转 L2 SJMP L4 ;(A)小 于 10,转 L4 L2:JMP LABEL ;无条件转 LABEL (3)A 10 CJNE A,#10,L1;(A)与 10 比 较,不等 转 L1 L2:LJMP LABEL;相 等转 LABEL L1:JC,L2;(A)小 于 10,转 LABEL 4-22 已知 SP=25H,PC=2345H,(24H)=12H,(25H)=3
24、4H,(26H)=56H。问 此时执 行“RET”指令 后,SP=?PC=?解 SP 23H,PC=3412H 4-23 已 知 SP=25H,PC=2345H,标 号 LABEL所 在 的 地 址 为 3456H。问 执 行 长 调用 指令“LCALL LABEL”后,堆 栈指针和堆 栈内容发生 什么 变化?PC的值 等于 什么?解 SP 27H,(26H)=48H,(27H)23H,PC 3456H 4-24 上题 中 LCALL能否 直接 换成 ACALL指令,为什 么?如果 使用 ACALL指 令,则 可调 用的 地址范围是多 少?解不能。ACALL是短 转指令,可调用的地址范围是2
25、KB。4-25 阅读 以下 程序,要求:(1)说 明程序功能;(2)试 修改程序,使片内 RAM 的内容成为 如下图的结 果。文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ
26、1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码
27、:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7
28、 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2
29、ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档
30、编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4
31、O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3234 MOV R2,#0AH 50H 00H MOV R0,#50H 51H 01H CLR A 52H 02H LOOP:MOV R0
32、,A 53H 03H INC R0 54H 04H DJNZ R2,LOOP 55H 05H DONE:56H 06H 57H 07H 58H 08H 59H 09H 解(1)功能是将片内RAM 中 50H 59H单 元清零。(2)7A(OA)(7850)DA(FC)(3)在 INC R0 后 添一句INC A。4-26 设(R0)=7EH,(DPTR)=10FEH,片 内 RAM 中 7EH单 元 的 内 容 为 0FFH,7F单元 的内 容为 38H,试为以下程 序注 释其运行结果。解 INC R0(7EH)00H INC R0 (R0)7FH INC R0 (7FH)39H INC DP
33、TR (DPTR)10FFH INC DPTR (DPTR)1100H INC DPTR (DPTR)1101H 4-27 以 下程序 段经 汇编 后,从 1000H开始的各有 关存 储单 元的内容将是 什么?ORG 1000H TAB1 EQU 1234H TAB2 EQU 3000H DB“START”DW TAB1,TAB2,70H 解(1000H)=53H (1001H)=54H (1002H)=41H(1003H)=52H (1004H)=54H (1005H)=12H(1006H)=34H (1007H)=30H (1008H)=00H(1009H)00H(100AH)=70H 4
34、-28 阅读 以下 程序,并要求:(1)说 明程序功能;(2)写 出涉及的寄 存器及 片内 RAM 单 元(如下图)的最 后结果。40H 98H AFH 文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7
35、HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 Z
36、J1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编
37、码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O
38、7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2
39、 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文
40、档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3235 MOV R0,#40H;40H R0 MOV A,R0;98H A INC R0;41H R0 ADD
41、 A,R0;98+(A)=47H A INC R0 MOV R0,A;结果存入 42H单元 CLR A;清 A ADDC A,#0;进位位存入 A INC R0 MOV R0,A;进位位存入43H 解功 能:将 40H,41H单元 中 的 内容 相 加结 果 放在 42H单 元,进 位 放 在 43H单元,(R0)=43H,(A)1,(40H)=98H,(41H)AFH,(42H)47H,(43H)=01H。4-29 同上 题要 求,程序如下:61H F2H CCH MOV A,61H;F2H A MOV B,#02H;02H B MUL AB;F2H 02H E4H A ADD A,62H;
42、积 的低 8位 加上 CCH A MOV 63H,A;结 果送 63H CLR A;清 A ADDC A,B ;积 的高 8位 加进位位 A MOV 64H,A;结 果送 64H 解功能:将 61H单元 的内容乘2,低 8位再 加 上 62H单 元的内容放人63H,将 结果的高8位放在64H单元。(A)02H (B)01H(61H)F2H (62H)CCH (63H)BOH (64H)02H 4-30 编写 程序,采 用“与”运算,判 断 8位 二进 制数 是奇 数个 1还是偶数个 1。解 MOV A,#XXH ;待判断的数A ANL A,#0FFH;与 0FFH相 与 JB P,REL;是
43、奇数转REL;是 偶数程序顺序执 行 REL:4-31 编写 程序,采用“或”运算,使任意 8位 二进 制数 的符号位必为1。解 MOV A,XXH;取数据 A ORL A,#80H;使该数符号位为 1 MOV XXH,A;保存该数据文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 H
44、J7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ
45、1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码
46、:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7
47、 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2
48、ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档
49、编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3文档编码:CB10G1K4G4O7 HJ7A2M1O1C2 ZJ1U3I9Q6X3236 4-32 请 思 考:
50、采 用“异 或”运 算 怎 样 可 使 一 带 符 号 数 的 符 号 位 改 变,数 据位 不变?怎样 可使 该数必然为 零?解 (1)符号位改变,数据位不变:MOV A,XXH;取 数据A XRL A,#80H;异或80H A (2)使 该数为零:MOV A,XXH;该数A MOV R0,A ;该数R0 XRL A,R0 ;该数自身相异或第 5章习题解答5-1 编 写 程 序,查 找 在 片 内 RAM 中 的 20H 50H单 元 中 是 否 有 0AAH这 一 数 据。假 设有,则 51H单 元置为01H;假设未找 到,则51H单元置为 00H。解 MOV R2,#31H ;数据块长度