PIC Assembly notes

Source: Internet
Author: User

1.

1: The binary integer 'B' or 'B' is followed by one or more binary numbers '01' enclosed in single quotes '.

2: an octal integer of 'O' or 'O' is followed by one or more Octal numbers enclosed in single quotes '123 '.

3: The decimal integer 'D' or 'D' is followed by one or more decimal numbers enclosed in single quotes '123 '.

Alternatively, the decimal integer is '.' followed by one or more decimal digits '123 '.

4: The hexadecimal integer 'H' or 'H' is followed by one or more hexadecimal numbers enclosed in single quotes.

'0123456789abcdefabcdef '. Or, the hexadecimal integer is '0x 'followed by one or more hexadecimal

The number '0123456789abcdefabcdef '. It can be: 99 h, 99, 0x99, H '99'. If the first two types are ~ F must start with 0, for example, 0eh.

5: the ASCII character 'a' or 'A' is followed by a character enclosed in single quotes (see section B .2 "ASCII characters

Set "). Alternatively, the ASCII character is a character enclosed by single quotes.

2. PIC file register (static RAM, 8-bit)

In the PIC microcontroller literature, data storage is also called a file register. File registers are divided into two types: Special Function registers (SFR) and General registers (GPR, gpram ).

The pic18 series file registers can be up to 4096b, and the address range is 000h ~ Fffh. It is divided into 16 storage areas with a size of 256b.

The literal value (immediate number) cannot be directly transmitted to the GPR of pic18, and must pass through wreg.

 

 
Addwf filereg, W; wreg is the resultaddwf filereg, F; filereg is the result

3. pic18 Status Register (8-bit)

 

Also known as the mark register, pic18 uses five of them. They are:

C, carry flag bit, carry time bit;

DC, digit carry sign, D3 to D4 carry 1;

Z, zero flag bit, the result is 0 set 1;

OV, overflow flag bit, high overflow set 1, used to detect the number of signed arithmetic operations

N, a negative flag. If the result of the arithmetic operation is 1, 1 is set.

Movf affects Z

4. When the data is written to latx, It is output to the pin only when trisx is cleared.

5. FSR, file Selection Register (12 bits)

Pic18 has three storage addresses: fsr0, fsr1, and fsr2. FSR is 12-bit, so it can cover the entire 4 kb space and be divided into high and low bytes. fsrxl, fsrxh, and fsrxh use only four lower bits. Indf is an indirect register. When data is transmitted to indfx, it is transmitted to the RAM address pointed to by fsrx.

 

 
Lfsr 0, 0x30; fsr0 = 30 h (Address) movwf indf0; copy wreg to address 30 h

 

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 1 K 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 be able 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 shoshould be within 1 K 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. 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 is often used to query the base address of a table, and wreg is used as an index.

10. pic18 RomProgramSpace can only be addressable by byte, while 4 kb of Data RAM can both be addressable by byte and by bit.

11. You can transfer data in a 4 kB RAM space without considering the storage zone conversion.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.