PIC16F84A – Instruction Set (Continued)
Having known about the byte oriented file register operation, only two categories are remaining – the bit oriented file register operations and the control operations.
Bit-oriented file register operations:
Here these instructions are used when a single bit needs to be affected/changed/checked. There are only four bit-oriented instruction for the 16F84A
Mnemonics & Operands | Description |
---|---|
BCF f,b | Bit clear f (b represents the bit to be cleared in the specified register) |
BSF f,b | Bit set f |
BTFSC f,b | Bit test f, skip (the next line) if clear |
BTFSS f,b | Bit test f skip (the next line) if set |
The instructions used above are already explained in previous posts about PIC16F84A.
Literal and Control operations:
These instruction are meant for manipulating the W-register values and also, control the working of the microcontroller. Here only W-register is involved and hence only one operand is needed – the 8 bit data.
Mnemonics & Operands | Description |
---|---|
ADDLW x | Add the eight bit literal value(x) and the contents of W-register |
ANDLW x | Logical AND the literal value(x) and the contents of the W-register |
CALL x | Call a subroutine such as a delay routine. Here x signifies the label of the subroutine |
CLRWDT | Clears the watchdog timer. This is a control instruction and hence no operand is used |
GOTO x | Goto the specified address or label denoted by x |
IORLW x | Inclusive OR 8-bit literal value(x) with the contents of W-register |
MOVLW x | Move the 8-bit literal value(x) to the W-register |
RETFIE | Return from interrupt. Usually used at the end of a interrupt routine |
RETLW x | Return with literal value(x) in the W-register. This instruction returns from a subroutine and also moves the literal value to the W-register |
RETURN | Returns from a subroutine |
SLEEP | Goes into standby mode |
SUBLW x | Subtract the contents of W-register from the literal value(x) |
XORLW x | Exclusive OR literal value(x) with contents of W-register |
Thats all about the 35 instructions which can be used in the PIC16F84A assembly programming. However, these instructions are used only if assembly programming is preferred. You won’t use even a single instruction from this list when embedded C programming is preferred. Even though embedded C programming is widely used, assembly language remains popular for small applications and among hobbyists for the following reason – Memory efficient coding.
Assembly-a memory efficient language:
Memory is a major constrain in microcontrollers since, memory is integrated into the controller, (This is not the case with the microprocessor, since, you can interface a maximum amount of memory – large enough which can be handled by its address bus) mostly few KBs of memory are integrated. For example, the PIC16F84A has only 64 bytes of data EEPROM memory. An assembled program takes a very low space when compared to the same program compiled in C language. This is the major reason, why assembly language is still popular for small applications. The reason, why assembly is not used for large applications is not the fact that we cannot write code for large applications, but in assembly as program size grows, complexity grows and hence it becomes difficult to troubleshoot(debug) the program. But for DIY projects and small hobby projects, the code won’t attract much complexity and hence assembly can be adopted which provides a efficient code and better control over the controller 😉