The Goto program jumps to the specified address unconditionally.
Syntax: goto m
Operand: m is the target address specified by the 11-bit immediate number.
Execution time: 2 instruction cycles
Execution Process:
M → PC [10: 0]
Pclath [4: 3] → PC [12: 11]
Status flag impact: None
Note: The program immediately jumps to the destination address unconditionally and continues execution. The destination address consists of the 11-bit address code contained in this instruction and the 4: 3 in the special register pclath.
Command example:
Org 0x000; the starting address of the program specified by the pseudocommand
Goto main; the program jumps to the position specified by the label and continues execution.
Movlw W register assigned immediate count
Syntax: movlw K
Operand: K is an 8-digit immediate number.
Execution time: one instruction cycle
Execution Process: K → W
Status flag impact: None
Note: This command assigns an initial value to the W register. To assign an immediate value to any other data register, it must be transmitted through the W register.
Command example:
Movlw 0x55; [w] = 0x55
Movwf TMP; [TMP] = [w] = 0x55
Addlw W register and 8-bit immediate addition
Syntax: addlw K
Operand: K is an 8-digit immediate number.
Execution time: one instruction cycle
Execution Process: [w] + k → W
Status flag impact: Z DC C
Note: The w register value and the 8-bit immediate number are added, and the result is placed in the W register.
Command example:
Movlw 0xaa; W = 0xaa
Addlw 0x11; W = 0xaa + 0x11 = 0xbb
Sublw immediate count minus W register
Syntax: sublw K
Operand: K is an 8-digit immediate number.
Execution time: one instruction cycle
Execution Process: K-[w] → W
Status flag impact: Z DC C
Note: W register is a subtrahend in this command.
If K = W and the subtraction result is 0, Z = 1
If K> W, no borrow occurs, c = 1
If K <W, there is a bid, then C = 0
In the PIC microcontroller, the execution of this subtraction command is to first obtain the W register and then add it to the subtrahend. Therefore, be careful when determining whether there is a bid sign.
Command example:
Movlw 0x23; W = 0x23
Sublw 0x32; W = 0x32-0x23 = 0x0f, k> W, so c = 1
Perform logic or operations on the iorlw register and the immediate number.
Syntax: iorlw K
Operand: K is an 8-digit immediate number.
Execution time: one instruction cycle
Execution Process: [w] | K → W
Status flag impact: Z
Note: The w register and the 8-bit immediate number are in the W register. This command can set any bit of the W register to data 1 according to the logic or the rule with 1 Output 1
Command example:
Iorlw B '00001111'; W register 4 Low Position 1
Perform logic and operations on andlw W registers and immediate count
Syntax: andlw K
Operand: K is an 8-digit immediate number.
Execution time: one instruction cycle
Execution Process: [w] & K → W
Status flag impact: Z
Description: W registers and 8-bit instant phase. The result is placed in W registers. According to the logic and the rule with 0 output 0, the W register can be cleared at any position.
Command example:
Andlw B '00001111'; W register height 4-bit clear 0
The xorlw registers and the immediate number perform logical XOR operations.
Syntax: xorlw K
Operand: K is an 8-digit immediate number.
Execution time: one instruction cycle
Execution Process: [w] ^ K → W
Status flag impact: Z
Note: The number of W registers is different from that of the 8-bit immediately, and the result is placed in the W register. According to the logic XOR rule, any number and 1 are different or, and the result is its inverse code; any number is different from its own or, and the result is 0. Therefore, this command can reverse any number of digits in the W register or determine whether the content of the W register is a specific value.
Command example:
Example 1: bitwise inversion of any data
Xorlw B '11111111'; obtains the 8-bit back code of the W register.
Example 2: Determine whether the W register content is a specific value
Xorlw 0x34; W = 0x34?
If btfsc status, Z; W is not equal to 0x34, the next command is skipped.
Goto w34; W equals 0x34.