Part 4: Instruction Set for 16F18875 Specific to Lab Assignments and Video Lectu
Part 4: Instruction Set for 16F18875 Specific to Lab Assignments and Video Lectures
This section provides an overview of the crucial data transfer, arithmetic, logical, and bit-oriented instructions for the 16F18875 microcontroller, which are fundamental to the Lab Assignments and Lecture Videos. Some of these instruction sets might overlap with previous readings. Understanding these instructions is key for effective assembly language programming and practical application in various embedded systems projects.
Data Transfer Instructions
- MOVLW (Move Literal to W register):
- Syntax:
MOVLW k
- Function: Loads the literal value
k
into the W register. - Example:
MOVLW 0x55
; Loads the value 0x55 into the W register.
- Syntax:
- MOVWF (Move W register to File register):
- Syntax:
MOVWF f
- Function: Copies the contents of the W register to the specified file register
f
. - Example:
MOVWF 0x20
; Copies the contents of the W register to file register 0x20.
- Syntax:
- MOVF (Move File register to W register):
- Syntax:
MOVF f, d
- Function: Moves the contents of the file register
f
to the W register ifd
is 0. - Example:
MOVF 0x20, W
; Moves the contents of file register 0x20 to the W register.
- Syntax:
Arithmetic Instructions
- ADDWF (Add W register to File register):
- Syntax:
ADDWF f, d
- Function: Adds the contents of the W register to the file register
f
, and stores the result inf
ifd
is 1. - Example:
ADDWF 0x20, F
; Adds W register to file register 0x20, storing the result in 0x20.
- Syntax:
- SUBWF (Subtract W register from File register):
- Syntax:
SUBWF f, d
- Function: Subtracts the contents of the W register from the file register
f
, and stores the result inW
ifd
is 0. - Example:
SUBWF 0x20, W
; Subtracts W register from file register 0x20, storing the result in W.
- Syntax:
- INCF (Increment File register):
- Syntax:
INCF f, d
- Function: Increments the contents of the file register
f
by one and stores the result inf
ifd
is 1. - Example:
INCF 0x20, F
; Increments the contents of file register 0x20 by one, storing the result in 0x20.
- Syntax:
- DECF (Decrement File register):
- Syntax:
DECF f, d
- Function: Decrements the contents of the file register
f
by one and stores the result inW
ifd
is 0. - Example:
DECF 0x20, W
; Decrements the contents of file register 0x20 by one, storing the result in W.
- Syntax:
Logical Instructions
- ANDWF (AND W register with File register):
- Syntax:
ANDWF f, d
- Function: Performs a bitwise AND operation between the W register and the file register
f
, storing the result inf
ifd
is 1. - Example:
ANDWF 0x20, F
; Performs AND operation between W register and file register 0x20, storing result in 0x20.
- Syntax:
- IORWF (Inclusive OR W register with File register):
- Syntax:
IORWF f, d
- Function: Performs a bitwise OR operation between the W register and the file register
f
, storing the result inf
ifd
is 1. - Example:
IORWF 0x20, F
; Performs OR operation between W register and file register 0x20, storing r