Académique Documents
Professionnel Documents
Culture Documents
Dwight Sabio
NOP
Uses one instruction cycle. Used for short time delays.
MOVWF f
Moves contents of W register to another file register location. Status affected: None Example MOVWF Temp
MOVF f,d
f d Moves contents of one file register to another. Can be used to set the Zero Status bit. Status Affected: Z Example MOVF Temp, f
CLRF f
The contents of register f are cleared and the Z bit is set. File (f) = 00000000 Status affected: Z
CLRW
W register is cleared. Zero bit (Z) is set. W = 00000000 Status affected: Z
INCF f,d
f + 1 d Status affected: Z
DECF
f - 1 d Status affected: Z
ADDWF f, d
W + f d Adds the contents of W to a File Register Status Affected: Z
ANDWF f,d
W AND f d Status Affected: Z Performs Logical AND with W and f Can be used to mask out specific bits
IORWF f, d
W OR f d Status Affected: Z Executes Inclusive-OR with W and a File Register
XORWF f,d
W XOR f d Status Affected: Z Executes Exclusive-OR with W and a File Register
COMF f,d
f d Executes a ones compliment on a file register.
RRF f, d
RLF f,d
SUBWF f,d
f - W d Subtracts the contents of W from a File Register Twos compliment Status affected: C, DC, Z
SWAPF f,d
BCF f,b
Clear the bit in a file F. Status Affected: None Operands: 0 f 127 0b7
BCF PORTB, 4; bit 4 is cleared in the PORTB
BSF f,b
Set bit in file F. Status Affected: None Operands: 0 f 127 0b7
BSF PORTB, 4; bit 4 is set in the PORTB
BTFSC f,b
Test bit in file skip if clear. Operation: skip if (f<b>) 0 Status Affected: None Operands: 0 f 127 0b7 BTFSC STATUS, 2 This test bit 2 in STATUS Register if it is clear then the next instruction is missed. Bit 2 is the zero bit so the program jumps if the result of an instruction was zero.
BTFSS f,b
Test bit in file skip if set. Operation: skip if (f<b>) = 1 Status Affected: None Operands: 0 f 127 0b7 BTFSS STATUS, 2 This tests bit 2 in the STATUS Register is set then the next instruction is skipped.
ADDLW k
Add a number(literal) to W. Operation: (W) + k (W) Operands: 0 k 255
ANDLW k
The contents of W are ANDed with an 8 bit number(literal). The result is placed in W. ANDLW 12H ANDLW b00010010 ANDLW .18
CALL k
Call Subroutine CALL WAIT1MIN- This will call a routine (you have written) to wait for 1 min.
GOTO k
This is an unconditional jump to a specified location in the program.
GOTO SIREN
IORLW k
The contents of the W register are Ored with the file F. The result is placed in the W register. Status Affected: Z IORLW 7
MOVLW k
The 8 bit literal is moved directly into W.
RETFIE
Return from Interrupt This instruction is used to return from an interrupt.
RETLW k
This instruction is used at the end of a subroutine to return to the program following a CALL instruction. The literal value is placed in the W register. This instruction can also be used with a look up table.
RETLW 0
RETURN
This instruction is used to return from a subroutine.
SUBLW k
The contents of the W register are subtracted from a number. Operation: k (W) (W)
XORLW k
The contents of the W register are Exclusive Ored with the literal. If a number of the input port, indicating temperature, is the same as the literal then the result is zero and the zero bit is set. XORLW 67
CLRWDT
The watchdog timer is cleared. The watchdog is a safety device in the microcontroller if the program crashes the watchdog timer times out then restarts the program. Status affected: TO, PD
SLEEP
When executing this instruction the chip is put into sleep mode. The power-down status bit (PD) is cleared, the time-out status bit is set, the watchdog timer and its prescaler is cleared and the oscillator driver is turned off. The watchdog timer still keeps running form its own internal clock. Status affected TO, PD
Seatwork 1- Prelims
Assume: f. CLRW g. COMF ALPHA,d W = 53h h. DECF BETA k = 26h i. INCF TEMP TEMP = BAh j. IORLW k ALPHA = 3Eh BETA = b11111001 k. IORWF BETA, w Find the result & indicate the l. MOVF ALPHA, 0 value of the C, DC & Z bit a. ADDWF TEMP, 1 m. RLF BETA, 1 n. SUBLW k b. ADDLW k o. SUBWF BETA c. ANDLW k d. ANDWF ALPHA e. CLRF TEMP
42
43
44