⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 freescale 汇编语言源程序标准.htm

📁 编程规范大全
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<TBODY>
<TR bgColor=#f8f8f8>
<TD><STRONG><FONT color=#ff0000>博客信息</FONT></STRONG></TD></TR>
<TR bgColor=#ffffff>
<TD>
<P><FONT color=#ff0000>blog名称:匠人的百宝箱<br>日志总数:1837<br>评论数量:707<br>留言数量:24<br>访问次数:1352231<br>建立时间:2005年5月18日</FONT></P>
<P align=center><FONT size=3><A href="http://cxjr.21ic.org/" target=_blank><IMG style="BORDER-LEFT-COLOR: #000000; BORDER-BOTTOM-COLOR: #000000; BORDER-TOP-COLOR: #000000; BORDER-RIGHT-COLOR: #000000" src="http://blog.21ic.org/uploadfile-/20051217161245384.gif" border=0></A></FONT></P></TD></TR></TBODY></TABLE></P>
<TD vAlign=top align=middle width=660>
<P align=left>
<TABLE style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellSpacing=1 cellPadding=3 width="100%" bgColor=#cccccc border=0>
<TBODY>
<TR bgColor=#f8f8f8>
<TD><STRONG><FONT color=#ff0000>广告(2号位)</FONT></STRONG></TD></TR>
<TR bgColor=#ffffff>
<TD>
<DIV align=center>
<ADDRESS>&nbsp;<A href="http://www.3gmcu.com/" target=_blank><IMG style="BORDER-LEFT-COLOR: #000000; BORDER-BOTTOM-COLOR: #000000; BORDER-TOP-COLOR: #000000; BORDER-RIGHT-COLOR: #000000" src="http://blog.21ic.org/uploadfile-/2005122820932375.gif" border=0></A></ADDRESS></DIV></TD></TR></TBODY></TABLE></P>
<P align=left>
<TABLE style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellSpacing=1 cellPadding=3 width="100%" bgColor=#cccccc border=0>
<TBODY>
<TR bgColor=#f8f8f8>
<TD><STRONG><FONT color=#ff0000>酷贴推荐 <FONT color=#ff0000>[</FONT><A href="http://blog.21ic.org/more.asp?name=cxjr&amp;id=7437" target=_blank><U><FONT color=#ff0000>更多…… </FONT></U></A><FONT color=#ff0000>]</FONT></FONT></STRONG></TD></TR>
<TR bgColor=#ffffff>
<TD>
<P align=left>
<TABLE borderColor=#cccccc cellSpacing=2 cellPadding=3 width="100%" bgColor=#ffffff border=1>
<TBODY>
<TR>
<TD>
<P align=center>&nbsp;[<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=16591"><U><FONT style="BACKGROUND-COLOR: #ffff00" color=#ff0000>岁月如歌——记匠人的百宝箱博客开通一周年</FONT></U></A>] [<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=17379"><U><FONT color=#0000ff>事件驅動觀念</FONT></U></A>] [<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=17377"><U><FONT color=#0000ff>单片机程序设计中运用事件驱动机制</FONT></U></A>]</P></TD>
<TR>
<TD>
<P align=center>[<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=18941"><U><FONT color=#0000ff>计算机族必喝的健康饮料</FONT></U></A>] [<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=18714"><U><FONT color=#0000ff>男人·女人·电脑</FONT></U></A>] [<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=18713"><U><FONT color=#0000ff>学编程的人不能不看的好文章</FONT></U></A>] [<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=18742"><U><FONT color=#0000ff>PIC机与MCS-51的区别</FONT></U></A>]</P></TD>
<TR>
<TD>
<P align=center>[<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=19794"><U><FONT color=#0000ff>一种软件去除键抖动的方法</FONT></U></A>] [<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=19752"><U><FONT color=#0000ff>司马光,你干嘛砸缸?</FONT></U></A>] [<A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=19748"><U><FONT color=#0000ff>编码规范</FONT></U></A>]&nbsp;</P></TD>
<TR>
<TD>
<P align=center><FONT color=#ff0000>调查:[</FONT><A href="http://21icbbs.com/club/vote/showvote.asp?id=98" target=_blank><U><FONT color=#ff0000>您认为《匠人的百宝箱》如何?</FONT></U></A><FONT color=#ff0000>] [</FONT><A href="http://21icbbs.com/club/vote/showvote.asp?id=129" target=_blank><U><FONT color=#ff0000>您最喜欢《匠人的百宝箱》中哪个栏目?</FONT></U></A><FONT color=#ff0000>] [</FONT><A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=18993"><U><FONT color=#ff0000>请网友来评选最佳队员专栏</FONT></U></A><FONT color=#ff0000>]</FONT>&nbsp;</P></TD></TR></TBODY></TABLE></P></TD></TR></TBODY></TABLE></P>
<P align=left>
<TABLE style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellSpacing=1 cellPadding=3 width="100%" bgColor=#cccccc border=0>
<TBODY>
<TR bgColor=#f8f8f8>
<TD>
<P align=left><FONT color=#ff0000 size=4><STRONG><img src=images/face/1.gif ><a href=blog.asp?name=cxjr&subjectid=66>[编程技巧]<a href=more.asp?name=cxjr&id=3562>Freescale&nbsp;汇编语言源程序标准</a></STRONG></FONT><BR>程序匠人&nbsp;&nbsp;&nbsp; 2005-9-29 13:14:00&nbsp;&nbsp;&nbsp;&nbsp; <a href=more.asp?name=cxjr&id=3562>阅读全文(932)</a> | <a href=more.asp?name=cxjr&id=3562#comment>回复(0)</a> | <a href=showtb.asp?id=3562 target=_blank>引用(0)</a><BR><FONT face=宋体 size=4><STRONG>[</STRONG></FONT><A href="http://blog.21ic.org/more.asp?name=cxjr&amp;id=6250" target=_blank><FONT face=宋体 color=#ff0000 size=4><STRONG>广告8号位</STRONG></FONT></A><FONT face=宋体 size=4><STRONG>]&nbsp;[</STRONG></FONT><A href="http://blog.21ic.org/more.asp?name=cxjr&amp;id=7705"><U><FONT style="BACKGROUND-COLOR: #000000" face=宋体 color=#ffffff size=4><STRONG>免责声明</STRONG></FONT></U></A><FONT face=宋体 size=4><STRONG>] [</STRONG><A href="http://blog.21ic.com/more.asp?name=cxjr&amp;id=18993"><U><FONT style="BACKGROUND-COLOR: #ffff00" color=#ff0000 size=3><STRONG>请网友来评选最佳队员专栏!</STRONG></FONT></U></A><STRONG>]</STRONG></FONT></P></TD></TR>
<TR bgColor=#ffffff>
<TD height=0>
<DIV align=left><P>Freescale 汇编语言源程序标准<BR>------------------------------------------------------<BR>此标准包括:<BR>&nbsp; 行的长度限制<BR>&nbsp; 可接受的字符和字符格式<BR>&nbsp; 源程序列的分配<BR>&nbsp; 注释格式<BR>-------------------------------------------------------<BR>行的长度:<BR>&nbsp;&nbsp; 为了便于阅读和打印,Freescale使用mono-spaced字体,这种字体每个字符宽度相等.字体大小是9 point;最大行长为70个字符.<BR>示例如下:<BR><FONT face="Courier New">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<BR>;234567890123456789012345678901234567890123456789012345678901234567890<BR>asc2hex:&nbsp;&nbsp;&nbsp; bsr&nbsp;&nbsp; ishex&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;check for valid hex # first<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bne&nbsp;&nbsp; dunA2asc&nbsp;&nbsp;&nbsp; ;if not just return<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmp&nbsp;&nbsp; #'9'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;check for A-F ($41-$46)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bls&nbsp;&nbsp; notA2F&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;skip if not A-F</FONT><BR>列表输出文件示例如下:<BR><FONT face=Courier>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9<BR>;23456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123<BR>&nbsp; 551 C1D7 AD EA&nbsp;&nbsp;&nbsp;&nbsp; asc2hex:&nbsp;&nbsp;&nbsp; bsr&nbsp;&nbsp; ishex&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;check for valid hex # first<BR>&nbsp; 552 C1D9 26 0A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bne&nbsp;&nbsp; dunA2asc&nbsp;&nbsp;&nbsp; ;if not just return<BR>&nbsp; 553 C1DB A1 39&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmp&nbsp;&nbsp; #'9'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;check for A-F ($41-$46)<BR>&nbsp; 554 C1DD 23 02&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bls&nbsp;&nbsp; notA2F&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;skip if not A-F<BR></FONT>从以上可以看出列宽最大到93字符,因为列表输出文件并不能给读者提供更多的有用信息,因此Freescale最大用到每行93字符.<BR>-----------------------------------------------------------<BR>避免使用TAB字符<BR>&nbsp;&nbsp;&nbsp; TAB字符在不同的字处理软件中有不同的含义,当把源文件提交给其它文档时可能会出现问题,所以要避免使用TAB,而用多个空格代替.<BR>-----------------------------------------------------------<BR>源程序列分配<BR>&nbsp;&nbsp; 源程序由标号,助记符,操作数和注释组成一行;<BR>&nbsp;&nbsp; 标号在第1列开始<BR>&nbsp;&nbsp; 指令助记符在第13列开始<BR>&nbsp;&nbsp; 操作数在19列开始<BR>&nbsp;&nbsp; 注释在31列开始;如果操作数超过了30列,注释必须和操作数的最后一个字符分开1到2个空格.<BR>&nbsp;&nbsp; 如果一个标号超过11个字符,就应该另起一行,并在31列做注释.短标号也可以另起一行来突出它,这经常用在一个子程序开始处.见图3<BR><FONT face=Courier>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<BR>;234567890123456789012345678901234567890123456789012345678901234567890<BR>label:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mne&nbsp;&nbsp; operand&nbsp;&nbsp;&nbsp;&nbsp; ;comment<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; brset very,long,operand&nbsp;&nbsp; ;comment can’t start in col 31<BR>veryLongLabel:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;long label on separate line<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;instruction with no operands<BR>short:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;short label may use a separate line<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mne operand&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;code to which ‘short’ refers</FONT><BR>-----------------------------------------------------------<BR>大写和小写字符<BR>&nbsp;&nbsp; 源程序中协调一致的大小写可以增强可读性,并使程序变得容易理解.<BR>&nbsp;&nbsp; 标号<BR>&nbsp;&nbsp; 标号可以混和使用大小写,但无论在哪儿引用它都应该严格匹配其初始定义.<BR>&nbsp;&nbsp; 指令助记符<BR>&nbsp;&nbsp; 指令助记符,汇编指示和预处理应当使用小写字符.尽管他们可以使用大写字符,但是输入时要敲shift键,而且大写字符使读者变得不能专心阅读.<BR>&nbsp;&nbsp; 各种各样得文档中指令使用大写字符仅仅是为了突出他们.有经验得程序员使用小写字符不但容易输入而且容易阅读.<BR>寄存器和位<BR>Freescale的头文件中使用大写字符定义寄存器和位.位的定义有两种方法位号(0-7)和位屏蔽码.位操作指令使用位号;逻辑操作指令使用屏蔽码方式.屏蔽码在位号前面加一个小写字母m前缀.示例见图4<BR><FONT face=Courier>PTAD:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; $00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;I/O port A data register<BR>; bit numbers for use in BCLR, BSET, BRCLR, and BRSET<BR>PTAD7:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;bit #7<BR>PTAD6:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;bit #6<BR>PTAD5:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;bit #5<BR>PTAD4:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;bit #4<BR>PTAD3:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;bit #3<BR>PTAD2:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;bit #2<BR>PTAD1:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;bit #1<BR>PTAD0:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;bit #0<BR>; bit position masks<BR>mPTAD7:&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; %10000000&nbsp;&nbsp; ;port A bit 7<BR>mPTAD6:&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; %01000000&nbsp;&nbsp; ;port A bit 6<BR>mPTAD5:&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; %00100000&nbsp;&nbsp; ;port A bit 5<BR>mPTAD4:&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; %00010000&nbsp;&nbsp; ;port A bit 4<BR>mPTAD3:&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; %00001000&nbsp;&nbsp; ;port A bit 3<BR>mPTAD2:&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; %00000100&nbsp;&nbsp; ;port A bit 2<BR>mPTAD1:&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; %00000010&nbsp;&nbsp; ;port A bit 1<BR>mPTAD0:&nbsp;&nbsp;&nbsp;&nbsp; equ&nbsp;&nbsp; %00000001&nbsp;&nbsp; ;port A bit 0<BR></FONT>-----------------------------------------------------------<BR>标号<BR>&nbsp;&nbsp; 标号可以混和使用大小写,但避免使用下划线,我们推荐使用大写字符做为多字符标号的分界.例如:VeryLongLabel代替ery_long_label<BR>&nbsp;&nbsp; 标号定义并加一个冒号,尽管有很多编译器不需要这个冒号.</P>
<P>文件和子程序头<BR>&nbsp;&nbsp;&nbsp; 文件和子程序前面需要一个块来说明他的用途和目的,称为头<BR>&nbsp;&nbsp;&nbsp; 图5是典型的文件头<BR><FONT face="Courier New">;********************************************************************************************<BR>;* Title: 9S08GB60_v1r2.equ&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (c) FREESCALE Inc. 2003 All rights reserved.<BR>;********************************************************************************************<BR>;* Author: Jim Sibigtroth - Freescale TSPG<BR>;*<BR>;* Description: Register and bit name definitions for 9S08GB60<BR>;*<BR>;* Documentation: 9S08GB60 family Data Sheet for register and bit explanations<BR>;* HCS08 Family Reference Manual (HCS08RM1/D) appendix B for explanation of equate files<BR>;*<BR>;* Include Files: none<BR>;*<BR>;* Assembler: Metrowerks Code Warrior 3.0 (pre-release)<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or P&amp;E Microcomputer Systems - CASMS08 (beta v4.02)<BR>;*<BR>;* Revision History:<BR>;* Rev #&nbsp; Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Who&nbsp;&nbsp;&nbsp;&nbsp; Comments<BR>;* ----- ----------- ------ --------------------------------------------<BR>;* 1.2&nbsp;&nbsp; 24-Apr-03&nbsp;&nbsp; J-Sib&nbsp; correct minor typos in comments<BR>;* 1.1&nbsp;&nbsp; 21-Apr-03&nbsp;&nbsp; J-Sib&nbsp; comments and modify for CW 3.0 project<BR>;* 1.0&nbsp;&nbsp; 15-Apr-03&nbsp;&nbsp; J-Sib&nbsp; Release version for 9S09GB60<BR>;********************************************************************************************</FONT></P>
<P>&nbsp;&nbsp;&nbsp; 其中有些是必须的,有些可以省略<BR>&nbsp;&nbsp;&nbsp; 文件名:必须,包括文件名和后缀<BR>&nbsp;&nbsp;&nbsp; 版权声明:必须<BR>&nbsp;&nbsp;&nbsp; 作者:必须,有些文件可能重复使用数年,有时需要帮助时可以联系他们<BR>&nbsp;&nbsp;&nbsp; 描述:必须,但仅是摘要,更多信息应该在一个单独的文件中<BR>&nbsp;&nbsp;&nbsp; 文档:另外一个文件,她是对这个文件的详细说明<BR>&nbsp;&nbsp;&nbsp; 包含文件:需要时必须<BR>&nbsp;&nbsp;&nbsp; 汇编器:汇编器的厂商和版本,非常重要<BR>&nbsp;&nbsp;&nbsp; 版本历史:提供何时,何人,哪个文件被修改等信息</P>
<P>&nbsp;&nbsp;&nbsp; 图6是子程序头模板,可以根据子程序的复杂程度适当增减<BR><FONT face=Courier>;******************************************************************<BR>;* RoutineName - expanded name or phrase describing purpose<BR>;* Brief description, typically a few lines explaining the<BR>;* purpose of the program.<BR>;*<BR>;* I/O: Explain what is expected and what is produced<BR>;*<BR>;* Calling Convention: How is the routine called?<BR>;*<BR>;* Stack Usage: (when needed) When a routine has several variables<BR>;* on the stack, this section describes the structure of the<BR>;* information.<BR>;*<BR>;* Information about routines that are called and any registers<BR>;* that get destroyed. In general, if some registers are pushed at<BR>;* the beginning and pulled at the end, it is not necessary to<BR>;* describe this in the routine header.<BR>;******************************************************************</FONT></P>
<P><BR><FONT face="Courier New">;******************************************************************<BR>;* GetSRec - retrieve one S-record via SCI1<BR>;*&nbsp; Terminal program should delay after &lt;cr&gt; to allow programming<BR>;*&nbsp; recommended delay after &lt;cr&gt; is TBDms, no delay after chars.<BR>;*&nbsp; Only header (S0), data (S1), and end (S9) records accepted<BR>;*<BR>;* Calling Convention:<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ais&nbsp;&nbsp;&nbsp; #-bufferLength ;# of data bytes + 4 (typ.36)<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jsr&nbsp;&nbsp;&nbsp; GetSRec&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;read S-record onto stack<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bne&nbsp;&nbsp;&nbsp; error&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;Z=0 means record bad<BR>;*;<BR>;*; 'bufferLength' is defined in calling program not in this<BR>;*; subroutine, calling routine must also deallocate buffer space<BR>;*; after processing the information that was returned on the stack<BR>;*;<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ais #bufferLength ;deallocate buffer space<BR>;*<BR>;* Returns: all but CCR Z-bit returned on stack (see stack map)<BR>;*&nbsp;&nbsp; CCR Z-bit = 1 if valid S-record; CCR Z-bit = 0 if not valid<BR>;*&nbsp;&nbsp; S-record type @ sp+1 (1 ASCII byte) ($30, $31, or $39)<BR>;*&nbsp;&nbsp; S-record size @ sp+2 (1 hex byte) (# of data bytes 0-31)<BR>;*&nbsp;&nbsp; S-record addr @ sp+3 (2 hex bytes) (addr of 1st data value)<BR>;*&nbsp;&nbsp; S-record data @ sp+5..sp+36 (up to 32 hex data bytes)<BR>;*<BR>;*&nbsp; Stack map... S-record, return, and locals on stack<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;-sp (after local space allocated)<BR>;*&nbsp; H:X-&gt; | SRecCount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | SRecChkSum&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;-sp (after jsr)<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | ReturnAddr msb&nbsp; |<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | ReturnAddr lsb&nbsp; | &lt;-sp (after rts)<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | SRecTyp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | SRecSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<BR>;*&nbsp; H:X-&gt; | SRecAddr msb&nbsp;&nbsp;&nbsp; |<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | SRecAddr lsb&nbsp;&nbsp;&nbsp; |<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | SRecData 00&nbsp;&nbsp;&nbsp;&nbsp; |<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | SRecData 01&nbsp;&nbsp;&nbsp;&nbsp; | etc... (up to 32 bytes)<BR>;*<BR>;*&nbsp;&nbsp;&nbsp; Data values are read as two ASCII characters, converted to<BR>;*&nbsp;&nbsp;&nbsp; hex digits, combined into 1 hex value, and stored on stack<BR>;*<BR>;*&nbsp; Calls: GetChar, PutChar, and GetHexByte<BR>;*&nbsp; Changes: A, H, and X<BR>;******************************************************************<BR></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 图7是一个复杂的头,它使用堆栈传递参数并且附加的堆栈来分配局部变量.虽然可以描述很多的细节但我们规定头的描述最好限制在3到4行.如果要求更多的细节,可以使用一个的单独的文件,而不是描述在代码文件中.<BR>&nbsp;&nbsp;&nbsp; 调用协议是想当复杂的,因为用户必须分配传递参数的堆栈空间,堆栈内的参数包括用户填充的和本子程序返回的.当这个子程序放回后,一条BNE指令用来检查Z标志来检查本子程序是否成功得到一个S记录.当检查到一个错误或可处理的返回数据,调用程序必须处理调用前分配的传递参数的堆栈空间.<BR>&nbsp;&nbsp;&nbsp; 堆栈的用法也非常复杂,因为本子程序在堆栈上处理信息,所以给读者提供一个堆栈信息映像来帮助读者理解这个子程序是非常重要的.这个映像展示了一个最大的块,这个块是在调用子程序之前分配的.返回地址做为JSR指令的结果也存储在堆栈上.本子程序内部分配使用的2字节局部变量必须在返回调用程序之前处理完毕.<BR>&nbsp;&nbsp;&nbsp; 在这个子程序的头的最后<BR>&nbsp;&nbsp;&nbsp; 调用项:列出本子程序需要调用的子程序.<BR>&nbsp;&nbsp;&nbsp; 改变项:列出执行本子程序改变的寄存器<BR><FONT face=Courier>;******************************************************************<BR>;* GetChar - wait indefinitely for a character to be received<BR>;*&nbsp; through SCI1 (until RDRF becomes set) then read char into A<BR>;*&nbsp; and return. Reading character clears RDRF. No error checking.<BR>;*<BR>;* Calling convention:<BR>;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jsr GetChar<BR>;*<BR>;* Returns: received character in A<BR>;******************************************************************<BR></FONT>&nbsp;&nbsp; 图8展示一个简单的子程序头,这个头不包含堆栈信息,也不调用其它子程序,所以这些信息都不需要了.<BR>----------------------------------------------------------------<BR>注释:<BR>&nbsp;&nbsp;&nbsp; 注释是非常重要的,大多数注释格式是以分号并从31列开始直到行尾.避免注释重复说明指令内容.<BR>&nbsp;&nbsp;&nbsp; 例如:lda pta&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;读A口数据.<BR>&nbsp;&nbsp;&nbsp; 取而代之注释应传递这样一些信息:为什么指令在这儿,指令如何描述程序功能或系统包含的嵌入式微控制器.<BR>&nbsp;&nbsp;&nbsp; 这是一个好的注释:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lda PTAD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;check for low on bit 7 (step switch)<BR>&nbsp;&nbsp;&nbsp; 如果注释过长不能在一行完成,那么应该在第1列单独起一行,但不宜频繁使用以防淹没代码行.如果是多行注释可以写成注释块,注释块与代码行以空注释行相分隔如下所示:<BR><FONT face="Courier New">;<BR>; In-line comment block. On rare occasions, an extended comment<BR>; is needed to explain some important aspect of a program. Each<BR>; line of the extended comment starts with a semicolon. A line<BR>; with nothing but a semicolon in column 1 is used above and<BR>; below the block comment to set it apart from code.<BR>;</FONT></P>
<P>注释格式基础理论<BR>&nbsp;&nbsp;&nbsp; 注释或空行可以使程序组成逻辑段以提高可读性.子程序头块可以标识一个子程序的开始.类似的分隔也是非常有用的.<BR></P><BR></DIV></TD></TR></TBODY></TABLE><FONT color=#ff0000></FONT>
<P align=right><A href="http://blog.21ic.org/blog.asp?name=cxjr" target=_blank><FONT color=#ff0000>如果你的‘芯’是一座作坊,我愿做那不知疲倦的程序匠。打造一流博客,我们每天在努力!</FONT></A></P><A href="http://blog.21ic.org/blog.asp?name=cxjr" target=_blank><FONT color=#ff0000></FONT></A><br><a name='comment'></a><table width='90%' border='0' align='center' cellspacing='0' cellpadding='0'> <tr> <td><strong>发表评论:</strong></tr></td></table>
<table width='90%' border='0' align='center' cellspacing='0' cellpadding='0'> <tr> <td><table align='left' width='100%' border='0' cellspacing='0' cellpadding='0'>
<form action='more.asp?name=cxjr&id=3562&action=addcomment_ic' method='post' name='commentform' onSubmit='return Verifycomment()'>
<tr><td height='25'  align='left'>昵称:<input name='UserName' type='text' id='UserName' size='15' maxlength='20' value=''></td></tr>
<tr><td height='25' align='left'>密码:<input name='Password' type='password' id='Password' size='15' maxlength='20' value=''> (游客无须输入密码)</td></tr>
<tr ><td height='25' align='left'  >验证码:<input name='GetCode' type='text' id='GetCode' size='12' maxlength='20' />&nbsp;<img src='inc/code.asp' width='40' height='10' border='0' /><td></tr><tr ><td height='25' align='left'  >主页:<input name='homepage' type='text' id='homepage' size='42' maxlength='50' value='http://'><td></tr><tr ><td height='25' align='left'  >标题:<input name='commenttopic' type='text' id='commenttopic' size='42' maxlength='50' value='回复:Freescale&nbsp;汇编语言源程序标准'><td></tr><tr height='200'><td ><INPUT type='hidden' name='edit' id='edit' value=''>
<link rel="STYLESHEET" type="text/css" href="images/edit.css">
<Script Src="images/DhtmlEdit.js"></Script>
<table id="oblog_Container" class="oblog_Body" height=100% width=350 cellpadding=1 cellspacing=0 border=0 >
  <tr> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -