The instruction set is highly orthogonal and is grouped into three basic catagories:

The instruction set is highly orthogonal and is grouped into three basic catagories: щ Byte Oriented operations щ Bit Oriented Operations щ Literal and Control Operations The following tables list the instructions recognized by the MPASM assembler, where:It is very possible that your source code will assemble as is. There are, however, a number of inconsistencies between the two assemblers that require some simple changes. In addition, MPASM attempts to provide a clean and simple assembler solution for the future. To that end, there are also a number of changes that are recommended to encourage compatibility going forward.Highlights щ Required Source Code Updates щ Recommended Source Code UpdatesRequired Source Code Updates щ Specify processor type at the very top of the first source file in pro- grams assembled with MPASM using either the PROCESSOR or LIST directives, or specify the processor on the command line. MPASM will not assemble your source without this information. Recommended Source Code Updates щ You are encouraged to move all of your labels to column one, and assembler directives (like LIST and TITLE) to at least column two. An example would be: list p=16c54, r=hex title SampleCode #include "c:\tools\regs.h" #define zero 0 #define one 1 alabel set zero blabel set one org 0x00 goto Start org 0x28 Start goto Start end and so on. щ Specify the radix you are assuming using either the RADIX or LIST directives, or the command line option. щ Change all radix overrides currently included in your code to one of those specified in the MPASM User's Guide. For example: Change: movlw 5D to: movlw D'5' щ Fully qualify moves of label addresses by using the HIGH or LOW directives. MPASM USER'S GUIDE Appendix D. ASM17 Conversion GuideIntroduction MPASM attempts to be backward compatible with ASM17. It is very possible that your source code will assemble as is. There are, however, a number of inconsistencies between the two assemblers that require some simple changes. In addition, MPASM attempts to provide a clean and simple assembler solution for the future. To that end, there are also a number of changes that are recommended to encourage compatibility going forward.Highlights щ Required Source Code Updates щ Recommended Source Code UpdatesRequired Source Code Updates щ Specify processor type at the very top of the first source file in pro- grams assembled with MPASM using either the PROCESSOR or LIST directives, or specify the processor on the command line. MPASM will not assemble your source without this information. щ Change DOS paths for ASM17 source code from using two back slashes to one. Example: Change: #include c:\\tools\\regs.h to: #include c:\tools\regs.h щ Recode any macros that use a variable number of arguments to call out specific arguments. This would only be appropriate for ASM17 code, and is a feature that will be included at some point in the future. щ If you are using the ASM17 HALT directive, recode this as a macro or remove it. This feature will be included at some point in the future. щ If you are using the ASM17 FILL directive, temporarily remove it. This feature will be included at some point in the future.Recommended Source Code Updates щ You are encouraged to move all of your labels to column one, and assembler directives (like LIST and TITLE) to at least column two. An example would be: list p=17c42, r=dec title Sample Code #include "c:\tools\regs.h" #define zero 0 #define one 1 alabel set zero blabel set one org 0x00 goto Start org 0x28 Start goto Start end and so on. щ Specify the radix you are assuming using either the RADIX or LIST directives, or the command line option. щ Change all radix overrides currently included in your code to one of those specified in the MPASM User's Guide. For example: Change: movlw 5D to: movlw D'5' щ Fully qualify moves of label addresses by using the HIGH or LOW directives. MPASM USER'S GUIDE Appendix E. Error and Warning Messages The following error and warning messages are produced by MPASM. These messages always appear in the listing file directly above each line in which the error occurred. The error and warning messages are stored in the error file (.ERR) if no MPASM options are specified. If the /e- option is used (turns error file off), then the messages will appear on the screen. If the /q (quiet mode) option is used with the /e-, then the messages will not display on the screen or in an error file. The messages will still appear in the listing file.Error Messages Address exceeds maximum limit available You are trying to access memory that is not available; the current program counter is greater than the maximum program memory limit for the specified processor type. Please refer to the data sheet for this processor to find the valid memory range. Argument out of range The location trying to be accessed or filled is outside of the program memory range for the specified processor type. Please refer to the data sheet for your specific processor to find its program memory boundaries. Attempt to redefine reserved word The words "END", "ERROR", "HIGH", "LOW" and "PAGE" are reserved words in MPASM. You must not use these words as labels or symbols. Remove or rename any occurances of these words and then reassemble. NOTE: It is too costly with regard to both time and space to treat all directives, opcodes and operators as reserved words. MPASM reserves only the above minimal list of words to avoid the most common misuses of directives. Branch or jump out of range A branch or jump statement is addressing the last half of a program memory page. This is not allowed. Any instruction which writes to the Program Counter (CALL, JUMP, BRANCH or GOTO) is limited to the first 256 locations of any program memory page. Call or jump not allowed at this address A call or computed jump statement is addressing the last half of a program memory page. This is not allowed. Any instruction which writes to the Program Counter (CALL, JUMP, BRANCH or GOTO) is limited to the first 256 locations of any program memory page. Couldn't open . . . MPASM couldn't open the specified object file, memory map file, code file, error file, listing file, or cross-reference file. Either the file already exists and is read/write protected, or there is not enough disk space to create or write to the file. Couldn't open source file . . . The source file specified on the command line, or through the interactive menu, does not exist. Check the current directory for the desired file, and verify the spelling of the source file name. Duplicate label or redefining symbol that cannot be redefined You have either used the same label name twice in your program, or a constant, a #DEFINE'd symbol, or an EQU'd symbol has been used on the left- hand side of an equation. MPASM does not know which definition to use. This ERROR message appears before BOTH definitions of the symbol, when appropriate. Error in parameter One of the options used on the MPASM command line was not a valid option, or an option was incorrectly formatted. Type mpasm /h or mpasm /? at the DOS prompt to see a usage message showing the valid command line options. Expected . . . The syntax of the source line is incorrect. MPASM expected to see one thing, but got something different. Check the syntax of the directive or opcode in error in the MPASM User's Guide. File not found The file specified in the shell screen's source file field does not exist in the current directory. This error appears when the shell interface is used to invoke MPASM, rather than the command line interface. Check the spelling of the file name, and verify that you are in the desired directory. Press any key to continue. Illegal argument One of the directive arguments is of the wrong type. It could be that the radix specified with either a LIST directive or the RADIX directive is not one of the valid radix choices. Change the radix to: DEC for decimal, OCT for octal, or HEX for hexadecimal radix. Also, make sure that FILL directives have parentheses around the if it is an opcode expression. Illegal argument ( must be greater than zero) The expression specifiying the memory locations to be filled by the FILL directive evaluates to a number less than or equal to zero. It must be greater than zero. Illegal condition An IF statement is using an illegal comparison operator. The valid conditions which can be checked by an IF statement are: == (equal to) != (not equal to) > (greater than) < (less than) >= (greater than or equal to) <= (less than or equal to). Illegal condition (EOF encountered before END or conditional end directive) The END directive is missing, or a CBLOCK, an IF, a WHILE or a MACRO statement is missing an ENDC, ENDIF, ENDW or ENDM respectively. Illegal conditional compile There is a problem with the construction of the indicated IF / ELSE / ENDIF statements. Illegal character . . . in label . . . The specified label contains an illegal character. Legal characters are: underscore (_), period (.), capital letters (A through Z), lower case letters (a through z), or decimal digits (0 through 9). Illegal digit The specified digit is illegal in the context used. The digit is either incorrect for the radix specified in the source file, or is an unsupported ANSI escape sequence. Check the LIST directive used in the source code to verify the specified radix. See Chapter 5: Expression Syntax and Operation in the MPASM User's Guide for valid radix specifications and ANSI `C' escape sequences. Illegal opcode The indicated opcode or directive is not recognized by MPASM. The opcode may be misspelled, or is no longer supported. Or, an otherwise legal opcode may be used in an illegal context. For example, a valid directive, such as LIST, prepended with a pound sign (#LIST) will generate this "Illegal opcode" error message. Other examples are: using an ELSE without an associated IF, or using an INCLUDE directive inside a macro definition. Include file not found The file to be included does not exist in the current directory. Check the spelling of the include file name, and verify that you are in the desired directory. If necessary, specify the complete DOS path. For example: C:\SOURCE\INCLUDE\FILENAM>E.H This error may also occur if you do not have a BUFFERS= statement in your DOS CONFIG.SYS system file. Please refer to your DOS manual to add this line. We recommend at least using BUFFERS=10. Include files nested too deep The current include file cannot include another file, because you have reached the maximum level of include file nesting. The maximum number of include files nested within each other is five (5). Macro name missing The term "macro" has been encountered without an associated name for the macro. Macro names can be any legal, unique MPASM label. Macros nested too deep The current macro definition cannot call another macro, because you have reached the maximum level of macro nesting. The maximum number of macros nested within each other is eight (8). Missing argument(s) This opcode, directive, or macro call requires at least one more operand (argument) than is provided. Check the instruction set for the proper syntax. This error can also occur if a #DEFINE'd label is missing a value. In this case, the error message won't appear until the label is used as an operand. This message may also appear if the arguments for a FILL or MACRO directive are not separated by commas. Missing terminator There is an open parenthesis, curly bracket or square bracket without a matching closed parenthesis, curly bracket or square bracket, respectively. This error message can also occur when a comma or blank is expected, but not found. Nested forward reference not allowed The indicated label has not been defined yet, and is not allowed to be used before it is defined. Specifically, forward references to macros are not permitted. If a macro call is generating the error, move the call to a point in the code below the macro definition. This error message also occurs when MPASM cannot tell the type of a given label: variable, constant, address, local variable, or reserved word. The label may be defined more than once. Out of memory All the PC's available memory has been used to create code segments, macros and forward references. Try reducing the number of macros in your source file(s). Also, close out of any terminate-and-stay- resident programs (TSR's) and close any applications, then try assembling the file again. If you are running Windows and assembling from a DOS prompt or from MPSLED, try exiting Windows and assembling directly from DOS. Overwriting previous address contents The location for which MPASM is trying to generate object code has already been used by this program. Usually, an ORG directive for this address occurs prior to the source line that produces this error message. The only time MPASM will allow you to overwrite a previously-used address is if it was reserved with an RES directive. This error also occurs if the FILL directive is trying to fill an address that already has a value. Processor type is undefined No processor type has been specified. Use the LIST or PROCESSOR directive at the top of your source code, or use the /p option on the command line, to define a processor type (PIC16C54, PIC16C55, PIC16C56, PIC16C57, PIC16C58, PIC16C63, PIC16C64, PIC16C65, PIC16C71, PIC16C73, PIC16C74, PIC16C84, or PIC17C42). Processor type previously defined A processor type has already been specified. You cannot change processor types in the middle of a program. Check the LIST or PROCESSOR directive in your source code to see which processor type is defined. If you specify the same processor type two or more times in the same program, no error will occur. Symbol table full All the PC's available memory has been used to create symbols. MPASM requires more memory to create all the symbols defined in this source file. Eliminate any TSR's, and close any applications, then try assembling the file again. If you are running Windows and assembling from a DOS prompt or from MPSLED, try exiting Windows and assembling directly from DOS. You may get the qualifier "Out of macro space (#define)" appended to this message. If this is the case, eliminate #DEFINE symbols in your code by hardcoding as many values as possible. Or, you may see this error message qualified with "more than 8 locals in a macro." The maximum number of local variables allowed per macro is eight (8). Eliminate local variables from the macro definition. Temp file creation error A temporary file could not be created as needed. MPASM uses temporary files when building the symbol table. This error could be caused by a DOS disk write error, if the disk is full. Too many arguments An opcode has been given too many operands, or a macro has been invoked with too many arguments. Check the processor's instruction set for the proper opcode syntax, or verify the number of arguments in the macro definition. Undefined argument A label is being used that has not yet been defined. The label might be used as an operand or as a macro argument. If there is a mistake in the argument list of a macro definition, this error message will appear when the macro is invoked, since the arguments were never properly defined. Unknown error An error has occurred which MPASM cannot understand. It is not any of the errors described in this appendix. Contact your Microchip Field Application Engineer (FAE) if you cannot debug this unknown error. While failed to terminate within 256 iterations The end condition of a WHILE loop was never met. This is flagged as an "Unknown error" because MPASM doesn't know why the WHILE loop didn't terminate. Check your condition statement for proper syntax and logic. Warning Messages Addresses above 32K not currently supported. Using MaxRom. MPASM does not currently allow you to access memory above 0x8000 (32K). Eventually, addresses up to 64K will be supported, when the linker and librarian are implemented. Argument out of range, least significant bits used The operand is not between the maximum and minimum values allowed for this opcode in this processor family. Most "Argument out of range" errors are WARNING messages. The out-of-range argument is truncated to the maximum value allowed. However, any argument that can produce unexpected object code (for example, TRIS 0 would evaluate to a NOP) generates an ERROR message rather than a WARNING. ... Is not currently supported Any directive that is not currently supported generates this WARNING. Please look in the User's Guide for alternative directives, or contact your Microchip Field Applications Engineer for options. LCALL should only be used for multi-paged program memory You are using the LCALL opcode, when you should be using CALL instead. LCALL only applies for processors that have more than one page of program memory (such as the 16C57). LCALL uses 4 execution cycles, while CALL only uses 2. This is only a WARNING, and correct code is generated. This number is being treated as a binary representation The specified number is ambiguous, and could be interpreted as either a binary or hexadecimal number. MPASM is assuming that it is binary. Example: b0101. MPASM expects hexadecimal numbers to be represented as 0xb0101 or as H'b0101'. Warning level superceded by command line value (...) The warning level specified by the LIST directive's "w=" option is not taking effect, because a value has been specified on the command line with the /w option. Information Messages Crossing page boundary -- ensure page bits are set MPASM is informing you that a page boundary has been crossed, and is recommending that you check to see that you have properly set the page bits. Please refer to the data sheet for your specific processor to find its memory boundaries. Filling locations <...> through <...> with the value <...> This information message lets you know the locations and the value the FILL directive is filling. This is needed because the addresses and values are not shown in the object code section of the listing file. ... May not be handled as preprocessor directive The #DEFINE and #UNDEFINE directives generate this WARNING to inform you that these directives do not function exactly as you would expect them to operate in the C language. Please refer to the User's Guide descriptions for these directives to determine how they will behave. The ZERO directive will be discontinued. Please use FILL instead The ZERO directive was provided for backward compatibility. It will not be supported in the future. We highly recommend using the FILL directive in place of ZERO. FILL is more versatile, and is well documented. MPASM USER'S GUIDE Quick Reference This quick reference guide is supplied to give you all of the instructions for the Microchip family of microcontrollers, including their description, function and status bits modified. If more information is required, please refer to the data sheets for the PIC16/17 in question.Highlights щ Directive Summary щ PIC16C5X Instruction Set and Notes щ PIC16CXX Instruction Set and Notes щ PIC17CXX Instruction Set and NotesTerms PIC16C5X Microchip's low-end 8-bit microcontroller with 12-bit wide instruction set currently including: PIC16C54, PIC16C55, PIC16C56, PIC16C57, and PIC16C58. PIC16CXX Microchip's mid-range 8-bit microcontroller with 14-bit wide instruction set currently including: PIC16C71, PIC16C64, and PIC16C84. PIC17CXX Microchip's high-end 8-bit microcontroller family with 16-bit wide instruction set currently including PIC17C42. TABLE 9: Directive Summary Directive Description CBANK Future Feature CBLOCK Define a Block of Constants CONSTANT Declare Symbol Constant DATA Create Numeric and Text Data DB Declare Data of One Byte #DEFINE Define a Text Substitution Label DW Declare Data of One Word ELSE Begin Alternative Assembly Block to IF END End Program Block ENDC End an Automatic Constant Block ENDIF End conditional Assembly Block ENDM End a Macro Definition ENDW End a While Loop EQU Define an Assembly Constant ERROR Issue an Error Message "" EXITM Exit from a Macro EXPAND Expand Macro Listing FILL Specify Memory Fill Value IF Begin ConditionallyAssembled Code Block if IFDEF Execute If Symbol has Been Defined IFNDEF Execute If Symbol has not Been Defined INCLUDE Include Additional Source File LIST Listing Options LOCAL Declare Local Macro Variable MACRO Declare Macro Definition MESSG Create User Defined Message NOEXPAND Turn off Macro Expansion NOLIST Turn off Listing Output ORG Set Program Origin PAGE Insert Listing Page Eject PROCESSOR Set Processor Type RADIX Specify Default Radix RES Reserve Memory SET Define an Assembler Variable SPACE Insert Blank Listing Lines SUBTITLE Specify Program Subtitle TITLE Specify Program Title #UNDEFINE Delete a Substitution Label VARIABLE Declare Symbol Variable WHILE Perform Loop While Condition is TruePIC16C5X Instruction Set All instructions execute in a single instruction cycle unless otherwise noted. Any unused opcode is executed as a NOP. The instruction set is highly orthogonal and is grouped into three basic catagories: щ Byte Oriented operations щ Bit Oriented Operations щ Literal and Control Operations The following tables list the instructions recognized by the MPASM assembler, where: TABLE 10: PIC16C5X OPERAND CODES Field Description f Register file address (0x00 to 0xFF) W Working register (accumulator) b Bit address within an 8 bit file register k Literal field, constant data or label. x Don't care location. d Destination select; d = 0: store result in W (f0A), d = 1: store result in file register f. Default is d = 1. TABLE 11: PIC16C5X BYTE ORIENTED FILE REGISTER OPERATIONS Binary Hex Mnemonic Description0001 11df ffff 1Cf ADDWF f,d Add W and f0001 01df ffff 14f ANDWF f,d AND W and f0000 011f ffff 06f CLRF f Clear f0000 0110 0000 040 CLRW Clear W0010 01df ffff 24f COMF f,d Complement f0000 11df ffff 0Cf DECF f,d Decrement f0010 11df ffff 2Cf DECFSZ f,d Decrement f, skip if zero0010 10df ffff 28f INCF f,d Increment f0011 11df ffff 3Cf INCFSZ f,d Increment f, skip if zero0001 00df ffff 10f IORWF f,d Inclusive OR W and f0010 00df ffff 20f MOVF f,d Move f to f0000 001f ffff 02f MOVWF f Move W to f0000 0000 0000 000 NOP No operation 0011 01df ffff 34f RLF f,d Rotate left f0011 00df ffff 30f RRF f,d Rotate right f0000 10df ffff 08f SUBWF f,d Subtract W from f0011 10df ffff 38f SWAPF f,d Swap halves f0001 10df ffff 18f XORWF f,d Exclusive OR W and fTABLE 12: PIC16C5X BIT ORIENTED FILE REGISTER OPERATIONS Binary Hex Mnemonic Description 0110 bbbf ffff 4bf BCF f,b Bit clear f0101 bbbf ffff 5bf BSF f,b Bit set f 0110 bbbf ffff 6bf BTFSC f,b Bit test, skip if clear 0111 bbbf ffff 8bf BTFSS f,b Bit test, skip if setTABLE 13: PIC16C5X LITERAL AND CONTROL OPERATIONS Binary Hex Mnemonic Description 1110 kkkk kkkk Ekk ANDLW k And literal and W1001 kkkk kkkk 9kk CALL k Call subroutine0000 0000 0100 004 CLRWDT Clear watch dog timer101k kkkk kkkk Akk GOTO k Goto address k1101 kkkk kkkk Dkk IORLW k Incl. OR literal and W1100 kkkk kkkk Ckk MOVLW k Move Literal to W0000 0000 0010 002 OPTION Load OPTION register1000 kkkk kkk 8kk RETLW k Return with literal in W0000 0000 0011 003 SLEEP Go into stand by mode 0000 0000 0fff 00f TRIS f Tristate port f1111 kkkk kkkk Fkk XORLW k Exclusive OR literal and W PIC16C5X Notes 1.If the destination of any instruction is the program counter (register file 2), the 8-bit destination value will be loaded into the lower 8-bits of the program counter (PC) and the 9th bit of the PC will be cleared. For the PIC16C56 and PIC16C57, the upper 3 bits of the status register (register file 3), PA2:PA0, are loaded into the most significant 3 bits of the PC(11:9). In case of the GOTO instruction, the lower 9 bits of the PC are loaded with the destination address, and the 3 most significant bits of the PC(11:9) are loaded with PA2:PA0 from the status register. 2.When an I/O register is modified as a function of itself (i.e. MOVF 6,1) the value used will be the value present on the pins themselves. For example, a tristated pin with data latch "1" but is driven low by an external device will be relatched in the low state. 3.The instruction "TRIS f", where f = 5, 6, or 7 causes the contents of the W register to be written to the tristate latches of the specified file (port). A one forces the pin to a high impedance state and disables the output buffers. 4.If this instruction is executed on file register f1 (and, where applicable d=1), the prescaler will be cleared if assigned to the RTCC. PIC16CXX Instruction Set The PIC16CXX instruction set consists of 36 instructions, each a single 14-bit wide word. Most instructions operate on a file register, f, and the working register, W (accumulator). The result can be directed either to the file register or the W register or to both in the case of some instructions. A few instructions operate solely on a file register (BSF for example). All instructions execute in a single instruction cycle unless otherwise noted. Any unused opcode is executed as a NOP. The instruction set is highly orthogonal and is grouped into three basic catagories: щ Byte Oriented operations щ Bit Oriented Operations щ Literal and Control Operations The following tables list the instructions recognized by the MPASM assembler. TABLE 14: PIC16CXX BYTE ORIENTED FILE REGISTER OPERATIONS Binary Hex Mnemonic Description00 0111 dfff ffff 07ff ADDWF f,d Add W and f00 0101 dfff ffff 05ff ANDWF f,d AND W and f00 0001 1fff ffff 018f CLRF f Clear f00 0001 0xxx xxxx 0100 CLRW Clear W00 1001 dfff ffff 09ff COMF f,d Complement f00 0011 dfff ffff 03ff DECF f,d Decrement f00 1011 dfff ffff 0Bff DECFSZ f,d Decrement f, skip ifzero00 1010 dfff ffff 0Aff INCF f,d Increment f00 1111 dfff ffff 0Fff INCFSZ f,d Increment f, skip if zero00 0100 dfff ffff 04ff IORWF f,d Inclusive OR W and f00 1000 dfff ffff 08ff MOVF f,d Move f00 0000 1fff ffff 008f MOVWF f Move W to f00 0000 0xx0 0000 0000 NOP No operation00 1101 dfff ffff 0Dff RLF f,d Rotate left f 00 1100 dfff ffff 0Cff RRF f,d Rotate right f00 0110 dfff ffff 02ff SUBWF f,d Sutract W from f 00 1110 dfff ffff 0Eff SWAPF f,d Swap haves f00 0110 dfff ffff 06ff XORWF f,d Exclusive OR W and fTABLE 15: PIC16CXX BIT ORIENTED FILE REGISTER OPERATIONS Binary Hex Mnemonic Description01 00bb bfff ffff 1bff BCF f,b Bit clear f01 01bb bfff ffff 1bff BSF f,b Bit set f01 10bb bfff ffff 1bff BTFSC f,b Bit test, skip if clear01 11bb bfff ffff 1bff BTFSS f,b Bit test, skip if setTABLE 16: PIC16CXX LITERAL AND CONTROL OPERATIONSBinary Hex Mnemonic Description11 111x kkkk kkkk 3Ekk ADDLW k Add literal to W11 1001 kkkk kkkk 39kk ANDLW k And literal and W10 0kkk kkkk kkkk 2kkk CALL k Call subroutine 00 0000 0110 0100 0064 CLRWDT Clear watch dog timer10 1kkk kkkk kkkk 2kkk GOTO k Goto address k11 1000 kkkk kkkk 38kk IORLW k Incl. OR literal and W11 00xx kkkk kkkk 30kk MOVLW k Move Literal to W00 0000 0110 0010 0062 OPTION Load OPTION register W00 0000 0000 1001 0009 RETFIE Return from Interrupt11 01xx kkkk kkkk 34kk RETLW k Return with literal in W 00 0000 0000 1000 0008 RETURN Return from subroutine00 0000 0110 0011 0063 SLEEP Go into stand by mode11 110x kkkk kkkk 3Ckk SUBLW k Subtract W from literal00 0000 0110 0fff 006f TRIS f Tristate port f 11 1010 kkkk kkkk 3Akk XORLW k Exclusive OR literal and W PIC16CXX Notes 1. TRIS and OPTION instructions are included in the instruction set for upward compatability with the PIC16C5X products. Microchip strongly recommends not using these instructions for new code development. Instead of using these instructions, directly address the TRIS and OPTION registers to obtain equivalent control. These instructions may not be supported in future PIC16CXX products. 2. When an I/O register is modified as a function of itself (i.e. MOVF 6,1) the value used will be the value present on the pins themselves. For example, a tristated pin with data latch "1" but is driven low by an external device will be relatched in the low state. 3. If this instruction is executed on file register f1 (and, where applicable d=1), the prescaler will be cleared if assigned to the RTCC. PIC17C42 Instruction Set The PIC17C42 instruction set consists of 55 instructions, each a single 16-bit wide word. Most instructions operate on a file register, f, and the working register, W (accumulator). The result can be directed either to the file register or the W register or to both in the case of some instructions. A few instructions operate solely on a file register (BSF for example). All instructions execute in a single instruction cycle unless otherwise noted. Any unused opcode is executed as a NOP. The instruction set is highly orthogonal and is grouped into four basic catagories: щ Data Move Operations щ Arithmetic and Logical Operations щ Bit Manipulation Operations щ Special Control Operations The following tables list the instructions recognized by the MPASM assembler, where: TABLE 19: PIC17C42 OPERAND CODES Field Description f Register file address (0x00 to 0xFF) p Peripheral register file address (0x00 to 0x1f) b Bit address within an 8 bit file register i Table pointer control; i = 0: do not change, i = 1: increment after instruction execution. t Table byte select; t = 0: perform operation on lower byte, t = 1: peform operation on upper byte. k Literal field, constant data or label. x Don't care location. d Destination select; d = 0: store result in W (f0A), d = 1: store result in file register f. Default is d = 1.TABLE 20: PIC17C42 DATA MOVE INSTRUCTIONSBinary Hex Mnemonic Description011p pppp ffff ffff 6pff MOVFP f,p Move f to p1011 1000 kkkk kkkk B8kk MOVLB k Move literal to BSR010p pppp ffff ffff 4pff MOVPF p,f Move p to f 0000 0001 ffff ffff 01ff MOVWF f Move W to F w ’ fNone1010 10ti ffff ffff a8ff TABLRD t,i,f Read data from table latch into file f, then update table latch with 16-bit contents of memory location addressed by table pointer11ti ffff ffff ffff acff TABLWT t,i,f Write data from file f to table latch and then write 16-bit table latch to program memory location addressed by table pointer1010 00tx ffff ffff a0ff TLRD t,f Read data from table latch into file f (table latch unchanged)1010 01tx ffff ffff a4ff TLWT t,f Write data from file f into table latchTABLE 21: PIC17C42 ARITHMETIC AND LOGICAL INSTRUCTIONSBinary Hex Mnemonic Description1011 0001 kkkk kkkk b1kk ADDLW k Add literal to W0000 111d ffff ffff 0eff ADDWF f,d Add W to F0001 000d ffff ffff 10ff ADDWFC f,d Add W and Carry to f1011 0101 kkkk kkkk b5kk ANDLW k AND Literal and W0000 101d ffff ffff 0aff ANDWF f,d AND W with f0010 100d ffff ffff 28ff CLRF f,d Clear f and Clear d0001 001d ffff ffff 12ff COMF f,d Complement f0010 111d ffff ffff 2eff DAW f,d Dec. adjust W, store in f,d0000 011d ffff ffff 06ff DECF f,d Decrement f0001 010d ffff ffff 14ff INCF f,d Increment f1011 0011 kkkk kkkk b3kk IORLW k Inclusive OR literal with W0000 100d ffff ffff 08ff IORWF f,d Inclusive or W with f1011 0000 kkkk kkkk b0kk MOVLW k Move literal to W0010 110d ffff ffff 2cff NEGW f,d Negate W, store in f and d0001 101d ffff ffff 1aff RLCF f,d Rotate left through carry0010 001d ffff ffff 22ff RLNCF f,d Rotate left (no carry)0001 100d ffff ffff 18ff RRCF f,d Rotate right through carry0010 000d ffff ffff 20ff RRNCF f,d Rotate right (no carry)0010 101d ffff ffff 2aff SETF f,d Set f and Set d1011 0010 kkkk kkkk b2kk SUBLW k Subtract W from literal0000 010d ffff ffff 04ff SUBWF f,d Subtract W from f0000 001d ffff ffff 02ff SUBWFB f,d Subtract from f with borrow0001 110d ffff ffff 1cff SWAPF f,d Swap f1011 0100 kkkk kkkk b4kk XORLW k Exclusive OR literal with W0000 110d ffff ffff 0cff XORWF f,d Exclusive OR W with fTABLE 22: PIC17C42 PROGRAM CONTROL INSTRUCTIONSBinary Hex Mnemonic Description111k kkkk kkkk kkkk ekkk CALL k Subroutine call (within 8k page)0011 0001 ffff ffff 31ff CPFSEQ f Compare f/w, skip if f = w0011 0010 ffff ffff 32ff CPFSGT f Compare f/w, skip if f > w0011 0000 ffff ffff 30ff CPFSLT f Compare f/w, skip if f < w0001 011d ffff ffff 16ff DECFSZ f,d Decrement f, skip if 00010 011d ffff ffff 26ff DCFSNZ f,d Decrement f, skip if not 0110k kkkk kkkk kkkk ckkk GOTO k Unconditional branch (within 8k)0001 111d ffff ffff 1eff INCFSZ f,d Increment f, skip if zero0010 010d ffff ffff 24ff INFSNZ f,d Increment f, skip if not zero1011 0111 kkkk kkkk b7kk LCALL k Long Call (within 64k)0000 0000 0000 0101 0005 RETFIE Return from interrupt, enable interrupt1011 0110 kkkk kkkk b6kk RETLW k Return with literal in W0000 0000 0000 0010 0002 RETURN Return from subroutine0011 0011 ffff ffff 33ff TSTFSZ f Test f, skip if zeroTABLE 23: PIC17C42 BIT HANDLING INSTRUCTIONSBinary Hex Mnemonic Description1000 1bbb ffff ffff 8bff BCF f,b Bit clear f1000 0bbb ffff ffff 8bff BSF f,b Bit set f1001 1bbb ffff ffff 9bff BTFSC f,b Bit test, skip if clear1001 0bbb ffff ffff 9bff BTFSS f,b Bit test, skip if set0011 1bbb ffff ffff 3bff BTG f,b Bit toggle fTABLE 24: PIC17C42 SPECIAL CONTROL INSTRUCTIONSBinary Hex Mnemonic Description0000 0000 0000 0100 0004 CLRWT Clear watch dog timer0000 0000 0000 0100 0000 NOP No operation0000 0000 0000 0011 0003 SLEEP Enter sleep mode PIC17C42 Notes 1. 2's complement arithmetic 2. Unsigned arithmetic 3. If d=1, only the file is affected; if d=0, both W and the file are affected; if only W is required to be affected, then f=0ah (File 0ah) must be defined. 4. The hex representation is not accurate. The value of the bit to be modified has to be incorporated into the third digit. 5. During an LCALL, the contents of File 03h are loaded into the MSB of the PC and kkkk kkkk is loaded into File 02h, the LSB of the PC. 6. Multiple cycle instructions for EPROM programming when table pointer selects internal EPROM. The instruction is terminated by an interrupt event. When writing to external program memory, it is a two cycle instruction. 7. Two cycle instructions when condition is TRUE, else single cycle instruction. 8. Two cycle instruction, except for TABLRD to File 02h (Program Counter low byte) in which case it takes 3 cycles. 9. A skip means that instructions fetched during execution of current instruction are not executed. Instead, a NOP is executed. 10. Any instruction that writes to PCL (File 02h) is a two cycle instruction, except for TABLRD to File 02h, which is a three cycle instruction.




А так же :


Социум
К.Х. Момджян 1. Понятие социума Стремясь познать общественную жизнь людей, социальная философия сталкивается со многими трудностями, первая из которых — многозначность самого термина «общество». Раскрывая газеты, включая радио или телевизор, мы постоянно слышим рассуждения об «интересах общества», «перспективах общества», «кризисе общества» и т.


Хвастушки. Детское


Сергей: XLN Audio ADpak Funk Hybrid v1.5.1. http://s004.radikal.ru/i2>061003 ...


Патриарх Никон
Богданов А. П. Седьмой патриарх Московский и всея Руси прожил, кажется, несколько жизней: нижегородского крестьянина, сельского, затем московского священника Никиты Минова (1605-1630 гг.), беломорского монаха-аскета Никона (1630-1646 гг.), члена кружка ревнителей благочестия при Алексее Михайловиче, архимандрита родового монастыря Романовых, с 1648 г.


Налоговые агенты по Налоговому кодексу Российской Федерации при налогообложении иностранных юридических лиц
С 1 января 1999 года введена в действие первая часть Налогового кодекса Российской Федерации (далее - НК РФ), подготовка проекта которого вызвала в свое время столько противоречивых мнений. Для налогоплательщиков она принесла много нововведений, по большей части положительных, не известных доселе нашему законодательству и существовавших только в подзаконных актах и теории.


ЗаголовокПриглашаю умных и позитивных людей в сетевой бизнес.



The instruction set is highly orthogonal and is grouped into three basic catagories:
Сайт управляется системой uCoz