Add the content of the addwf W register and the content of the f Data Register
Syntax: addwf F, d
Operand: F is the low 7-bit address of the data register (0x00 ~ 0x7f)
D is the low 7-bit address of the destination register (0x00 ~ 0x7f)
When d = F, the result is placed in the f data register, and the content of the W Register remains unchanged.
When d = W, the result is placed in W register, and the content of F Data Register remains unchanged.
Execution time: one instruction cycle
Execution Process: [f] + [w] → D
Status flag impact: Z DC C
Description: The data register content is added to the W register content, and the result is placed in the place specified by D.
Command example:
Movlw 0x55; W = 0x55, assuming sum = 0xaa
Addwf sum, F; W unchanged, sum = 0xff
Movf transfers the f data register content to the destination register
Syntax: movf F, d
Operand: F is the low 7-bit address of the data register (0x00 ~ 0x7f)
D is the low 7-bit address of the destination register (0x00 ~ 0x7f)
When d = F, put the content of the data register back into itself to determine whether the content of the data register is 0.
When d = W, the result is placed in W register, and the content of data register F is transmitted to W register
Execution time: one instruction cycle
Execution Process: [f] → D
Status flag impact: Z
Note: transfer the content of the data register to it, or determine 0 for the content of the F data register. If the transmitted data is 0, set the Z mark.
Command example:
Example 1: Data Transmission
Movf var1, W; var1 content transmitted to W register
Movwf var2; W register content is transferred to var2, at this time var1 = var2
Example 2: DATA 0
Movf var3, F; var3 register content is sent to itself, other registers remain unchanged, but the Z mark is affected.
Btfsc status, Z; If var3 is not equal to 0, the next command is skipped.
Goto var3zero; If var3 is equal to 0, it is switched to another operation.
The content of the comf data register is reversed.
Syntax: comf F, d
Operand: F is the low 7-bit address of the data register (0x00 ~ 0x7f)
D is the low 7-bit address of the destination register (0x00 ~ 0x7f)
When d = F, the result is placed in the f data register, and the content of the W Register remains unchanged.
When d = W, the result is placed in W register, and the content of F Data Register remains unchanged.
Execution time: one instruction cycle
Execution Process :! [F] → D
Status flag impact: Z
(Calculate the reverse code of the data register content. You can use this command to obtain the complement code of a number (add one by bit)
Command example:
Comf num, F; returns the inverse code of the num variable
Incf num, F; anti-code plus 1 is its complement
The content of the decfsz data register is decreased by 1 and 0 is determined.
Syntax: decfsz F, d
Operand: F is the low 7-bit address of the data register (0x00 ~ 0x7f)
D is the low 7-bit address of the destination register (0x00 ~ 0x7f)
When d = F, the result is placed in the f data register, and the content of the W Register remains unchanged.
When d = W, the result is placed in W register, and the content of F Data Register remains unchanged.
Execution time: one or two command cycles
Execution Process: [f]-1 → D
Status flag impact: Z
Note: This command first reduces the content of the F data register by 1, and the result is placed in the destination address specified by D, at the same time, it will also determine 0 for the Z mark (for Branch Jump Control); if the result of the F data register minus 1 is not 0, then z = 0, the program will execute the next command sequentially, and this command operation consumes a command cycle; if the result is 0, then z = 1, then the program will skip the first command followed by it, to execute the second command that follows it, this command operation takes two command cycles. This command is usually used to control the count or the number of cycles.
Command example:
Movlw 0x10; prepare to assign initial values to the cyclic counter
Movwf count; at this time, the cyclic counter COUNT = 0x10
Loop: decfsz count, F; count decrease 1, the result is put into the count, and the Z mark is used to determine goto loop; break. If the result is not 0 after the decrease, continue the loop operation ,; A total of 0x10 (hexadecimal) cycles.
NOP; if the result is 0 after the decrease, it will jump to this command