1 / 13

Microprocessor and Interfacing 261214

Microprocessor and Interfacing 261214. PIC Code Execution. http ://mango.e-cpe.org. 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. 11000000000001 01001010000011

jera
Download Presentation

Microprocessor and Interfacing 261214

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microprocessor and Interfacing261214 PIC Code Execution http://mango.e-cpe.org

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

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

  4. Machine Code 11000000000001 01001010000011 00000010100001 00101010100001

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

  6. 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

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

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

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

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

  11. Program Execution Ex 2 .................... inti; .................... i = 5; 000D: MOVLW 05 000E: BCF 03.5 000F: MOVWF 21 .................... do { .................... i--; 0010: DECF 21,F .................... } while (i>0); 0011: MOVF 21,F 0012: BTFSS 03.2 0013: GOTO 010

More Related