PIC汇编笔记

2019-04-15 12:52发布

1.
1: 二进制整数为'b' 或'B' 后跟一个或多个用单引号括起的二进制数字'01'。 2: 八进制整数为'o' 或'O' 后跟一个或多个用单引号括起的八进制数字‘01234567' 。 3: 十进制整数为'd' 或'D' 后跟一个或多个用单引号括起的十进制数字‘0123456789’ 。 或者,十进制整数为‘.' 后跟一个或多个十进制数字 '0123456789’ 。 4: 十六进制整数为'h' 或'H' 后跟一个或多个用单引号括起的十六进制数字 ‘0123456789abcdefABCDEF’ 。或者,十六进制整为‘0x' 后跟一个或多个十六进制 数字 ‘0123456789abcdefABCDEF’ 。可以是:99H, 99, 0x99, h'99'.前两种若以A~F开头,需在前面加0,如0EH。 5: ASCII 字符为'a' 或'A' 后跟一个用单引号括起的字符(见第B.2 节“ASCII 字符 集”)。或者, ASCII 字符是一个单引号括起的字符。
2.PIC文件寄存器(静态RAM,8位) 在PIC微控制器文献中,数据存储器又被称为文件寄存器。文件寄存器分为两类:特殊功能寄存器(SFR)和通用寄存器(GPR,GPRAM)。 PIC18系列文件寄存器最大可达4096B,地址范围为000H~FFFH。分成16个存储区,每区大小256B。 字面值(立即数)不能直接传送至PIC18的GPR,必须经过WREG。 ADDWF fileReg, w ;wreg is the result ADDWF fileReg,f ;filereg is the result
3.PIC18状态寄存器(8位)
又称作标志寄存器,PIC18用到了其中5位。分别是: C,进位标志位,进位时置位; DC,数字进位标志,D3向D4进位时置1; Z,零标志位,结果为零置1; OV,溢出标志位,高位溢出置1,用于检测有符号数算术运算 N,负数标志位,算术运算结果D7为1则置1. MOVF影响Z

4.数据写到LATx中时,只有TRISx清零才输出到引脚
5.FSR,文件选择寄存器(12位) PIC18有三个,FSR0,FSR1, FSR2.用于寄存器间接寻址时存储地址。FSR为12位,因此可以覆盖整个4KB空间,同时分成高低字节,FSRxL和FSRxH,FSRxH只用了低四位。INDF为间接寄存器。将数据传送至INDFx时,就是要传送至FSRx所指向的RAM地址。 LFSR 0,0x30 ;FSR0=30H(address) MOVWF INDF0 ;copy wreg to address 30h
6.difference between BRA and GOTO BRA is a relative jump from current position to anywhere within +1023 and -1024 locations. Goto is an absolute unconditional jump within the available program locations on the PIC.  Whenever you are sure your jump is within 1K locations you can use BRA,like software delay loops etc where lot of code efficient short jumps can be there.Another thing that comes to mind is upon reset location 0x0000 where you may want to insert some code before branching to main code without overlapping the interrupt location 0x0008.BRA can squeeze in one more instruction.Once again,BRAnching should be within 1K locations. 7.status register The STATUS register, contains the arithmetic status of the ALU. As with any other SFR,it can be the operand for any instruction.
8.movlb  move literal to bank select register 9. In addition to the INDF operand, each FSR register pair also has four additional indirect operands. Like INDF,these are “virtual” registers that cannot be indirectly read or written to. Accessing these registers actually accesses the associated FSR register pair, but also performs a specific action on its stored value. They are:
• POSTDEC: accesses the FSR value, then automatically decrements it by 1 afterwards  • POSTINC: accesses the FSR value, then automatically increments it by 1 afterwards  • PREINC: increments the FSR value by 1, then uses it in the operation  • PLUSW: adds the signed value of the W register (range of -127 to 128) to that of the FSR and uses the new value in the operation. plusw常用作查询表的基址,wreg作为索引。
10. PIC18的ROM程序空间只能按字节寻址,而4KB的数据RAM则既可以按字节寻址,又可以按位寻址。
11. MOVFF不用考虑存储区的转换,可以在4KB RAM空间内传送数据。

热门文章