《微机原理与接口技术》第四版周何琴课后习题答案.docx
《《微机原理与接口技术》第四版周何琴课后习题答案.docx》由会员分享,可在线阅读,更多相关《《微机原理与接口技术》第四版周何琴课后习题答案.docx(50页珍藏版)》请在冰豆网上搜索。
《微机原理与接口技术》第四版周何琴课后习题答案
第4章作业
P153
5.阅读下列程序,说明每条指令执行后的结果是什么?
X1DB65H,78H
X2DW06FFH,5200H
X3DD?
GO:
MOVAL,TYPEX1
MOVBL,TYPEX2
MOVCL,TYPEX3
MOVAH,TYPEGO
MOVBH,SIZEX2
MOVCH,LENGTHX3
解:
(1)前三条语句的功能是设置数据于数据段中,从数据段偏移地址0000H开始存放。
变量
偏移地址
数据
X1
0000H
65H
0001H
78H
X2
0002H
FFH
0003H
06H
0004H
78H
0005H
00H
X3
0006H
随机数
0007H
随机数
0008H
随机数
0009H
随机数
六条程序执行结果如下:
(AL)=01H;设置变量类型属性,字节数
(BL)=02H;设置变量类型属性,字节数
(CL)=04H;设置变量类型属性,字节数
(AH)=0FFH;设置GO显示类型,近标号,为-1,补码表示
(BH)=02H;设置数据类型,无DUP时,返回数据类型的字节数
(CH)=01H;无DUP时,返回1。
程序执行后结果如下:
调试程序如下:
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
DATASEGMENT
X1DB65H,78H
X2DW06FFH,5200H
X3DD?
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
GO:
MOVAL,TYPEX1
MOVBL,TYPEX2
MOVCL,TYPEX3
MOVAH,TYPEGO
MOVBH,SIZEX2
MOVCH,LENGTHX3
POPDS
HLT
CODEENDS
ENDSTART
6.画出示意图,说明下列变量在内存中如何让存放?
A1DB12H,34H
A2DB‘Right.’
A3DW5678H
A4DB3DUP(?
)
(1)设置数据于数据段中,从数据段偏移地址0000H开始存放。
变量
偏移地址
数据
A1
0000H
12H
0001H
34H
A2
0002H
52H
0003H
69H
0004H
67H
0005H
68H
0006H
74H
0007H
2EH
A3
0008H
78H
0009H
56H
A4
000AH
随机数
000BH
随机数
000CH
随机数
调试程序如下:
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
DATASEGMENT
A1DB12H,34H
A2DB'Right.'
A3DW5678H
A4DB3DUP(?
)
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
POPDS
HLT
CODEENDS
ENDSTART
12.编程实现,从键盘输入一个十进制数0~9,查表求键入数字的七段代码(共阳极LED显示器的段码),存入DL中,并在键入数字之前,显示提示信息“Pleaseinputanumber(0~9):
”。
解:
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
DATASEGMENT
TABLEDB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
BUFDB'Pleaseinputonenumber(0~9):
',0DH,0AH,'$'
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK,ES:
DATA
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
MOVDX,OFFSETBUF
MOVAH,09H
INT21H
MOVAH,1
INT21H
ANDAL,0FH
MOVBX,OFFSETTABLE
XLAT
MOVDL,AL
POPDS
HLT
CODEENDS
ENDSTART
调试结果:
数字5的共阳极LED七段码为92H。
15.已知:
在内存BUF开始的单元中,存在一串数据:
58,75,36,42,89。
编程找出其中的最小值存入MIN单元中,并将这个数显示在屏幕上。
解:
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
DATASEGMENT
BUFDB58H,75H,36H,42H,89H
MINDB0
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
MOVCX,4
MOVBX,OFFSETBUF
MOVAL,[BX]
ST1:
INCBX
CMPAL,[BX]
JBENEXT
MOVAL,[BX]
NEXT:
LOOPST1
MOVMIN,AL
ANDAL,0F0H
MOVCL,4
RORAL,CL
ADDAL,30H
MOVDL,AL
MOVAH,02H
INT21H
MOVAL,MIN
ANDAL,0FH
ADDAL,30H
MOVDL,AL
MOVAH,02H
INT21H
POPDS
MOVAH,4CH
INT21H
HLT
CODEENDS
ENDSTART
18.某班有20个同学的微机原理成绩存放在LIST开始的单元中,要求编程先从高到低的次序排列好,再求出总分和平均值,分别存放在SUM和AVER开始的单元中。
解:
STACKENDS
DATASEGMENT
LISTDB65H,76H,78H,54H,90H,85H,68H,66H,77H,88H
DB99H,89H,79H,69H,75H,85H,63H,73H,83H,93H
SUMDW0
AVERDB0
BUFDB100DUP(?
)
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
MOVDI,OFFSETLIST
MOVBX,19
LP0:
MOVSI,DI
MOVCX,BX
LP1:
MOVAL,[SI]
INCSI
CMPAL,[SI]
JNCLP2
MOVDL,[SI]
MOV[SI-1],DL
MOV[SI],AL
LP2:
LOOPLP1
DECBX
JNZLP0
LP3:
MOVCX,20
MOVBX,OFFSETLIST
MOVSUM,0
XORAX,AX
LP4:
ADDAL,[BX]
DAA
ADCAH,0
INCBX
LOOPLP4
MOVSUM,AX
MOVBL,20H
DIVBL
ADDAL,0
DAA
MOVAVERAL
POPDS
HLT
CODEENDS
ENDSTART
1.下列变量各占多少字节?
A1DW23H,5876H4字节
A2DB3DUP(?
),0AH,0DH,‘$’6字节
A3DD5DUP(1234H,567890H)4×2×5=40字节
A4DB4DUP(3DUP(1,2,‘ABC’))5×3×4=60字节
调试程序:
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
DATASEGMENT
DA1DW23H,5876H
DA2DB3DUP(?
),0AH,0DH,'$'
DA3DD5DUP(1234H,567890H)
DA4DB4DUP(3DUP(1,2,'ABC'))
DA5DB10DUP(?
)
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
MOVAX,OFFSETDA1
MOVBX,OFFSETDA2
MOVCX,OFFSETDA3
MOVDX,OFFSETDA4
MOVDI,OFFSETDA5
POPDS
HLT
CODEENDS
ENDSTART
5.对于下面的数据定义,各条MOV指令执行后,有关寄存器的内容是什么?
DA1DB?
DA2DW10DUP(?
)
DA3DB‘ABCD’
MOVAX,TYPEDA1
MOVBX,SIZEDA2
MOVCX,LENGTHDA3
解:
各条MOV指令执行后,有关寄存器的内容如下:
MOVAX,TYPEDA1;(AX)=1
MOVBX,SIZEDA2;(BX)=20
MOVCX,LENGTHDA3;(CX)=1
调试程序
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
DATASEGMENT
DA1DB?
DA2DW10DUP(?
)
DA3DB'ABCD'
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
MOVAX,TYPEDA1
MOVBX,SIZEDA2
MOVCX,LENGTHDA3
POPDS
HLT
CODEENDS
ENDSTART
6.下段程序完成后,AH等于什么?
INAL,5FH
TESTAL,80H
JZL1
MOVAH,0
JMPSTOP
L1:
MOVAH,0FFH
STOP:
HLT
解:
如果地址为5FH的外设输入到AL中的数据的最高位=1,则(AH)=0,否则,(AH)=0FFH。
10.编制两个通用过程,完成两位十六进制数转换成ASCII码,并将ASCII码字符显示。
(1)两位十六进制数转换成ASCII码
设两位十六进制数存放在DL中,输出的ASCII码存放在BX中。
CONPROC
PUSHAX
PUSHCX
MOVCL,4
MOVAL,DL
ANDAL,0FH
CMPAL,0AH
JNCLP1
ADDAL,30H
JMPLP2
LP1:
ADDAL,37H
LP2:
MOVBL,AL
MOVAL,DL
SHRAL,CL
ANDAL,0FH
CMPAL,0AH
JNCLP3
ADDAL,30H
JMPLP4
LP3:
ADDAL,37H
LP4:
MOVBH,AL
POPCX
POPAX
RET
CONENDP
四位十六进制数转换成ASCII码,
设四位十六进制数存放在存储器BUF1单元中,输出的ASCII码存放在存储器BUF2开始的单元中。
CONPROC
PUSHAX
PUSHCX
PUSHDX
MOVDI,OFFSETBUF2
MOVSI,OFFSETBUF1
MOVCL,4
MOVDH,4
MOVDX,[SI]
LP1:
ROLDX,CL
MOVAL,DL
ANDAL,0F
ADDAL,30H
CMPAL,3AH
JCLP2
ADDAL,07H
LP2:
MOV[DI],AL
INCDI
DECCH
JNZLP1
POPDX
POPCX
POPAX
RET
CONENDP
(2)ASCII码字符显示
设2个ASCII码字符在BX中。
DISPPROC
PUSHAX
MOVDL,BL
MOVAH,2
INT21H
MOVDL,BH
INT21H
POPAX
RET
DISPENDP
调试程序
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
DATASEGMENT
DA1DB5FH,0A4H,0C7H
DA2DB100DUP(?
)
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
MOVDL,DA1
CALLCON
CALLDISP
POPDS
HLT
CON:
PUSHAX
PUSHCX
MOVCL,4
MOVAL,DL
ANDAL,0FH
CMPAL,0AH
JNCLP1
ADDAL,30H
JMPLP2
LP1:
ADDAL,37H
LP2:
MOVBL,AL
MOVAL,DL
SHRAL,CL
ANDAL,0FH
CMPAL,0AH
JNCLP3
ADDAL,30H
JMPLP4
LP3:
ADDAL,37H
LP4:
MOVBH,AL
POPCX
POPAX
RET
DISP:
PUSHAX
MOVDL,BL
MOVAH,2
INT21H
MOVDL,BH
INT21H
POPAX
RET
CODEENDS
ENDSTART
13.将键盘上输入的一位为十六进制数转换成十进制数,在屏幕上显示。
DATASEGMENT
DATA1DB10DUP(?
)
DATA2DB10DUP(?
)
DATAENDS
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
KEY:
MOVAH,1
INT21H
ZH:
CMPAL,3AH
JAEZH1
SUBAL,30H
JMPZH2
ZH1:
SUBAL,37H
ADDAL,0
DAA
ZH2:
MOVBL,AL
ANDAL,0F0H
MOVCL,4
SHRAL,CL
ADDAL,30H
MOVBH,AL
MOVAL,BL
ANDAL,0FH
ADDAL,30H
MOVBL,AL
DISP:
MOVDL,BH
MOVAH,2
INT21H
MOVDL,BL
MOVAH,2
INT21H
POPDS
MOVAH,4CH
INT21H
HLT
CODEENDS
ENDSTART
调试程序:
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
DATASEGMENT
BUF1DB'Pleaseinputonehexadecimal(0-9,A-F):
',0DH,0AH,'$'
BUF2DB20H,20H,'Decimal(0-15):
',0DH,0AH,'$'
BUF3DB10DUP(?
)
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
MOVDX,OFFSETBUF1
MOVAH,9
INT21H
KEY:
MOVAH,1
INT21H
PUSHAX
MOVDX,OFFSETBUF2
MOVAH,9
INT21H
POPAX
ZH:
CMPAL,3AH
JAEZH1
SUBAL,30H
JMPZH2
ZH1:
SUBAL,37H
ADDAL,0
DAA
ZH2:
MOVBL,AL
ANDAL,0F0H
MOVCL,4
SHRAL,CL
ADDAL,30H
MOVBH,AL
MOVAL,BL
ANDAL,0FH
ADDAL,30H
MOVBL,AL
DISP:
MOVDL,BH
MOVAH,2
INT21H
MOVDL,BL
MOVAH,2
INT21H
POPDS
MOVAH,4CH
INT21H
HLT
CODEENDS
ENDSTART
22.编程序统计学生的数学成绩,分别归类90~99分,80~89分,70~79分,60~69分及60分以下,并将各段的人数送入内存单元中。
解:
STACKSEGMENT
DB100DUP(?
)
STACKENDS
DATASEGMENT
DATA1DB200DUP(?
)
DATA2DB100DUP(?
)
DATA3DB10DUP(?
)
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
PUSHDS
MOVAX,DATA
MOVDS,AX
XORCX,CX
KEY:
MOVSI,OFFSETDATA1
KEY1:
MOVAH,1
INT21H
CMPAL,‘$’
JZZH
INCCX
MOV[SI],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4[DATA3]
JMPTJ5
TJ1:
INC[DATA3]
JMPTJ5
TJ2:
INC1[DATA3]
JMPTJ5
TJ3:
INC2[DATA3]
JMPTJ5
TJ4:
INC3[DATA3]
TJ5:
INCDI
LOOPTJ0
POPDS
MOVAH,4CH
INT21H
HLT
CODEENDS
ENDSTART
第5章作业P194
5.PROM、EPROM、E2PROM的共同特点是什么?
它们在功能上主要不同之处在哪里?
试举例说明它们的用途。
答:
(1