Instuction set

Similar documents
Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

Lecture (04) PIC16F84A (3)

Assembly Language Instructions

Chapter 13. PIC Family Microcontroller

SOLUTIONS!! DO NOT DISTRIBUTE!!

PIC 16F84A programming (II)

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

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

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

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

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

PIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

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

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

EEE111A/B Microprocessors

16.317: Microprocessor-Based Systems I Spring 2012

PIC16C63A/65B/73B/74B

16.317: Microprocessor-Based Systems I Summer 2012

ECE Test #1: Name

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

Section 31. Instruction Set

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

PTK8756B 8 Bit Micro-controller Data Sheet

Week1. EEE305 Microcontroller Key Points

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

ALU and Arithmetic Operations

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

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

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

Chapter 5 Sections 1 6 Dr. Iyad Jafar

DERTS Design Requirements (1): Microcontroller Architecture & Programming

Arithmetic,logic Instruction and Programs

Section 4. Architecture

16.317: Microprocessor-Based Systems I Fall 2012

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

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

PIC Discussion. By Eng. Tamar Jomaa

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

16.317: Microprocessor Systems Design I Fall 2015

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

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

An Introduction & Guide to JALV2

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

16.317: Microprocessor Systems Design I Spring 2015

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

Micro II and Embedded Systems

Chapter 3: Further Microcontrollers

CONNECT TO THE PIC. A Simple Development Board

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

16.317: Microprocessor Systems Design I Fall 2014

Controller Provides Display of Monitored Process Deviation

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

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

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

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

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

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

Lesson 4 Fun with W and F

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

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

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

Introduction to PICL and PICLab

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

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS 2008/9. Semester One

D:\PICstuff\PartCounter\PartCounter.asm

Application Note - PIC Source Code v1.1.doc

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

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

Performance & Applications

TMU3101. tenx technology, inc. GENERAL DESCRIPTION

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */

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

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

Power Aware Instruction Scheduling for Microcontrollers

Mod-5: PIC 18 Introduction 1. Module 5

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

Embedded System Design

Computer Engineering Capstone Design Summer A : Handheld Video Games

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

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

PROGRAMMING PIC MICROCONTROLLERS WITH MICRO C

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

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

MPASM and MPLINK PICmicro QUICK REFERENCE GUIDE

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver

Discrete Logic Replacement Message Dispatch Engine

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

16.317: Microprocessor Systems Design I Fall Exam 3 December 15, Name: ID #:

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

The University of Texas at Arlington Lecture 7

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

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

Beacon Keyers Using PIC s. Dave Powis, DL/G4HUP

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

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

EE 367 Introduction to Microprocessors Homework 6

Transcription:

Instuction set http://www.piclist.com/images/www/hobby_elec/e_pic3_1.htm#1 In PIC16 series, RISC(Reduced Instruction Set Computer) is adopted and the number of the instructions to use is 35 kinds. When clicking the mnemonic of each instruction, you can jump to the instruction specification. The terminology explanation Mnemonic : The assembler language which made an operation code plain Operands : The specification part except the operation code MSb LSb Flag d : Most Significant bit : Least Significant bit : The field of the STAUS register : Bit in each instruction that determines the placement of the result 1/0 : f gets answer/w gets answer W f : bi- operand arithmetic operations always involve W (the accumulator) : General Purpose Reg 7 bits of the instruction RP0/RP1 of status reg 9 bits : address 512 memory locations literal k address data : pass a value as part of the instruction either an address or data : literal is 11 bits 2048 address out of 8192 total program space : literal is 8 bits (data width for PIC16) REGISTER 2-1: STATUS: STATUS REGISTER R/W-0 R/W-0 R/W-0 R-1 R-1 R/W-x R/W-x R/W-x IRP RP1 RP0 TO PD Z DC (1) C (1) bit 7 bit 0 Mnemonic Operands Operation explanation Instruction code Flag Byte-oriented file register operations ADDWF f, d Add W and f C, DC, Z ANDWF f, d AND W with f Z CLRF f Clear f Z CLRW - Clear W Z COMF f, d Complement f Z DECF f, d Decrement f Z

DECFSZ f, d Decrement f, Skip if 0 INCF f, d Increment f Z INCFSZ f, d Increment f, Skip if 0 IORWF f, d Inclusive OR W with f Z MOVF f, d Move f Z MOVWF f Move W to f NOP - No Operation RLF f, d Rotate Left f through Carry C RRF f, d Rotate Right f through Carry C SUBWF f, d Subtract W from f C, DC, Z SWAPF f, d Swap nibbles in f XORWF f, d Exclusive OR W with f Z Bit-oriented file register operations BCF f, b Bit Clear f BSF f, b Bit Set f BTFSC f, b Bit Test f, Skip if Clear BTFSS f, b Bit Test f, Skip if Set Literal and control operations ADDLW k Add literal and W C, DC, Z ANDLW k AND literal with W Z

CALL k Call subroutine CLRWDT - Clear Watchdog Timer GOTO k Go to address IORLW k Inclusive OR literal with W Z MOVLW k Move literal to W RETFIE - Return from interrupt RETLW k Return with literal in W RETURN - Return from Subroutine SLEEP - Go into stanby mode SUBLW k Subtract W from literal C, DC, Z XORLW k Exclusive OR literal with W Z 11 10 9 8 7 6 5 4 3 2 1 0 Mnemonic C? Z? Description 12 BITS for instructions 2Bits 14 total bits 12 for instruction 2 for status 0 0 0 0 0 0 0 opcode 5b Miscellaneous instructions 0 0 0 0 0 0 0 0 0 0 0 0 NOP No operation (MOVW 0,W) 0 0 0 0 0 0 0 0 0 0 1 0 OPTION Copy W to OPTION register 0 0 0 0 0 0 0 0 0 0 1 1 SLEEP Go into standby mode 0 0 0 0 0 0 0 0 0 1 0 0 CLRWDT Restart watchdog timer 0 0 0 0 0 0 0 0 0 1 f TRIS f Copy W to tri-state register (f = 1, 2 or 3) 0 0 opcode 4b d register 5b ALU operations: dest OP(f,W)

0 0 0 0 0 0 1 f MOVWF f dest W 0 0 0 0 0 1 d f CLR f,d Z dest 0, usually written CLRW or CLRF f 0 0 0 0 1 0 d f SUBWF f,d C Z dest f W (dest f+~w+1) 0 0 0 0 1 1 d f DECF f,d Z dest f 1 0 0 0 1 0 0 d f IORWF f,d Z dest f W, logical inclusive or 0 0 0 1 0 1 d f ANDWF f,d Z dest f & W, logical and 0 0 0 1 1 0 d f XORWF f,d Z dest f ^ W, logical exclusive or 0 0 0 1 1 1 d f ADDWF f,d C Z dest f+w 0 0 1 0 0 0 d f MOVF f,d Z dest f 0 0 1 0 0 1 d f COMF f,d Z dest ~f, bitwise complement 0 0 1 0 1 0 d f INCF f,d Z dest f+1 0 0 1 0 1 1 d f DECFSZ f,d dest f 1, then skip if zero 0 0 1 1 0 0 d f RRF f,d C dest CARRY<<7 f>>1, rotate right through carry 0 0 1 1 0 1 d f RLF f,d C dest F<<1 CARRY, rotate left through carry 0 0 1 1 1 0 d f SWAPF f,d dest f<<4 f>>4, swap nibbles 0 0 1 1 1 1 d f INCFSZ f,d dest f+1, then skip if zero 0 1 op bit register Bit operations 0 1 0 0 bit f BCF f,b Clear bit b of f 0 1 0 1 bit f BSF f,b Set bit b of f 0 1 1 0 bit f BTFSC f,b Skip if bit b of f is clear 0 1 1 1 bit f BTFSS f,b Skip if bit b of f is set 1 0 op k Control transfers 1 0 0 0 k RETLW k Set W k, then return from subroutine 1 0 0 1 k CALL k Call subroutine, 8-bit address k 1 0 1 k GOTO k Jump to 9-bit address k[10] 1 1 op 8-bit immediate Operations with W and 8-bit literal: W OP(k,W) 1 1 0 0 k MOVLW k W k 1 1 0 1 k IORLW k Z W k W, bitwise logical or 1 1 1 0 k ANDLW k Z W k & W, bitwise and 1 1 1 1 k XORLW k Z W k ^ W, bitwise exclusive or 11 10 9 8 7 6 5 4 3 2 1 0 Mnemonic C? Z? Description Link between mikroc and these instructions: (see phystu/class 0f 2012/Matt Chamberlin/mikroC_2/xxx projects and code) You can directly execute an insruction asm assembly_instruction; Or a block of assembly asm { block of assembly instructions }

mikroc PRO for PIC has additional set of keywords that do not belong to the ANSI standard C language keywords: ("Keywords" are words that have special meaning to the C compiler e.g. instruction such as int, float) code data rx (This memory specifier variable stored in the Rx space (Register file).) at sbit bit sfr (This mem spec - with (rx, data) - access spec func reg. - maintain same identifier in C& assembly.) sfr keyword ids variables as register references and allows bit manipulation (ids variables as specific bits in a register (special function register (SFR)). sbit name = sfr-name ^ bit-position; sbit name = sfr-address ^ bit-position; sbit name = sbit-address; (http://www.keil.com/support/man/docs/c166/c166_le_sbit.htm) sfr PSW = 0xFF10; //PSW refers to a regiser with an absolute address sbit USR0 = PSW ^ 6; // USR0 refers to bit 6 in PSW sfr / sbit signifies both a data- type and storage class, they are used to describe the special function registers and special bit variables of a 8051. (Associating identifiers with objects requires each identifier to have at least two attributes: storage class and type. Storge classes are used to define the scope (visability) and life time of variables. static is a storage class that makes the variable constant. extern is a storage class that makes variables global.) A storage class dictates the location (data segment, register, heap, or stack) of object and its duration or lifetime. All PIC SFR registers and their bits are implicitly declared as global variables. These identifiers have an external linkage, and are visible in the entire project. When creating a project, the mikroc PRO for PIC will include an appropriate (*) file from defs folder, containing declarations of available SFR registers and constants.//// Special function registers (SFRs) sfr unsigned short volatile INDF absolute 0x0000; sfr unsigned short volatile TMR0 absolute 0x0001; sfr unsigned short volatile PCL absolute 0x0002; sfr unsigned short volatile STATUS absolute 0x0003; sfr unsigned short FSR absolute 0x0004; register unsigned short *FSRPTR absolute 0x0004; sfr unsigned short volatile PCLATH absolute 0x000A; sfr unsigned short volatile INTCON absolute 0x000B; storage-class [type-qualifier] type var1 [=init1]