Microprocessor and Interfacing 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
Status Register (Address 03) Zero Bit = จะเป็น 0 เมื่อใดก็ตาม ที่ ALU คำนวณค่าออกมาเป็น 0
The 4 Qs Q1 = Instruction Decode Q2 = Fetch Operand Q3 = Process the Data Q4 = Write Result Data
Instruction Pipeline Flow Flash->Ins Reg Q1Q2Q3Q4 Flash->Ins Reg Q1Q2Q3Q4 Flash->Ins Reg Q1Q2Q3Q4 time Fetch Execute
Pipeline interruption Flash->Ins Reg Q1Q2Q3Q4 Flash->Ins Reg Q1Q2Q3Q4 time Goto Fetch Execute
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
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