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

Control structures Hot to translate high level control structures to assembler.
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.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 29: Microcontroller intro.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2013 Lecture 27: PIC instruction set.
Microprocessor Systems Design I
Rodolfo Rodriguez Kevin Zhang MJ Gellada
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Instruction Set.
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Programmers Model and Instruction Set.
Two’s Complement Number wheel for 4 bit numbers
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.
PIC Processor Design CPE 428/528 April 29, 2002 Dr. Milenkovic Presented by: David Fatzer Le Pitts William Cruger Donn Hall.
EEE237 Introduction to Microprocessors Week x. SFRs.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
Architecture and instruction set. Microcontroller Core Features:  Operating speed: DC - 20 MHz clock input DC ns instruction cycle Up to 8K x.
V 0.41 C Arithmetic operators OperatorDescription +, -addition (i+j), subtraction (i-j) *, /multiplication (i*j), division (i/j) ++, --increment (i++),
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
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,
Chapter 5 Building Assembler Programs The aims of this chapter are to introduce: how to visualise a program, and represent it diagrammatically; how to.
Department of Electronic & Electrical Engineering Lecture 4. ➢ Loops ➢ Delays ➢ Conditional instructions ➢ Simple clock example.
I/O PORTS. General purpose I/O pins can be considered the simplest of peripherals. They allow the PICmicro™ to monitor and control other devices. To add.
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
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
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
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
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Presentation transcript:

16.317 Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2012 Lecture 22: PIC instruction set (cont.)

Microprocessors I: Lecture 22 Lecture outline Announcements/reminders HW 3 due today Lab 2 due 11/14 Exam 2: Wednesday, 11/7 Will post list of instructions to be included Today’s lecture: Review PIC ISA covered so far Continue with PIC instructions 6/10/2018 Microprocessors I: Lecture 22

Review: PIC instructions (cont.) Unary operations: incf/decf/comf Arithmetic: addlw/addwf/sublw/subwf Logical operations andlw/andwf iorlw/iorwf xorlw/xorwf Rotates rrf rlf 6/10/2018 Microprocessors I: Lecture 22

Multi-bit Manipulation 6/10/2018 Multi-bit Manipulation andlw k ; AND literal value k into W andwf f, F(W) ; AND W with F, putting result in F or W iorlw k ; Inclusive-OR literal value k into W iorwf f, F(W) ; Inclusive-OR W with F, putting result in F or W xorlw k ; Exclusive-OR literal value k into W xorwf f, F(W) ; Exclusive-OR W with F, putting result in F or W Examples: andlw B’00000111’ ;force upper 5 bits of W to zero andwf TEMP1, F ;TEMP1 <- TEMP1 AND W andwf TEMP1, W ;W <- TEMP1 AND W iorlw B’00000111’ ;force lower 3 bits of W to one iorwf TEMP1, F ;TEMP1 <- TEMP1 OR W xorlw B’00000111’ ;complement lower 3 bits of W xorwf TEMP1, W ;W <- TEMP1 XOR W STATUS bits: Z 6/10/2018 Microprocessors I: Lecture 22 Chapter 9

Microprocessors I: Lecture 22 6/10/2018 Rotate rlf f, F(W) ; copy f into F or W; rotate F or W left through ; the carry bit rrf f, F(W) ; copy f into F or W; rotate F or W right through STATUS bits: C Examples: rlf TEMP1, F ; C <- TEMP1.bit(7), TEMP1.bit(i+1) <- TEMP1.bit(i) ; TEMP1.bit(0) <- C rrf TEMP1, W ; Copy TEMP1 to W and rotate W right through C ; TEMP1 unchanged 6/10/2018 Microprocessors I: Lecture 22 Chapter 9

Microprocessors I: Lecture 22 Example Show the values of all changed registers after the following sequence Assume the carry bit is initially 0 cblock 0x40 z endc clrf z movlw 0xF0 iorwf z, F xorlw 0xFF rrf z, F andwf z, W rlf z, F 6/10/2018 Microprocessors I: Lecture 22

Microprocessors I: Lecture 22 Example solution clrf z  z = 0 movlw 0xF0  W = 0xF0 iorwf z, F  z = z OR W = 0xF0 xorlw 0xFF  W = W XOR 0xFF = 0xF0 XOR 0xFF = 0x0F rrf z, F  Rotate z right thru carry Before rotate, (z, carry) = 1111 0000 02  z = 0111 10002 = 0x78, C = 0 andwf z, W  W = z AND W = 0x78 AND 0x0F = 0x08 rlf z, F  Rotate z left thru carry Before rotate, (z, carry) = 0 0111 10002  z = 1111 00002 = 0xF0, C = 0 6/10/2018 Microprocessors I: Lecture 22

Goto/Call/Return/Return from Interrupt 6/10/2018 Goto/Call/Return/Return from Interrupt goto label ; Go to labeled instruction call label ; Call labeled subroutine return ; Return from subroutine retlw k ; Return from subroutine, putting literal ; value in W retfie ; Return from interrupt service routine; ; re-enable interrupts STATUS bits: none Examples: goto There ; Next instruction to be executed is labeled “There” call Task1 ; Push return address; Next instruction to be ; executed is labeled “Task1” return ; Pop return address off of stack retlw 5 ; Pop return address; W <- 5 retfie ; Pop return address; re-enable interrupts 6/10/2018 Microprocessors I: Lecture 22 Chapter 9

Conditional Execution 6/10/2018 Conditional Execution Conditional execution in PIC: skip next instruction if condition true Two general forms Test bit and skip if bit clear/set Increment/decrement register and skip if result is 0 STATUS bits: none btfsc f, b ;Test bit b of register f, where b=0 to 7, skip if clear btfss f, b ;Test bit b of register f, where b=0 to 7, skip if set decfsz f, F(W) ;decrement f, putting result in F or W, skip if zero incfsz f, F(W) ;increment f, putting result in F or W, skip if zero Examples: btfsc TEMP1, 0 ; Skip the next instruction if bit 0 of TEMP1 equals 0 btfss STATUS, C ; Skip the next instruction if C==1 decfsz TEMP1, F ; Decrement TEMP1, skip if TEMP1==0 incfsz TEMP1, W ; W <- TEMP1+1 , skip if W==0 (TEMP1==0xFF) ; Leave TEMP1 unchanged 6/10/2018 Microprocessors I: Lecture 22 Chapter 9

Microprocessors I: Lecture 22 Example Show the values of all changed registers after each of the following sequences What high-level operation does each perform? (b) movf NUM2, W subwf NUM1, W btfss STATUS, C goto BL movf NUM1, W goto Done BL movf NUM2, W Done movwf MIN (a) movf a, W sublw 0xA btfsc STATUS, Z goto L1 incf b, W goto L2 L1 decf b, W L2 movwf a 6/10/2018 Microprocessors I: Lecture 22

Example solution (part a) movf a, W  W = a sublw 0xA  W = 10 – a btfsc STATUS, Z  Skip goto if result is non-zero goto L1  Goto L1 if result == 0  Reach this point if result non-zero incf b, W  W = b + 1 goto L2 L1 decf b, W  W = b - 1 L2 movwf a  a = W  value depends on what’s executed before this High-level operation: if ((10 – a) == 0) a = b – 1 else a = b + 1 6/10/2018 Microprocessors I: Lecture 22

Example solution (part b) movf NUM2, W  W = NUM2 subwf NUM1, W  W = NUM1 – W = NUM1 – NUM2 btfss STATUS, C  Carry indicates “above”  if set, NUM1 > NUM2 goto BL movf NUM1, W  if (NUM1 >= NUM2) W = NUM1 goto Done  Skip “below” section BL movf NUM2, W  if (NUM1 < NUM2) W = NUM2 Done movwf MIN High-level operation: if (NUM1 < NUM2) MIN = NUM1 else MIN = NUM2 6/10/2018 Microprocessors I: Lecture 22

Microprocessors I: Lecture 22 6/10/2018 Miscellaneous clrwdt ; clear watchdog timer sleep ; go into standby mode nop ; no operation STATUS bits: clrwwdt, sleep: NOT_TO, NOT_PD nop: none Examples: clrwdt ; if watchdog timer is enabled, this instruction will reset ; it (before it resets the CPU) sleep ; Stop clock; reduce power; wait for watchdog timer or ; external signal to begin program execution again nop ; Do nothing; wait one clock cycle 6/10/2018 Microprocessors I: Lecture 22 Chapter 9

Microprocessors I: Lecture 22 Final notes Next time Exam 2 Preview Reminders: HW 3 due today Lab 2 due 11/14 Exam 2: Wednesday, 11/7 Will post list of instructions to be included 6/10/2018 Microprocessors I: Lecture 22