PIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

Similar documents
PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

PIC16C63A/65B/73B/74B

Assembly Language Instructions

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

Instuction set

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

SOLUTIONS!! DO NOT DISTRIBUTE!!

Chapter 13. PIC Family Microcontroller

Lecture (04) PIC16F84A (3)

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

PIC 16F84A programming (II)

16.317: Microprocessor-Based Systems I Spring 2012

Section 31. Instruction Set

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

EEE111A/B Microprocessors

Section 4. Architecture

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

ECE Test #1: Name

Fortune. Semiconductor Corporation 富晶半導體股份有限公司. 8-bit MCU with 1k program ROM, 64-byte RAM, 1 R2F module and 3 13 LCD driver. TD Rev. 1.

PTK8756B 8 Bit Micro-controller Data Sheet

Week1. EEE305 Microcontroller Key Points

TM57PA20/ TM57PA40. 8 Bit Microcontroller. User Manual. Tenx reserves the right to change or discontinue this product without notice.

16.317: Microprocessor-Based Systems I Summer 2012

Arithmetic,logic Instruction and Programs

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

16.317: Microprocessor-Based Systems I Fall 2012

DERTS Design Requirements (1): Microcontroller Architecture & Programming

/ 28 HLL assembly Q4: Conditional instructions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

PIC Discussion. By Eng. Tamar Jomaa

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

PIN DESCRIPTION Name I/O Description VDD P VSS P 5V Power from USB cable Ground RC6M O X1 I Test/OTP mode clock in Internal clock output (6MHz) VPP I

ABOV SEMICONDUCTOR 8-BIT SINGLE-CHIP MICROCONTROLLERS MC71PD506. USER S MANUAL (Ver. 1.0)

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

/ 40 Q3: Writing PIC / 40 assembly language TOTAL SCORE / 100 EXTRA CREDIT / 10

16.317: Microprocessor Systems Design I Spring 2015

Chapter 3: Further Microcontrollers

16.317: Microprocessor Systems Design I Fall 2014

Q1: Multiple choice / 20 Q2: Protected mode memory accesses. / 40 Q3: Reading PIC. / 40 assembly language TOTAL SCORE / 100

movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt

ALU and Arithmetic Operations

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

4.5.1) The Label Field ) The Mnemonic Field. 4.5) Assembly Language Program Structure A PIC18 ALP consists of 3 type of statements:

CONNECT TO THE PIC. A Simple Development Board

D:\PICstuff\PartCounter\PartCounter.asm

Mod-5: PIC 18 Introduction 1. Module 5

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features:

Arithmetic and Logic Instructions. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

Introduction to PIC Programming

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

PIC Discussion By Eng. Tamar Jomaa

16.317: Microprocessor Systems Design I Fall 2015

Chapter 5 Sections 1 6 Dr. Iyad Jafar

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features:

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

S w e d i s h c r. w e e b l y. c o m j a l i l a h m e l i v e. c o m Page 1

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet:

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

Power Aware Instruction Scheduling for Microcontrollers

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

A Better Mouse Trap. Consumer Appliance, Widget, Gadget APPLICATION OPERATION: Ontario, Canada

PROGRAMMING PIC MICROCONTROLLERS WITH MICRO C

ECE 354 Introduction to Lab 2. February 23 rd, 2003

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

RISC8 Core Page 1. RISC8 Core. Version 1.0. Written by Tom Coonan

More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller

Assembly Language Programming of 8085

PIC Architecture & Assembly Language Programming. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Embedded System Design

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

PART TWO LISTING 8 PROGRAM TK3TUT8 MOVF PORTA,W ANDLW B ADDWF COUNT,F MOVF COUNT,W MOVWF PORTB GOTO LOOP

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

PIC10F200/202/204/206 Data Sheet

Controller Provides Display of Monitored Process Deviation

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver

Lesson 4 Fun with W and F

The University of Texas at Arlington Lecture 7

An Introduction & Guide to JALV2

Here is a sample of the Hellschrieber sent by this project: Following is the PIC MPASM Source Code for Version 0.03 of the Beacon:

Assembly Language Programming of 8085

ME 515 Mechatronics. A microprocessor

Discrete Logic Replacement A Keypad Controller for Bi-directional Key Matrix

PIC10F200/202/204/206

68HC11 PROGRAMMER'S MODEL

MPASM and MPLINK PICmicro QUICK REFERENCE GUIDE

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics:

Performance & Applications

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

Midrange 8b PIC Microcontrollers. ECE Senior Design 14 February 2017

Micro II and Embedded Systems

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

These 3 registers contain enable, priority,

Semester 1. Module Code: EEE305J1. Module Title: MICROCONTROLLER SYSTEMS

Application Note - PIC Source Code v1.1.doc

Transcription:

PI6F84A 7.0 INSTRUTION SET SUMMARY Each PI6XX instruction is a 4bit word, divided into an OPODE which specifies the instruction type and one or more operands which further specify the operation of the instruction. The PI6XX instruction set summary in Table 7 lists byteoriented, bitoriented, and literal and control operations. Table 7 shows the opcode field descriptions. For byteoriented instructions, f represents a file register designator and d represents a destination designator. The file register designator specifies which file register is to be used by the instruction. The destination designator specifies where the result of the operation is to be placed. If d is zero, the result is placed in the W register. If d is one, the result is placed in the file register specified in the instruction. For bitoriented instructions, b represents a bit field designator which selects the number of the bit affected by the operation, while f represents the address of the file in which the bit is located. For literal and control operations, represents an eight or eleven bit constant or literal value. TABLE 7: Field f W b OPODE FIELD DESRIPTIONS Description Register file address (0x to 0x7F) Woring register (accumulator) Bit address within an 8bit file register Literal field, constant data or label x Don't care location (= 0 or ) The assembler will generate code with x = 0. It is the recommended form of use for compatibility with all Microchip software tools. d Destination select; d = 0: store result in W, d = : store result in file register f. Default is d = P TO PD Program ounter Timeout bit Powerdown bit The instruction set is highly orthogonal and is grouped into three basic categories: Byteoriented operations Bitoriented operations Literal and control operations All instructions are executed within one single instruction cycle, unless a conditional test is true or the program counter is changed as a result of an instruction. In this case, the execution taes two instruction cycles with the second cycle executed as a NOP. One instruction cycle consists of four oscillator periods. Thus, for an oscillator frequency of 4 MHz, the normal instruction execution time is µs. If a conditional test is true or the program counter is changed as a result of an instruction, the instruction execution time is µs. Table 7 lists the instructions recognized by the MPASM Assembler. Figure 7 shows the general formats that the instructions can have. Note: All examples use the following format to represent a hexadecimal number: 0xhh where h signifies a hexadecimal digit. FIGURE 7: To maintain upward compatibility with future PI6XX products, do not use the OPTION and TRIS instructions. GENERAL FORMAT FOR INSTRUTIONS Byteoriented file register operations 3 8 7 6 0 OPODE d f (FILE #) d = 0 for destination W d = for destination f f = 7bit file register address Bitoriented file register operations 3 0 9 7 6 0 OPODE b (BIT #) f (FILE #) b = 3bit bit address f = 7bit file register address Literal and control operations General 3 8 7 0 OPODE = 8bit immediate value ALL and GOTO instructions only (literal) 3 0 0 OPODE = bit immediate value (literal) A description of each instruction is available in the PImicro MidRange Reference Manual (DS3303). 0 Microchip Technology Inc. DS357Bpage 35

PI6F84A TABLE 7: PI6XXX INSTRUTION SET Mnemonic, Operands Description ycles MSb 4Bit Opcode LSb Status Affected Notes ADDWF ANDWF LRF LRW OMF DEF DEFS INF INFS IORWF MOVF MOVWF NOP RLF RRF SUBWF SWAPF XORWF BF BSF BTFS BTFSS ADDLW ANDLW ALL LRWDT GOTO IORLW MOVLW RETFIE RETLW RETURN SLEEP SUBLW XORLW f f f, b f, b f, b f, b Add W and f AND W with f lear f lear W omplement f Decrement f Decrement f, Sip if 0 Increment f Increment f, Sip if 0 Inclusive OR W with f Move f Move W to f No Operation Rotate Left f through arry Rotate Right f through arry Subtract W from f Swap nibbles in f Exclusive OR W with f Bit lear f Bit Set f Bit Test f, Sip if lear Bit Test f, Sip if Set Add literal and W AND literal with W all subroutine lear Watchdog Timer Go to address Inclusive OR literal with W Move literal to W Return from interrupt Return with literal in W Return from Subroutine Go into standby mode Subtract W from literal Exclusive OR literal with W BYTEORIENTED FILE REGISTER OPERATIONS () () BITORIENTED FILE REGISTER OPERATIONS () () 0 0 0 0 LITERAL AND ONTROL OPERATIONS 0 0 0 0 0 0 0 0 0 0 0 bb 0bb 0bb bb x 0 0 xx 0xx 0x lfff 0xxx lfff 0xx0 bfff bfff bfff bfff xxxx 0 0,D,,D,,D, TO,PD TO,PD,D, Note : When an I/O register is modified as a function of itself ( e.g., MOVF PORTB, ), the value used will be that value present on the pins themselves. For example, if the data latch is for a pin configured as input and is driven low by an external device, the data will be written bac with a 0. : If this instruction is executed on the TMR0 register (and, where applicable, d = ), the prescaler will be cleared if assigned to the Timer0 Module. 3: If Program ounter (P) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is executed as a NOP.,,,,,,3,,,3,,,,,,,,, 3 3 Note: Additional information on the midrange instruction set is available in the PImicro MidRange MU Family Reference Manual (DS3303). DS357Bpage 36 0 Microchip Technology Inc.

PI6F84A 7. Instruction Descriptions ADDLW Add Literal and W [label] ADDLW 0 55 (W) + (W), D, The contents of the W register are added to the eightbit literal and the result is placed in the W register. BF Bit lear f [label] BF f,b 0 f 7 0 b 7 0 (f<b>) Bit 'b' in register 'f' is cleared. ADDWF Add W and f [label] ADDWF f,d 0 f 7 d [0,] (W) + (f) (destination), D, Add the contents of the W register with If d is 0, the result is stored in the W register. If d is, the result is stored bac in BSF Bit Set f [label] BSF f,b 0 f 7 0 b 7 (f<b>) Bit 'b' in register 'f' is set. ANDLW AND Literal with W [label] ANDLW 0 55 ANDWF (W).AND. () (W) The contents of W register are AND ed with the eightbit literal ''. The result is placed in the W register. AND W with f [label] ANDWF f,d 0 f 7 d [0,] (W).AND. (f) (destination) AND the W register with register 'f'. If 'd' is 0, the result is stored in the W register. If 'd' is, the result is stored bac in register 'f'. BTFSS Bit Test f, Sip if Set [label] BTFSS f,b 0 f 7 0 b < 7 sip if (f<b>) = If bit 'b' in register 'f' is '0', the next instruction is executed. If bit 'b' is '', then the next instruction is discarded and a NOP is executed instead, maing this a TY instruction. 0 Microchip Technology Inc. DS357Bpage 37

PI6F84A BTFS Bit Test, Sip if lear [label] BTFS f,b 0 f 7 0 b 7 sip if (f<b>) = 0 If bit b in register f is, the next instruction is executed. If bit b in register f is 0, the next instruction is discarded, and a NOP is executed instead, maing this a TY instruction. LRWDT lear Watchdog Timer [ label ] LRWDT h WDT 0 WDT prescaler, TO PD TO, PD LRWDT instruction resets the Watchdog Timer. It also resets the prescaler of the WDT. Status bits TO and PD are set. ALL all Subroutine [ label ] ALL 0 047 (P)+ TOS, P<0:0>, (PLATH<4:3>) P<:> all Subroutine. First, return address (P+) is pushed onto the stac. The elevenbit immediate address is loaded into P bits <0:0>. The upper bits of the P are loaded from PLATH. ALL is a twocycle instruction. OMF omplement f [ label ] OMF f,d 0 f 7 d [0,] (f) (destination) complemented. If d is 0, the result is stored in W. If d is, the result is stored bac in LRF lear f [label] LRF f 0 f 7 LRW h (f) cleared and the bit is set. lear W [ label ] LRW h (W) W register is cleared. ero bit () is set. DEF Decrement f [label] DEF f,d 0 f 7 d [0,] (f) (destination) Decrement If d is 0, the result is stored in the W register. If d is, the result is stored bac in DS357Bpage 38 0 Microchip Technology Inc.

PI6F84A DEFS Decrement f, Sip if 0 0 f 7 d [0,] [ label ] DEFS f,d (f) (destination); sip if result = 0 decremented. If d is 0, the result is placed in the W register. If d is, the result is placed bac in If the result is, the next instruction is executed. If the result is 0, then a NOP is executed instead, maing it a TY instruction. INFS Increment f, Sip if 0 0 f 7 d [0,] [ label ] INFS f,d (f) + (destination), sip if result = 0 incremented. If d is 0, the result is placed in the W register. If d is, the result is placed bac in If the result is, the next instruction is executed. If the result is 0, a NOP is executed instead, maing it a TY instruction. GOTO Unconditional Branch [ label ] GOTO 0 047 P<0:0> PLATH<4:3> P<:> GOTO is an unconditional branch. The elevenbit immediate value is loaded into P bits <0:0>. The upper bits of P are loaded from PLATH<4:3>. GOTO is a twocycle instruction. IORLW Inclusive OR Literal with W [ label ] IORLW 0 55 (W).OR. (W) The contents of the W register are OR ed with the eightbit literal ''. The result is placed in the W register. INF Increment f [ label ] INF f,d 0 f 7 d [0,] (f) + (destination) incremented. If d is 0, the result is placed in the W register. If d is, the result is placed bac in IORWF 0 f 7 d [0,] Inclusive OR W with f [ label ] IORWF f,d (W).OR. (f) (destination) Inclusive OR the W register with register 'f'. If 'd' is 0, the result is placed in the W register. If 'd' is, the result is placed bac in register 'f'. 0 Microchip Technology Inc. DS357Bpage 39

PI6F84A MOVF Move f [ label ] MOVF f,d 0 f 7 d [0,] (f) (destination) The contents of register f are moved to a destination dependant upon the status of d. If d = 0, destination is W register. If d =, the destination is file register f itself. d = is useful to test a file register, since status flag is affected. RETFIE Return from Interrupt [ label ] RETFIE TOS P, GIE MOVLW Move Literal to W [ label ] MOVLW 0 55 (W) The eightbit literal is loaded into W register. The don t cares will assemble as 0 s. RETLW Return with Literal in W [ label ] RETLW 0 55 (W); TOS P The W register is loaded with the eightbit literal ''. The program counter is loaded from the top of the stac (the return address). This is a twocycle instruction. MOVWF Move W to f [ label ] MOVWF f 0 f 7 (W) (f) Move data from W register to register 'f'. RETURN Return from Subroutine [ label ] RETURN TOS P Return from subroutine. The stac is POPed and the top of the stac (TOS) is loaded into the program counter. This is a twocycle instruction. NOP No Operation [ label ] NOP No operation No operation. DS357Bpage 40 0 Microchip Technology Inc.

PI6F84A RLF Rotate Left f through arry [ label ] RLF f,d 0 f 7 d [0,] See description below rotated one bit to the left through the arry Flag. If d is 0, the result is placed in the W register. If d is, the result is stored bac in Register f SUBLW Subtract W from Literal [ label ] SUBLW 0 55 (W) (W), D, The W register is subtracted ( s complement method) from the eightbit literal ''. The result is placed in the W register. RRF Rotate Right f through arry [ label ] RRF f,d 0 f 7 d [0,] See description below rotated one bit to the right through the arry Flag. If d is 0, the result is placed in the W register. If d is, the result is placed bac in Register f SUBWF Subtract W from f [ label ] SUBWF f,d 0 f 7 d [0,], D, (f) (W) (destination) Subtract ( s complement method) W register from register 'f'. If 'd' is 0, the result is stored in the W register. If 'd' is, the result is stored bac in register 'f'. SLEEP [ label ] SLEEP h WDT, 0 WDT prescaler, TO, 0 PD TO, PD The powerdown status bit, PD is cleared. Timeout status bit, TO is set. Watchdog Timer and its prescaler are cleared. The processor is put into SLEEP mode with the oscillator stopped. SWAPF Swap Nibbles in f [ label ] SWAPF f,d 0 f 7 d [0,] (f<3:0>) (destination<7:4>), (f<7:4>) (destination<3:0>) The upper and lower nibbles of register 'f' are exchanged. If 'd' is 0, the result is placed in W register. If 'd' is, the result is placed in register 'f'. 0 Microchip Technology Inc. DS357Bpage 4

PI6F84A XORLW Exclusive OR Literal with W [label] XORLW 0 55 (W).XOR. (W) The contents of the W register are XOR ed with the eightbit literal ''. The result is placed in the W register. XORWF Exclusive OR W with f [label] XORWF f,d 0 f 7 d [0,] (W).XOR. (f) (destination) Exclusive OR the contents of the W register with register 'f'. If 'd' is 0, the result is stored in the W register. If 'd' is, the result is stored bac in register 'f'. DS357Bpage 4 0 Microchip Technology Inc.