PIC Code Execution How does the CPU executes this simple program? void main() { int i; i = 1; i++; }

Slides:



Advertisements
Similar presentations
振動スイッチを活用 振動(傾き)を検出 ボールが移動 a)オン時 b)オフ時 オンからオフ時の観察.
Advertisements

Control structures Hot to translate high level control structures to assembler.
Machine cycle.
Electronics Design Lab TUTORIAL PIC Microcontrollers Francesco Tenore 2/10/2006.
RISC and Pipelining Prof. Sin-Min Lee Department of Computer Science.
The 8051 Microcontroller and Embedded Systems
Prof. Jorge A. Ramón Introducción a Microcontroladores.
1 Lecture-2 CS-120 Fall 2000 Revision of Lecture-1 Introducing Computer Architecture The FOUR Main Elements Fetch-Execute Cycle A Look Under the Hood.
1 Sec (2.3) Program Execution. 2 In the CPU we have CU and ALU, in CU there are two special purpose registers: 1. Instruction Register 2. Program Counter.
Microcontroller Programming How to make something almost do something else Raffi Krikorian MAS November 2003.
Building Assembler Programs Chapter Five Dr. Gheith Abandah1.
4-1 Chapter 4 - The Instruction Set Architecture Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring.
Directives, Memory, and Stack. Directives Special commands to the assembler May or may not generate machine code Categories by their function Programming.
Microprocessor and Interfacing PIC Code Execution
What have mr aldred’s dirty clothes got to do with the cpu
PIC18F Programming Model and Instruction Set
Embedded System Spring, 2011 Lecture 5: The PIC Microcontrollers Eng. Wazen M. Shbair.
Assembly Language A Brief Introduction. Unit Learning Goals CPU architecture. Basic Assembler Commands High level Programming  Assembler  Machine Language.
Embedded System Spring, 2011 Lecture 11: Bank Switching Eng. Wazen M. Shbair.
EEC4133 Computer Organization & Architecture Chapter 5: Datapath & Control by Muhazam Mustapha, April 2014.
 Mini-Computer  Microprocessor  The Brains  Arithmetic Logic Unit (ALU)  Control Unit  Program/ Data Storage  Peripherals (Input/Output) Low-Cost.
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
Sample Code (Simple) Run the following code on a pipelined datapath: add1 2 3 ; reg 3 = reg 1 + reg 2 nand ; reg 6 = reg 4 & reg 5 lw ; reg.
EEE237 Introduction to Microprocessors Week x. SFRs.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
E X C E E D I N G E X P E C T A T I O N S VLIW-RISC CSIS Parallel Architectures and Algorithms Dr. Hoganson Kennesaw State University Instruction.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Department of Electronic & Electrical Engineering Introduction to microcontrollers A microcontroller is a small computer on a single integrated circuit.
Department of Electronic & Electrical Engineering Lecture 2. PIC16F84A Architecture / Instructions Memory. Program/Data (Harvard) File Registers (Data).
1 EKT 225 MICROCONTROLLER I CHAPTER ASSEMBLY LANGUAGE PROGRAMMING.
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,
RISC / CISC Architecture by Derek Ng. Overview CISC Architecture RISC Architecture  Pipelining RISC vs CISC.
CPUz 4 n00bz.
Department of Electronic & Electrical Engineering Lecture 3. ● Template program. ● Introduction to IO ● PORTA PORTB TRISA TRISB ● Using a subroutine ●
5-2-1 PIC microcontroller. Learning objectives To aid revision, areas that are examinable are identified by a vertical line in the left margin. Where.
Applications examples. A binary count : stepped manually and reset with push buttons. Define ports Reset portd Reset =0? INCF portd no Step =0? yes.
1.  List all addressing modes of PIC18 uCs  Contrast and compare the addressing modes  Code PIC18 instructions to manipulate a lookup table.  Access.
STUDY OF PIC MICROCONTROLLERS.. Design Flow C CODE Hex File Assembly Code Compiler Assembler Chip Programming.
Chapter 9 PIC18 Timer Programming in Assembly
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Micro-processor vs. Micro-controller
Microprocessor Systems Design I
HTP Programme: Assembler
PIC – ch. 2b Md. Atiqur Rahman Ahad.
16.317: Microprocessor System Design I
The fetch-execute cycle
Figure 8.1 Architecture of a Simple Computer System.
Instruction cycle Instruction: A command given to the microprocessor to perform an operation Program : A set of instructions given in a sequential.
Computer Organization and ASSEMBLY LANGUAGE
Figure 8.1 Architecture of a Simple Computer System.
EECE.3170 Microprocessor Systems Design I
Chapter 4 Instruction Set.
INSTRUCTION SET.
Figure 6-1a. MOVFF Direct Addressing Opcode
PIPELINING Santosh Lakkaraju CS 147 Dr. Lee.
MARIE: An Introduction to a Simple Computer
EECE.3170 Microprocessor Systems Design I
Program Execution.
The Von Neumann Machine
EECE.3170 Microprocessor Systems Design I
CSc 453 Final Code Generation
Instruction execution and ALU
Computer Architecture Assembly Language
Figure 3-1. Flowchart for the DECFSZ Instruction
Algoritmos y Programacion
Sec (2.3) Program Execution.
Presentation transcript:

PIC Code Execution

How does the CPU executes this simple program? void main() { int i; i = 1; i++; }

Assembly Code MOVLW 01 BCF 03.5 MOVWF 21 INCF 21,F

Machine Code

File Register Map See figure 6-5 in the handout For a complete File Register layout

The 4 Qs Q1 = Instruction Decode Q2 = Fetch Operand Q3 = Process the Data Q4 = Write Result Data See section 4.2, 4.3 in the handout for details

Instruction Pipeline Flow time Cmd1 Cmd2 Cmd3 Flash->Ins RegQ1Q2Q3Q4 Flash->Ins RegQ1Q2Q3Q4 Flash->Ins RegQ1Q2Q3Q4 FetchExecute Q1 = Instruction Decode Q2 = Fetch Operand Q3 = Process the Data Q4 = Write Result Data

Pipeline interruption time Q1 = Instruction Decode Q2 = Fetch Operand Q3 = Process the Data Q4 = Write Result Data Goto 3 Cmd2 Cmd3 Flash->Ins RegQ1Q2Q3Q4 Flash->Ins Reg Q1Q2Q3Q4 FetchExecute

Program Execution Example int i; i=1; 000D: MOVLW E: BCF F: MOVWF i++; 0010: INCF 21,F

Converting Assembly to Machine Code MOVLW 01 BCF 03.5 MOVWF 21 INCF 21,F Look at table 5-1 in the handout for the machine code reference

Program Execution Ex int i; i = 5; 000D: MOVLW E: BCF F: MOVWF do { i--; 0010: DECF 21,F } while (i>0); 0011: MOVF 21,F 0012: BTFSS : GOTO 010