52905.fb2 Introduction to Microprocessors and Microcontrollers - читать онлайн бесплатно полную версию книги . Страница 21

Introduction to Microprocessors and Microcontrollers - читать онлайн бесплатно полную версию книги . Страница 21

Appendix B: PIC 16CXXX instruction set

SyntaxDescriptionStatus affected
ADDLW kThe contents of the W register are added to an 8-bit number and the result put in the W reg.C, DC, Z
ADDWF f,dAdd the contents of the W and f registers. If d=0 the result goes to W. If d=1 the result goes to the f registerC, DC, Z
ANDLW kThe contents of the W register are ANDed with an 8-bit number and the result put in the W reg.Z
ANDWF f,dAND w with reg f. If d=0 the result goes to W. If d=1 the result goes to the f registerZ
BCF f,bBit b in reg f is cleared 
BSF f,bBit b in reg f is set 
BTFSS f,bIf bit b in reg f=0, the next instruction in executed. If it is 1 the next instr. is replaced with a NOP1 or 2 cycles
BTFSC f,bIf bit b in reg f=1, the next instruction in executed. If it is 0 the next instr. is replaced with a NOP1 or 2 cycles
CALL kCall subroutine. Return address (PC+1) is pushed onto stack. The 11-bit immediate address is loaded into PC bits 1:0 The upper bits of the PC are loaded from PCLATH 4:3.2 cycle
CLRFf Register f is cleared and Z flag is set.Z
CLRWRegister W is cleared and Z flag is set.Z
CLRWDTResets watchdog timer and watchdog prescalerTO, PD
COMF f,dContents of ‘f’ are complemented (0→1, 1→0) If d=0 the result goes to W. If d=1 the result goes to fZ
DECF f,dContents of ‘f’ reduced by 1. If d=0 the result goes to W. If d = 1 the result goes to fZ
DECFSZ f,dContents of ‘f’ reduced by 1. if d=0 the result goes to W. If d=1 the result goes to f. If result = 1, the next instruction in executed. If it is 0 the next instr. is replaced with a NOP1 or 2 cycles
GOTO kThe 11-bit immediate address is loaded into PC bits <10:0>. The upper bits of the PC are loaded from PCLATH <4:3>. 
INCF f,dIf d=0 the result goes to W. If d=1, result goes to f. 
INCFSZ f,dContents of ‘f’ incremented. If d=0 the result goes to W. If d=1 the result goes to f. If rfesult = 1, the next instruction is executed. If it is 0 the next instr. is replaced with a NOP1 or 2 cycles
IORLW kThe contents of the W register are ANDed with an 8-bit number and the result put in the W reg.Z
IORFWF f,dThe contents of the W register are Inclusive ORed with reg. F. If d=1 resujlt goes back into f 
MOVF f,dIf d=0, contents of f goes to W reg. If d=1 it goes to fZ
MOVLW kThe 8-bit number k goes into W. 
MOVWF fMoves data from W register to f register 
NOPDoes nothing – just a time waster (one cycle period) 
RETFIEReturn from interrupt. Top of stack→PC, 1→GIE2 cycle
RETLW kW reg loaded with number , return address→PC2 cycle
RETURNReturn from subroutine. Return address→PC2 cycle
RLF f,dContents of ‘f’ are rotated left one bit via the carry flag. If d=0 the result goes to W. Id=1, result goes back to f. See fig. belowC
SLEEPPowerdown status bit PD is cleared, Timeout status bit TO is set. WDT and prescaler are cleared, oscillator stops and controller goes to sleep.TO, PD
SUBLW kW register subtracted from the number k, result goes into W reg. (2’s complement method)C, DC, Z
SUBWF f,dW register subtracted from the register f. If d=0 the result goes to W. If d=1 the result goes to f. (2’s complement method)C, DC, Z
SWAPF f,dUpper and lower nibbles of f are exchanged. If d=0 the result goes to W. If d=1 the result goes to f. 
XORLW kW register contents XOR’ed with the number k, result goes into W reg.Z
XORWF f,dW register contents XOR’ed with the register f, if d=0 the result goes to W. If d=1 the result goes to fZ