📄 单片机指令(二).htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://www.onestudy.net/download/elec/dpj9.htm -->
<!-- saved from url=(0048)http://www.21icsearch.com/pmcu/dpjjx/dpjjx11.htm --><HTML><HEAD><TITLE>单片机指令(二)</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb_2312-80">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<META content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot"
name=Template></HEAD>
<BODY vLink=#800080 link=#0000ff background=""><FONT lang=ZH-CN face=宋体>
<P align=justify>单片机指令(二)</P>
<OL>
<P align=justify>
<LI>数据传递类指令
<P></P></LI></OL></FONT>
<P align=justify><FONT lang=ZH-CN face=宋体>(</FONT><FONT lang=ZH-CN
face=System>3</FONT><FONT lang=ZH-CN face=宋体>)以直接地址为目的操作数的指令</FONT></P>
<P align=justify><FONT lang=ZH-CN face=System>MOV direct,A</FONT><FONT
lang=ZH-CN face=宋体> </FONT><FONT lang=ZH-CN face=System></FONT><FONT lang=ZH-CN
face=宋体>例:</FONT> <FONT lang=ZH-CN face=System>MOV 20H,A</FONT></P><FONT
lang=ZH-CN face=System>
<P align=justify>MOV direct,Rn MOV 20H,R1</P>
<P align=justify>MOV direct1,direct2 MOV 20H,30H</P>
<P align=justify>MOV direct,@Ri MOV 20H,@R1</P>
<P align=justify>MOV direct,#data MOV 20H,#34H</P></FONT>
<P align=justify><FONT lang=ZH-CN face=宋体>(</FONT><FONT lang=ZH-CN
face=System>4</FONT><FONT lang=ZH-CN face=宋体>)以间接地址为目的操作数的指令</FONT></P>
<P align=justify><FONT lang=ZH-CN face=System>MOV @Ri,A </FONT><FONT lang=ZH-CN
face=宋体>例:</FONT><FONT lang=ZH-CN face=System>MOV @R0,A</FONT></P><FONT
lang=ZH-CN face=System>
<P align=justify>MOV @Ri,direct MOV @R1,20H</P>
<P align=justify>MOV @Ri,#data MOV @R0,#34H</P></FONT>
<P align=justify><FONT lang=ZH-CN face=宋体>(</FONT><FONT lang=ZH-CN
face=System>5</FONT><FONT lang=ZH-CN face=宋体>)十六位数的传递指令</FONT></P>
<P align=justify><FONT lang=ZH-CN face=System>MOV DPTR</FONT><FONT lang=ZH-CN
face=宋体>,</FONT><FONT lang=ZH-CN face=System>#data16</FONT></P>
<P align=justify><FONT lang=ZH-CN face=System>8051</FONT><FONT lang=ZH-CN
face=宋体>是一种</FONT><FONT lang=ZH-CN face=System>8</FONT><FONT lang=ZH-CN
face=宋体>位机,这是唯一的一条</FONT><FONT lang=ZH-CN face=System>16</FONT><FONT lang=ZH-CN
face=宋体>位立即数传递指令,其功能是将一个</FONT><FONT lang=ZH-CN face=System>16</FONT><FONT
lang=ZH-CN face=宋体>位的立即数送入</FONT><FONT lang=ZH-CN face=System>DPTR</FONT><FONT
lang=ZH-CN face=宋体>中去。其中高</FONT><FONT lang=ZH-CN face=System>8</FONT><FONT
lang=ZH-CN face=宋体>位送入</FONT><FONT lang=ZH-CN face=System>DPH</FONT><FONT
lang=ZH-CN face=宋体>,低</FONT><FONT lang=ZH-CN face=System>8</FONT><FONT
lang=ZH-CN face=宋体>位送入</FONT><FONT lang=ZH-CN face=System>DPL</FONT><FONT
lang=ZH-CN face=宋体>。例:</FONT><FONT lang=ZH-CN face=System>MOV DPTR</FONT><FONT
lang=ZH-CN face=宋体>,</FONT><FONT lang=ZH-CN face=System>#1234H</FONT><FONT
lang=ZH-CN face=宋体>,则执行完了之后</FONT><FONT lang=ZH-CN face=System>DPH</FONT><FONT
lang=ZH-CN face=宋体>中的值为</FONT><FONT lang=ZH-CN face=System>12H</FONT><FONT
lang=ZH-CN face=宋体>,</FONT><FONT lang=ZH-CN face=System>DPL</FONT><FONT
lang=ZH-CN face=宋体>中的值为</FONT><FONT lang=ZH-CN face=System>34H</FONT><FONT
lang=ZH-CN face=宋体>。反之,如果我们分别向</FONT><FONT lang=ZH-CN
face=System>DPH</FONT><FONT lang=ZH-CN face=宋体>,</FONT><FONT lang=ZH-CN
face=System>DPL</FONT><FONT lang=ZH-CN face=宋体>送数,则结果也一样。如有下面两条指令:</FONT><FONT
lang=ZH-CN face=System>MOV DPH</FONT><FONT lang=ZH-CN face=宋体>,</FONT><FONT
lang=ZH-CN face=System>#35H</FONT><FONT lang=ZH-CN face=宋体>,</FONT><FONT
lang=ZH-CN face=System>MOV DPL</FONT><FONT lang=ZH-CN face=宋体>,</FONT><FONT
lang=ZH-CN face=System>#12H</FONT><FONT lang=ZH-CN face=宋体>。则就相当于执行了</FONT><FONT
lang=ZH-CN face=System>MOV DPTR</FONT><FONT lang=ZH-CN face=宋体>,</FONT><FONT
lang=ZH-CN face=System>#3512H</FONT><FONT lang=ZH-CN face=宋体>。</FONT></P><FONT
lang=ZH-CN face=宋体>
<P align=justify>综合练习:</P></FONT>
<OL><FONT lang=ZH-CN face=宋体>
<P align=justify>
<LI>给出每条指令执行后的结果
<P></P></FONT>
<TABLE cellSpacing=1 cellPadding=7 width=607 border=1>
<TBODY>
<TR>
<TD vAlign=top width="28%" height=113><FONT lang=ZH-CN face=System>
<P align=justify>MOV 23H,#30H</P>
<DIR>
<DIR>
<P align=justify>MOV 12H,#34H</P>
<P align=justify>MOV R0,#23H</P>
<P align=justify>MOV R7,#22H</P>
<P align=justify>MOV R1,12H</P>
<P align=justify>MOV A,@R0</P>
<P align=justify>MOV 34H,@R1</P></DIR></DIR></FONT></TD>
<TD vAlign=top width="22%" height=113><FONT lang=ZH-CN face=System>
<P align=justify>(23h)=30h</P>
<DIR>
<DIR>
<P align=justify>(12h)=34h</P>
<P align=justify>(R0)=23H</P>
<P align=justify>(R7)=22H</P>
<P align=justify>(R1)=12H</P>
<P align=justify>(A)=30H</P>
<P align=justify>(34H)=34H</P></DIR></DIR></FONT></TD>
<TD vAlign=top width="28%" height=113><FONT lang=ZH-CN face=System>
<P align=justify>MOV 45H,34H</P>
<DIR>
<DIR>
<P align=justify>MOV DPTR,#6712H</P>
<P align=justify>MOV 12H,DPH</P>
<P align=justify>MOV R0,DPL</P>
<P align=justify>MOV A,@R0</P></DIR></DIR></FONT></TD>
<TD vAlign=top width="22%" height=113><FONT lang=ZH-CN face=System>
<P align=justify>(45H)=34H</P>
<DIR>
<DIR>
<P align=justify>(DPTR)=6712H</P>
<P align=justify>(12H)=67H</P>
<P align=justify>(R0)=12H</P>
<P align=justify>(A)=67H</P></DIR></DIR></FONT></TD></TR></TBODY></TABLE>
<P align=justify><FONT lang=ZH-CN face=宋体>说明:用括号括起来代表内容,如(</FONT><FONT
lang=ZH-CN face=System>23H</FONT><FONT lang=ZH-CN face=宋体>)则代表内部</FONT><FONT
lang=ZH-CN face=System>RAM23H</FONT><FONT lang=ZH-CN
face=宋体>单元中的值,(</FONT><FONT lang=ZH-CN face=System>A</FONT><FONT lang=ZH-CN
face=宋体>)则代表累加器</FONT><FONT lang=ZH-CN face=System>A</FONT><FONT lang=ZH-CN
face=宋体>单元中的值。</FONT></P><FONT lang=ZH-CN face=宋体>
<P align=justify></P>
<LI>上机练习:
<P></P></FONT></LI></OL>
<OL><FONT lang=ZH-CN face=宋体>
<P align=justify></FONT>
<LI><FONT lang=ZH-CN face=宋体>进入</FONT><FONT lang=ZH-CN
face=System>DOS</FONT><FONT lang=ZH-CN face=宋体>状态,进入</FONT><FONT lang=ZH-CN
face=System>WAVE</FONT><FONT lang=ZH-CN face=宋体>所在的目录,例</FONT><FONT lang=ZH-CN
face=System>D:\WAVE</FONT><FONT lang=ZH-CN face=System>
<P></P></FONT><FONT lang=ZH-CN face=宋体>
<P align=justify></FONT></P>
<LI><FONT lang=ZH-CN face=宋体>键入</FONT><FONT lang=ZH-CN
face=System>MCS51</FONT><FONT lang=ZH-CN face=宋体>,出现如下画面</FONT><FONT
lang=ZH-CN face=宋体>
<P></P></FONT><FONT lang=ZH-CN face=System>
<P align=justify><IMG height=303 src="单片机指令(二).files/1101.gif"
width=564></P></FONT><FONT lang=ZH-CN face=宋体>
<P align=justify></FONT></P>
<LI><FONT lang=ZH-CN face=宋体>按</FONT><FONT lang=ZH-CN
face=System>File->Open</FONT><FONT lang=ZH-CN face=宋体>,出现对话框后,在</FONT><FONT
lang=ZH-CN face=System>Name</FONT><FONT lang=ZH-CN
face=宋体>处输入一个文件名(见图</FONT><FONT lang=ZH-CN face=System>2</FONT><FONT
lang=ZH-CN face=宋体>),如果是下面列表中已存在的,则打开这个文件,如果不存在这个文件,则新建一个文件(见图</FONT><FONT
lang=ZH-CN face=System>3</FONT><FONT lang=ZH-CN face=宋体>)</FONT><FONT
lang=ZH-CN face=宋体>
<P></P></FONT><FONT lang=ZH-CN face=System>
<P align=justify><IMG height=303 src="单片机指令(二).files/1102.gif" width=560><IMG
height=230 src="单片机指令(二).files/1103.gif" width=351></P></FONT><FONT lang=ZH-CN
face=宋体>
<P align=justify></FONT></P>
<LI><FONT lang=ZH-CN face=宋体>在空白处将上面的程序输入。见图</FONT><FONT lang=ZH-CN
face=System>4</FONT><FONT lang=ZH-CN face=宋体>。用</FONT><FONT lang=ZH-CN
face=System>ALT+A</FONT><FONT lang=ZH-CN face=宋体>汇编通过。用</FONT><FONT lang=ZH-CN
face=System>F8</FONT><FONT lang=ZH-CN
face=宋体>即可单步执行,在执行过程中注意观察屏幕左边的工作寄存器及</FONT><FONT lang=ZH-CN
face=System>A</FONT><FONT lang=ZH-CN face=宋体>累加器中的值的变化。</FONT><FONT lang=ZH-CN
face=宋体>
<P></P></FONT><FONT lang=ZH-CN face=System>
<P align=justify><IMG height=302 src="单片机指令(二).files/1104.gif"
width=560></P></FONT><FONT lang=ZH-CN face=宋体>
<P align=justify></FONT></P>
<LI><FONT lang=ZH-CN face=宋体>内存中值的变化在此是看不到的,可以用如下方法观察(看图</FONT><FONT
lang=ZH-CN face=System>5</FONT><FONT lang=ZH-CN face=宋体>):将鼠标移到</FONT><FONT
lang=ZH-CN face=System>DATA</FONT><FONT lang=ZH-CN
face=宋体>,双击,则光标进入此行,此时可以键盘上的上下光标键上下翻动来观察内存值的变化。本行的最前面</FONT><FONT lang=ZH-CN
face=System>DATA</FONT><FONT lang=ZH-CN
face=宋体>后面的数据代表的是“一段”的开始地址,如现在为</FONT><FONT lang=ZH-CN
face=System>20H</FONT><FONT lang=ZH-CN face=宋体>,再看屏幕的最上方,数字从</FONT><FONT
lang=ZH-CN face=System>0</FONT><FONT lang=ZH-CN face=宋体>到</FONT><FONT
lang=ZH-CN face=System>F</FONT><FONT lang=ZH-CN
face=宋体>,显示两者相加就等于真正的地址值,如现在图上所示的内存</FONT><FONT lang=ZH-CN
face=System>20H</FONT><FONT lang=ZH-CN face=宋体>、</FONT><FONT lang=ZH-CN
face=System>21H</FONT><FONT lang=ZH-CN face=宋体>、</FONT><FONT lang=ZH-CN
face=System>22H</FONT><FONT lang=ZH-CN face=宋体>、</FONT><FONT lang=ZH-CN
face=System>23H</FONT><FONT lang=ZH-CN face=宋体>中的值分别是</FONT><FONT lang=ZH-CN
face=System>FBH </FONT><FONT lang=ZH-CN face=宋体>、</FONT><FONT lang=ZH-CN
face=System>0EH</FONT><FONT lang=ZH-CN face=宋体>、</FONT><FONT lang=ZH-CN
face=System>E8H</FONT><FONT lang=ZH-CN face=宋体>、</FONT><FONT lang=ZH-CN
face=System>30H</FONT><FONT lang=ZH-CN face=宋体>。</FONT><FONT lang=ZH-CN
face=宋体>
<P></P></FONT><FONT lang=ZH-CN face=System>
<P align=justify></FONT></P>
<LI><FONT lang=ZH-CN face=System><IMG height=431 src="单片机指令(二).files/1105.gif"
width=694></FONT><FONT lang=ZH-CN
face=宋体>当运行完程序后,即进入它的反汇编区,不是我们想要的东西。为了再从头开始,可以用</FONT><FONT lang=ZH-CN
face=System>CTRL+F2</FONT><FONT lang=ZH-CN face=宋体>功能键复位</FONT><FONT
lang=ZH-CN face=System>PC</FONT><FONT lang=ZH-CN
face=宋体>值。注意此时不会看到原来的窗口,为看到原来的窗口,请用</FONT><FONT lang=ZH-CN
face=System>ALT+4</FONT><FONT lang=ZH-CN face=宋体>或</FONT><FONT lang=ZH-CN
face=System>ALT+5</FONT><FONT lang=ZH-CN
face=宋体>等来切换。当然以上操作也可以菜单进行。</FONT><FONT lang=ZH-CN
face=System>CTRL+F2</FONT><FONT lang=ZH-CN face=宋体>是程序复位,用</FONT><FONT
lang=ZH-CN face=System>RUN</FONT><FONT lang=ZH-CN face=宋体>菜单。窗口用</FONT><FONT
lang=ZH-CN face=System>WINDOWS</FONT><FONT lang=ZH-CN face=宋体>菜单。</FONT> <FONT
lang=ZH-CN face=宋体>
<P></P></FONT></LI></OL><FONT lang=ZH-CN face=宋体>
<DIR>
<P
align=justify>此次大家就用用熟这个软件吧,说实话,我并不很喜欢它,操作起来不方便,但给我的机器只能上这个,没办法,下次再给网友单独介绍一个好一点的吧。</P></DIR>
<P align=center><A href="http://www.onestudy.net/"><FONT
face=黑体>返回“一学网</FONT><FONT face="Times New Roman" color=#000000> </FONT><FONT
face="Times New Roman"><FONT color=#000000>www.</FONT><FONT
color=#ff0000>one</FONT><FONT color=#008000>study</FONT>.net</FONT><FONT
face=黑体> ”首页</FONT></A></P></FONT></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -