EECE.3170 Microprocessor Systems Design I

Slides:



Advertisements
Similar presentations
Instruction formats for the PIC series. ROM encoding Instructions are encoded in binary in ROM. The instructions are fixed format, each occupying 14 bits.
Advertisements

Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Prof. Jorge A. Ramón Introducción a Microcontroladores.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2013 Lecture 26: PIC microcontroller intro.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 30: PIC data memory.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2013 Lecture 27: PIC instruction set.
Microprocessor Systems Design I
Chapter 4 Starting to Program – an Introduction to Assembler The aims of this chapter are to introduce: the essentials of Assembler programming; the Microchip.
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Instruction Set.
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Programmers Model and Instruction Set.
Building Assembler Programs Chapter Five Dr. Gheith Abandah1.
Microprocessor and Interfacing PIC Code Execution
PIC18F Programming Model and Instruction Set
Lecture – 4 PIC18 Family Instruction Set 1. Outline Literal instructions. Bit-oriented instructions. Byte-oriented instructions. Program control instructions.
Embedded System Spring, 2011 Lecture 11: Bank Switching Eng. Wazen M. Shbair.
EEE237 Introduction to Microprocessors Week x. SFRs.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
V 0.11 Extended Precision Operations To represent larger numbers, more bits are needed. N bits can represent the unsigned range 0 to 2 N -1. Bytes 1 Byte.
Embedded System Spring, 2011 Lecture 11: Bank Switching Eng. Wazen M. Shbair.
PIC12F629/675. “Wide variety” 8-84 pin RISC core, 12/14/16bit program word USART/AUSART, I 2 C, ADC, ICSP, ICD OTP/UV EPROM/FLASH/ROM Families: PIC12,
1.  List all addressing modes of PIC18 uCs  Contrast and compare the addressing modes  Code PIC18 instructions to manipulate a lookup table.  Access.
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Lecture – 5 Assembly Language Programming
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Micro-processor vs. Micro-controller
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
C. K. PITHAWALA COLLEGE OF ENGINEERING AND TECHNOLOGY
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
PIC – ch. 2b Md. Atiqur Rahman Ahad.
PIC 16F877.
16.317: Microprocessor System Design I
Microprocessor Systems Design I
PIC18 CH. 4.
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Instruction Set.
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Chapter 4 Instruction Set.
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Presentation transcript:

EECE.3170 Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2016 Lecture 20: PIC instruction set

Microprocessors I: Lecture 20 Lecture outline Announcements/reminders HW 5 due 1:00 PM, 3/21 Coming up: HW 6 due 1:00 PM, 3/28—no late submissions Exam 2 in class Wednesday, 3/30 PICkits to be handed out after break Will have to work in groups (3 students preferred size) Today’s lecture: PIC instruction set intro 4/17/2019 Microprocessors I: Lecture 20

Microprocessors I: Lecture 20 4/17/2019 PIC16F1829 Instructions 49 instructions Each instruction is 14 bits Byte-oriented OPCODE f, F(W) Source f: name of a SFR or a RAM variable Destination F(W): F if the destination is to be the same as the source register W if the destination is to be the working register Bit-oriented OPCODE f, b Bit address b (0≤b≤7) Literal and control OPCODE k Literal value k 4/17/2019 Microprocessors I: Lecture 20 Chapter 9

PIC16F1829 Instructions (cont.) 4/17/2019 PIC16F1829 Instructions (cont.) MOVLP/MOVLB: move literal to PCL/BSR BRA: Relative branch FSR instructions used in indirect addressing 4/17/2019 Microprocessors I: Lecture 20 Chapter 9

Microprocessors I: Lecture 20 RAM variables Memory variable: symbolic name to refer to space in memory (GPRs) Usable space on 16F1829: offsets 0x20–0x7F Once declared, use symbolic name, not address Example PIC syntax (cblock/endc): cblock 0x20 ; cblock directive needs starting ; address var1 ; var1 = byte at 0x20 var2 ; var2 = byte at 0x21 var3 ; var3 = byte at 0x22 endc ; End of variable block 4/17/2019 Microprocessors I: Lecture 20

Microprocessors I: Lecture 20 4/17/2019 Microprocessors I: Lecture 20

Microprocessors I: Lecture 20 4/17/2019 Microprocessors I: Lecture 20

Microprocessors I: Lecture 20 4/17/2019 Clear/Move clrw ; Clear W register clrf f ; Clear f register movlw k ; move literal value k to W movwf f ; move W to f movf f, F(W) ; move f to F or W swapf f, F(W) ; swap nibbles of f, putting result in F or W STATUS bits: clrw, clrf, movf: Z movlw, movwf, swapf: none Examples: clrf TEMP1 ;Clear variable TEMP1 movlw 5 ;load 5 into W movwf TEMP1 ;move W into TEMP1 movwf TEMP1, F ;Incorrect Syntax movf TEMP1, W ;move TEMP1 into W ; movf TEMP1, TEMP2 ;Incorrect Syntax swapf TEMP1, F ;Swap 4-bit nibbles of TEMP1 swapf TEMP1, W ;Move TEMP1 to W, swap nibbles, leave TEMP1 unchanged 4/17/2019 Microprocessors I: Lecture 20 Chapter 9

Single Bit Manipulation 4/17/2019 Single Bit Manipulation bcf f,b Operation: Clear bit b of register f, where b=0 to 7 bsf f,b Operation: Set bit b of register f, where b=0 to 7 STATUS bits: none Examples: bcf PORTB, 0 ;Clear bit 0 off PORTB bsf STATUS, C ;Set the Carry bit 4/17/2019 Microprocessors I: Lecture 20 Chapter 9

Microprocessors I: Lecture 20 Example Show the values of all changed registers after the following sequence cblock 0x30 x y endc clrw movwf x movlw 0xFE movwf y swapf y, F bcf y, 3 bsf x, 3 movf y, W 4/17/2019 Microprocessors I: Lecture 20

Microprocessors I: Lecture 20 Example solution clrw  W = 0x00 movwf x  x = W = 0x00 movlw 0xFE  W = 0xFE movwf y  y = W = 0xFE swapf y, F  Swap nibbles of y  y = 0xEF bcf y, 3  Clear bit 3 of y = 1110 11112  y = 1110 01112 = 0xE7 bsf x, 3  Set bit 3 of x  x = 0000 10002 = 0x08 movf y, W  W = y = 0xE7 4/17/2019 Microprocessors I: Lecture 20

Increment/Decrement/ Complement 4/17/2019 Increment/Decrement/ Complement incf f, F(W) ; increment f, putting result in F or W decf f, F(W) ;decrement f, putting result in F or W comf f, F(W) ;complement f, putting result in F or W STATUS bits: Z Examples: incf TEMP1, F ;Increment TEMP1 incf TEMP1, W ;W <- TEMP1+1; TEMP1 unchanged decf TEMP1, F ;Decrement TEMP1 comf TEMP1, F ;Change 0s and 1s to 1s and 0s 4/17/2019 Microprocessors I: Lecture 20 Chapter 9

Addition/Subtraction 4/17/2019 Addition/Subtraction addlw k ;add literal value k into W addwf f, F(W) ;add w and f, putting result in F or W sublw k ;subtract W from literal value k, putting ;result in W subwf f, F(W) ;subtract W from f, putting result in F or W STATUS bits: C, DC, Z Examples: addlw 5 ; W <= 5+W addwf TEMP1, F ; TEMP1 <- TEMP1+W sublw 5 ; W <= 5-W (not W <= W-5 ) subwf TEMP1, F ; TEMP1 <= TEMP1 - W 4/17/2019 Microprocessors I: Lecture 20 Chapter 9

Microprocessors I: Lecture 20 Final notes Next time: Continue with PIC instructions (M 3/21) Enjoy your break! Reminders: HW 5 due 1:00 PM, 3/21 Coming up: HW 6 due 1:00 PM, 3/28—no late submissions Exam 2 in class Wednesday, 3/30 PICkits to be handed out after break Will have to work in groups (3 students preferred size) 4/17/2019 Microprocessors I: Lecture 20