📄 the04.htm
字号:
WHILE i<count</p>
<p class="lh15" >
MOVLW i</p>
<p class="lh15" >
i=i+1</p>
<p class="lh15" >
ENDW</p>
<p class="lh15">注:VARIABLE也是一条定义变量的伪指令,和EQU及SET不同的是它不要求变量在定义时必须赋值给初值,如上例中的变量i。关于这条伪指令不再赘述。</p>
<p class="lh15">四、宏定义伪指令 </p>
<p class="lh15" > 1. MACRO——宏定义命令。宏是一段指令,可以插在源程序中。宏必须事先定义好,宏之间可以互相调用,也可以自己递归调用。宏本身不会产生代码,只是在调用它时把宏体插入源程序,这点和子程序调用有本质不同,即宏并不会节省程序空间,它主要的好处是令程序书写简洁明了。</p>
<p class="lh15" > 格式: <标号>
MACRO〔<参数1>…<参数N>〕</p>
<p class="lh15" >
(宏体)</p>
<p class="lh15" > ENDM</p>
<p class="lh15" >
例:GET MACRO X,Y,Z</p>
<p class="lh15" >
MOVWF X</p>
<p class="lh15" >
Y</p>
<p class="lh15" >
Z MOVLW 10</p>
<p class="lh15" >
GOTO Z</p>
<p class="lh15" >
ENDM</p>
<p class="lh15" > 宏调用可以下为:</p>
<p class="lh15" >
…</p>
<p class="lh15" >
GET F0,(INCF F17,W), ENTRY</p>
<p class="lh15" >
…</p>
<p class="lh15" > 则汇编后这句宏调用产生的源代码为:</p>
<p class="lh15" >
GET F0,(INF17,W), ENTRY</p>
<p class="lh15" >
+ MOVWF F0</p>
<p class="lh15" >
+ INCF F17,W</p>
<p class="lh15" >
+ ENTRY MOVLW 10</p>
<p class="lh15" >
+ GOTO ENTRY</p>
<p class="lh15" > 前面带+号表示是宏体中定义的程序。 </p>
<p class="lh15" ><b><font size="2">§4.4 错误/警告信息 </font></b> </p>
<p class="lh15">MPASM汇编一个源程序后,可以产生一个.ERR文件,该文件用来存放汇编后可能产生的错误或警告信息。必须强调的是错误信息(Error)是指出源程序中出现“致命”(fatal)的错误,用户必须修改直至汇编后Errors=
0。而警告信息(Warnings)是指出源程序中可能有问题的地方,但并不一定是“致命”错误,只是提醒用户去注意这些被警告的地方。如果用户可以确认无误,便可以不理会产生的Warnings。</p>
<p class="MsoNormalIndent"><span class="lh15">一、错误信息</span></p>
<p class="lh15" > 1.Address exceeds maximum
limit avaiable</p>
<p class="lh15" > 程序存储器地址溢出(超出)有效范围。</p>
<p class="lh15" > 2.Attempt to redefine reserved
word</p>
<p class="lh15" > MPASM中的保留字如“END”、“ERROR”、“HIGH”、“LOW”和“PAGE”被重定义,用户必须避免再将其用做标号或变量。</p>
<p class="lh15" > 3.Branch or jump out of
range</p>
<p class="lh15" > 程序跳转指令如“GOTO”、“CALL”等超出规定的范围。</p>
<p class="lh15" > 4.Couldn't open…</p>
<p class="lh15" > TMPASM 不能打开“.OBJ”、“.map”、“.Hex”、“.Err”、“.Lst”或“.ref”文件。一般是电脑已没有足够的磁盘空间。</p>
<p class="lh15" > 5.Couldn't open source file…</p>
<p class="lh15" > 汇编的源程序文件不存在。</p>
<p class="lh15" > 6.Duplicate lable or redefininy
symbol that cannot be redefined</p>
<p class="lh15" > 标号或变量名重复定义。</p>
<p class="lh15" > 7.Error in parameter</p>
<p class="lh15" > 参数错误。</p>
<p class="lh15" > 8.Expected…</p>
<p class="lh15" > 源程序行有错。</p>
<p class="lh15" > 9.File not found</p>
<p class="lh15" > 指定的文件找不到。</p>
<p class="lh15" > 10.Illegal argument</p>
<p class="lh15" > 非法参数。</p>
<p class="lh15" > 11.Illegal condition</p>
<p class="lh15" > IF语句中的条件符号出错。</p>
<p class="lh15" > 12.Illegal condition,EOF encountered
before END or conditional end directive</p>
<p class="lh15" > IF、WHILE或MACRO语句中缺少相应的ENDIF、ENDW和ENDM。</p>
<p class="lh15" > 13.Illegal conditional compile</p>
<p class="lh15" > IF/ELSE/ENDIF结构书写有错。</p>
<p class="lh15" > 14.Illegal character…in label…</p>
<p class="lh15" > 在标号字符中出现非法字符。合法的字符是“-”、“·”、“A”~“Z”、“a”~“z”、“0”~“9”。</p>
<p class="lh15" > 15.Illegal digit</p>
<p class="lh15" > 非法数字。如在十进制数中出现十六进制符等。</p>
<p class="lh15" > 16.Illegal opcode</p>
<p class="lh15" > 非法操作数。</p>
<p class="lh15" > 17.Include file not found</p>
<p class="lh15" > Include 指令中的文件找不到。</p>
<p class="lh15" > 18.Include files nested too cleep</p>
<p class="lh15" > Include 文件嵌套太多。Include
文件嵌套最多的为5重。</p>
<p class="lh15" > 19.Macro name missing</p>
<p class="lh15" > 缺少宏定义名称。</p>
<p class="lh15" > 20.Marco nested too deep</p>
<p class="lh15" > 宏体嵌套太多。宏体中最多可嵌套8重。</p>
<p class="lh15" > 21.Missing arguments</p>
<p class="lh15" > 缺少参数,如指令中缺少操作数等。</p>
<p class="lh15" > 22.Missing terminator</p>
<p class="lh15" > 缺少配对符,如各种括号“)”、“〕”、“}”或“·”、空格等。</p>
<p class="lh15" > 23.Nested forward reference not
allowed.</p>
<p class="lh15" > 使用未定义的标号、变量、宏定义等。或者是MPASM不能确认标号的类型,一般由标号重复定义引起。</p>
<p class="lh15" > 24.Out of memory</p>
<p class="lh15" > 程序空间溢出。</p>
<p class="lh15" > 25.Overwriting previous address
contents</p>
<p class="lh15" > 程序空间重复使用。一般由地址定义指令ORG定义不当引起。</p>
<p class="lh15" > 26.Processor type is undefined</p>
<p class="lh15" > 单片机芯片型号未定义。要么在源程序中未定义,要么在使用MPASM汇编时未定义。</p>
<p class="lh15" > 27.Processor type previously defined</p>
<p class="lh15" > 单片机芯片型号重复定义。</p>
<p class="lh15" > 28.Symbol table full</p>
<p class="lh15" > 符号表溢出。</p>
<p class="lh15" > 29.Temp file creation error</p>
<p class="lh15" > MPASM在汇编过程中会使用一些临时性文件。这个错一般是电脑磁盘满或读写出错引起。</p>
<p class="lh15" > 30.Too many arguments</p>
<p class="lh15" > 参数太多,如指令操作符带过多的操作数。</p>
<p class="lh15" > 31.Undefined argument</p>
<p class="lh15" > 使用了未定义的参数。</p>
<p class="lh15" > 32.Unknow error</p>
<p class="lh15" > MPASM碰到未知的错,这种情况一般很少发生。</p>
<p class="lh15" > 33.While failed to terminate within
256 iterationg</p>
<p class="lh15" > While 语句中没有结束的条件产生。 </p>
<p class="MsoNormalIndent"><span class="lh15">二、警告信息</span></p>
<p class="lh15" > 1.Addresses above 32K not
currently supported. Using MaxRom.</p>
<p class="lh15" > MPASM目前只允许源程序使用8000H(32K)以下的程序地址。将来可以增加到64K。</p>
<p class="lh15" > 2.Argument out of rauge,least
significant bits used.</p>
<p class="lh15" > 参数超出所允许的范围值。MPASM一般会把超出的值自动截为认可的最大值。</p>
<p class="lh15" > 3.Crossing page boundary--ensure
page blts are set</p>
<p class="lh15" > MPASM通知你程序跨页面了,建议你确认相应的页面位是否已经设置了。</p>
<p class="lh15" > 4.…Is not currently supported</p>
<p class="lh15" > 使用了MPASM尚未支持的指令。</p>
<p class="lh15" > 5.…Not a single byte quantity</p>
<p class="lh15" > 使用了超出8位的数值。</p>
<p class="lh15" > 6.This number is being treated
as a binary representation</p>
<p class="lh15" > MPASM碰到不知是二进制或十六进制的值,如b
0101。这时MPASM都会把它当做二进制处理。上例如果要表示16进制,应写成ox b0101或H'b0101'。</p>
<p class="lh15" ><b><font size="2">§4.5 使用MPASM来汇编PIC12C5XX的问题</font></b></p>
<p class="lh15">如果用户手中的MPASM版本是97年前的老版本,则在Processor Type中寻不到PIC12C508/509,怎么办?不要紧,因为PIC12C5XX和PIC16C5X的指令是完全一样的。所以如果手中的MPASM是老版本,可以用如下方法来操作:</p>
<div align="center">
<table border="1" cellspacing="0" cellpadding="0" >
<tr style="height:19.5pt">
<td width="119" class="lh15" > 汇编对象 </td>
<td width="119" class="lh15" > Processor Type </td>
</tr>
<tr style="height:19.5pt">
<td width="119" class="lh15" > PIC12C508 </td>
<td width="119" class="lh15" > 16C54 </td>
</tr>
<tr style="height:19.5pt">
<td width="119" class="lh15" > PIC12C509 </td>
<td width="119" class="lh15" > 16C58 </td>
</tr>
</table>
</div>
<p> </td>
</tr>
</table>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"> </td>
<td> </td>
</tr>
</table>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#990000">
<td height="1" width="634"></td>
</tr>
<tr align="right">
<td height="6"></td>
</tr>
<tr align="right">
<td><font color="#990000" size="2">[ <a href="index.htm">返回</a> ]</font>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -