PIC Controller

20
PIC Controller Instruction format

description

PIC Controller. Instruction format. RISC (Reduced Instruction Set Computing) or ‘Risk’. Is a CPU design method that gives an instruction set reduced both in size and complexity of addressing modes . Every small operation needs an instruction. - PowerPoint PPT Presentation

Transcript of PIC Controller

Page 1: PIC Controller

PIC Controller

Instruction format

Page 2: PIC Controller

RISC (Reduced Instruction Set Computing) or ‘Risk’ Is a CPU design method that gives an

instruction set reduced both in size and complexity of addressing modes.

Every small operation needs an instruction. Load data from memory to working register,

Add some data, Store the data in to memory – needs 3 instructions.

Ex. ARM, PIC, AVR, SPARC, etc.

Page 3: PIC Controller

CISC (Complex Instruction Set Computing) or ‘Sisk’ Is a microprocessor architecture that gives an

instruction set which can execute many low level operations.

Load data from memory to working register, Arithmetic/Logical operation, Store data into memory – can be done in 1 instruction.

Ex. Intel, AMD, Motorola, etc.

Page 4: PIC Controller

Introduction Instructions do data transfer between the

data memory [SFR (control/configuration registers), GPR, repetitive registers] and working register (W).

Instructions do Arithmetic, logical operations on the data.

Instruction can check the status of each operation and decide the next operation using the status register.

Page 5: PIC Controller

Working Register (Accumulator) Whenever a double operand instruction is

executed, one operand comes from the instruction or from a register. The other operand comes from a register called working register.

This is a special register in CPU (not a part of data memory)

This is the default destination for any instruction.

Page 6: PIC Controller

StatusRegister

Page 7: PIC Controller

StatusRegister

Page 8: PIC Controller

Introduction Each instruction is 14 bit wide

Opcode Specifies instruction type

One or two operands Specifies operation of instruction

Three basic categories Byte oriented Bit oriented Literal and control operations

Page 9: PIC Controller

Inst

ruct

ion

F

orm

ats

Page 10: PIC Controller

OPCODE Field Descriptions

Page 11: PIC Controller

Byte Oriented Operations

Page 12: PIC Controller
Page 13: PIC Controller

Instructions

Page 14: PIC Controller
Page 15: PIC Controller

Assembly Language Each instruction typically consists of an operation or opcode plus zero or more operands.

A label can be specified before each instruction.

Labels are case sensitive and start with an alphabetic or underscore character only.

Page 16: PIC Controller

Assembly Language The instructions must be written in proper

case. The MPASM is case sensitive.

All function registers and their bits are specified in upper case, because upper case is used in the included PIC file.

Use comment for every instruction.

Page 17: PIC Controller

Assembly Language Sample Instruction:

NEXT MOVF FSR,W ;move the contents of FSR to W.

‘NEXT’ is called the Label. ‘MOVF’ is called the Mnemonic. ‘FSR, W’ are called the Operands. ‘;move the contents….’ is the Comment.

Page 18: PIC Controller

Assembly Language Sample Instruction:

_OP1 IORLW 0xFF ;Inclusive OR the contents of W with 1111 1111.

‘_OP1’ is called the Label. ‘IORLW’ is called the Mnemonic. ‘0xFF’ are called the Operands. ‘;Inclusive OR the ….’ is the Comment.

Page 19: PIC Controller

Assembler Directives An assembler directive is a command given

to an assembler. Looks like assembly instructions These directives may do anything from telling

the assembler to include other source files, to allocate memory for constant data, etc.

Specific for each assembler software Ex: RIGHT EQU 1 ;equ is an assembler directive.

Page 20: PIC Controller

Program Structure: All programs must have the following

structure.List p=16f877A ; List directive mentioning the PIC

; Microcontroller part number

#include ‘C:\my_name\pic_lab\P16f877A.inc’

; file having standard definitions of SFR’s of this PIC

ORG 0x20 ; The address 0x20 at which the

; next instruction 'goto' will be stored

GOTO start ; Go to the beginning of main program

start

--------------------------- ;Program Logic

--------------------------- ;Program Logic

END