PIC18 Series Family Instructions Quick Index

Publisher:dst2015Latest update time:2019-11-13 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

TBLPTR = 0x01A357; The value of TBLPTR register is 0x01A357.

MEMORY (0x01A357) = 0x12

     ;The value in memory location 0x01A357 is 0x12.

MEMORY (0x01A358) = 0x34

     ;The value in memory location 0x01A358 is 0x34.

After execution:

TABLAT = 0x34; the value of the TABLAT register is 0x34.

TBLPTR = 0x01A358; the value of TBLPTR register is 0x01A358.


Command name: TBLWT

Original meaning: Table Write

Syntax: [label] TBLWT (*; *+, *-, +*)

Operator: None

Operation description:

uIf TBLWT *,

(TABLAT) -> Holding Register;

TBLPTR No Change;

uIf TBLWT *+,

(TABLAT) -> Holding Register;

(TBLPTR) +1 -> TBLPTR;

uIf TBLWT *-,

(TABLAT) -> Holding Register;

(TBLPTR) -1 -> TBLPTR;

uIf TBLWT +*,

(TBLPTR) +1 -> TBLPTR;

(TABLAT) -> Holding Register;

Impact flags: None

Instruction description: TBLWT is a program memory writing instruction. It has the following four uses:

1.TBLWT*:

Using the contents of the TBLPTRH and TBLPTRL registers as address pointers, write the value in the TABLAT register into the program memory.

2.TBLWT *+:

Using the contents of the TBLPTRH and TBLPTRL registers as address pointers, write the value in the TABLAT register into the program memory, and then automatically increase the address pointer by 1.


3.TBLWT *-:

Using the contents of the TBLPTRH and TBLPTRL recorders as the address pointer, write the value in the TABLAT register into the program memory, and then automatically decrement the address pointer by 1.

4.TBLWT +*:

First add 1 to the TBLPTRH and TBLPTRL recorders, and then use the contents of the TBLPTRH and TBLPTRL recorders as address pointers to write the value in the TABLAT register into the program memory.

Category: Program memory read and write instructions.

Group: Data writing instructions.

Example 1:

TBLWT *+; Use the contents of the TBLPTRH and TBLPTRL recorders as the address pointer, write the value in the TABLAT register into the program memory, and then automatically increase the address pointer by 1.

Before execution:

TABLAT = 0x55; the value of the TABLAT register is 0x55.

TBLPTR = 0x00A356; the value of TBLPTR register is 0x00A356.

Holding Register (0x00A356) = 0xFF

     ;The value in memory location 0x00A356 is 0xFF.

After execution:

TABLAT = 0x55; the value of TABLAT register is 0x55.

TBLPTR = 0x00A357; The value of TBLPTR register is 0x00A357.

Holding Register (0x00A356) = 0x55

     ;The value in memory location 0x00A356 is 0x55.


Example 2:

TBLWT +*; First increment the TBLPTRH and TBLPTRL recorders by 1, and then use the contents of the TBLPTRH and TBLPTRL recorders as address pointers to write the value in the TABLAT register into the program memory.

Before execution:

TABLAT = 0x34; the value of the TABLAT register is 0x34.

TBLPTR = 0x01389A; The value of the TBLPTR register is 0x01389A.

Holding Register (0x01389A) = 0xFF

     ;The value in memory location 0x01389A is 0xFF.

Holding Register (0x01389B) = 0xFF

     ;The value in memory location 0x01389B is 0xFF.

After execution:

TABLAT = 0x34; the value of the TABLAT register is 0x34.

TBLPTR = 0x01389B; the value of TBLPTR register is 0x01389A.

Holding Register (0x01389A) = 0xFF

     ;The value in memory location 0x01389A is 0xFF.

Holding Register (0x01389B) = 0x34

     ;The value in memory location 0x01389B is 0x34.


Command name: TSTFSZ

Original meaning: Test f, Skip if 0

Syntax: [label] TSTFSZ f, a

Operator:

Operation description: Skip if f = 0

Impact flags: None

Instruction description: If the value in temporary register f is equal to 0, skip the next instruction; if the value in temporary register f is not equal to 0, execute the next instruction. If a = 0, the result of the operation is placed in the current RAM address; if a = 1, the result of the operation is placed in the RAM address specified by the BSR register.

Category: Program flow control instructions.

Group: Bit comparison instructions.

Example 1:

HERE TSTFSZ REG, 1; if the value in the temporary register REG is equal to 0, execute the GOTO N2 line of instructions; if the value in the temporary register REG is not equal to 0, execute the GOTO N1 line of instructions.

NZERO GOTO N1;

ZERO GOTO N2;

Before execution:

PC = HERE Address; the current value of the program counter is at the address of the instruction line HERE.

After execution:

If REG = 0x00; If the value in the temporary register REG is equal to 0.

PC = GOTO N2; the value of the program counter will jump to the address of the instruction in the GOTO N2 line.

If REG   0x00; If the value in the temporary register REG is not equal to 0.

PC = GOTO N1; the value of the program counter will jump to the address of the instruction in the GOTO N1 line.


Command name: XORLW

Original meaning: Exclusive OR Literal With W

Syntax: [label] XORLW k

Operator:

Operation description: (W) .XOR. k -> W

Impact flags: N, Z

Instruction description: Perform an exclusive OR (XOR) operation on the constant k and the value of the W accumulator, and put the result back into the W accumulator.

Category: Immediate constant addressing method.

Group: Logical operation XOR instructions.

Example 1:

XORLW 0xAF; Perform an exclusive OR (XOR) operation between the constant k and the value of the W accumulator, and put the result back into the W accumulator.

Before execution:

W = 0xB5; the value of W accumulator is 0xB5.

After execution:

W = 0x1A; the value of W accumulator is 0x1A.

Z = N = 0; both the zero flag Z and the negative flag N are equal to 0.



Example 2:

XORLW 0x40; Perform an exclusive OR (XOR) operation between the constant k and the value of the W accumulator, and put the result back into the W accumulator.

Before execution:

W = 0xB5; the value of W accumulator is 0xB5.

After execution:

W = 0xF5; the value of W accumulator is 0xF5.

N = 1; the negative flag N is equal to 1.

Z = 0; zero flag Z is equal to 0.

Example three:

XORLW 0xB5; Perform an exclusive OR (XOR) operation between the constant k and the value of the W accumulator, and put the result back into the W accumulator.

Before execution:

W = 0xB5; the value of W accumulator is 0xB5.

After execution:

W = 0x00; the value of W accumulator is 0x00.

N = 0; the negative flag N is equal to 0.

Z = 1; zero flag Z is equal to 1.

 


Command name: XORWF

Original meaning: Exclusive OR W With f

Syntax: [label] XORWF f, d, a

Operator:

Operation description: (W) .XOR. (f) -> dest

Impact flags: N, Z

Instruction description: Perform an exclusive OR (XOR) operation on the constant k and the value of the W accumulator. If d = 0, the result after the operation is placed in the W accumulator; if d = 1, the result after the operation is placed in the W accumulator. In the f temporary register, if the temporary register that stores the operation result is stored in the W accumulator, we can also write it as W (table W accumulator); if the temporary register that stores the operation result is stored in the temporary register, we It can also be written as F (table register). If a = 0, the result of the operation is placed in the current RAM address; if a = 1, the result of the operation is placed in the RAM address specified by the BSR register.

Category: Data transfer instructions.

Group: Logical operation XOR instructions.

Example 1:

XORWF REG,f; The value of the REG temporary register performs a mutually exclusive OR (XOR) operation with the W accumulator, and the result of the operation is placed in the REG temporary register.

Before execution:

W = 0xB5; the value of W accumulator is 0xB5.

REG = 0xAF; the value of the REG register is 0xAF.

After execution:

W = 0xB5; the value of W accumulator is 0xB5.

REG = 0x1A; the value of the REG register is 0x1A.

Z = N = 0; both the zero flag Z and the negative flag N are equal to 0.

Example 2:

XORWF REG,W; perform a mutually exclusive OR (XOR) operation on the value of the REG temporary register and the W accumulator, and put the result of the operation into the REG temporary register.

Before execution:

W = 0xB5; the value of W accumulator is 0xB5.

REG = 0xAF; the value of the REG register is 0xAF.

After execution:

W = 0x1A; the value of W accumulator is 0x1A.

REG = 0xAF; the value of the REG register is 0xAF.

Z = N = 0; both the zero flag Z and the negative flag N are equal to 0.


[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
Reference address:PIC18 Series Family Instructions Quick Index

Previous article:Ultrasonic PIC microcontroller C program
Next article:Single chip microcomputer EC1 digital rotary encoder simulation program

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号