PIC彙編筆記

來源:互聯網
上載者:User

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 resultADDWF 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空間內傳送資料。

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.