14
Microprocessor and Interfacing 261313 PIC Code Execution http://www.e-cpe.org/moodle

Microprocessor and Interfacing 261313

  • Upload
    eydie

  • View
    53

  • Download
    1

Embed Size (px)

DESCRIPTION

Microprocessor and Interfacing 261313. PIC Code Execution. http://www.e-cpe.org/moodle. 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 - PowerPoint PPT Presentation

Citation preview

Page 1: Microprocessor and Interfacing 261313

Microprocessor and Interfacing

261313

PIC Code Execution

http://www.e-cpe.org/moodle

Page 2: Microprocessor and Interfacing 261313

How does the CPU executes this simple program?

void main() {

int i;

i = 1; i++;

}

Page 3: Microprocessor and Interfacing 261313

Assembly Code

MOVLW 01BCF 03.5MOVWF 21INCF 21,F

Page 4: Microprocessor and Interfacing 261313

Machine Code

11000000000001010010100000110000001010000100101010100001

Page 5: Microprocessor and Interfacing 261313
Page 6: Microprocessor and Interfacing 261313
Page 7: Microprocessor and Interfacing 261313

File Register Map

Page 8: Microprocessor and Interfacing 261313

Status Register (Address 03)

Zero Bit = จะเป็�น 0 เมื่อใดก็�ตามื่ที่� ALU คำ�านวณคำ�าออก็มื่าเป็�น 0

Page 9: Microprocessor and Interfacing 261313

The 4 Qs

Q1 = Instruction Decode

Q2 = Fetch Operand

Q3 = Process the Data

Q4 = Write Result Data

Page 10: Microprocessor and Interfacing 261313

Instruction Pipeline Flow

Flash->Ins Reg Q1 Q2 Q3 Q4

Flash->Ins Reg Q1 Q2 Q3 Q4

Flash->Ins Reg Q1 Q2 Q3 Q4

time

123

Fetch Execute

Page 11: Microprocessor and Interfacing 261313

Pipeline interruption

Flash->Ins Reg Q1 Q2 Q3 Q4

Flash->Ins Reg

Flash->Ins Reg Q1 Q2 Q3 Q4

time

Goto 323

Fetch Execute

Page 12: Microprocessor and Interfacing 261313

Program Execution Example

.................... int i;

....................

.................... i=1; 000D: MOVLW 01000E: BCF 03.5000F: MOVWF 21.................... i++; 0010: INCF 21,F

Page 13: Microprocessor and Interfacing 261313

Converting Assembly to Machine Code

11000000000001MOVLW 01BCF 03.5MOVWF 21INCF 21,F

010010100000110000001010000100101010100001

Page 14: Microprocessor and Interfacing 261313

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