PIC Assembly
PIC Assembly
PIC Assembly
Lecture 3
PIC Assembly Basics
CSE 3442/5442
Embedded Systems I
Based heavily on slides by Dr. Roger Walker
From Last Lecture
4
Compiler Data Formats
• Binary:
– Put B in front of the number in single quotes:
• MOVLW B’10011001’
• Decimal:
– Put D in front of the number in single quotes:
• MOVLW D’12’
– Use .value:
• MOVLW .12
5
Compiler Directives
6
Compiler Directives
9
Assembly Programming
sample
SUM EQU 10H ; RAM loc 10H for SUM
ORG 0H ; start at address 0
MOVLW 25H ;25H à WREG
ADDLW 0x34 ;+ 34H
ADDLW 11H ;+ 11H
ADDLW 25 ;+25H
ADDLW D'18‘ ;+ 18 decimal
ADDLW .18 ;+18 decimal
ADDLW A’0’ ; add ascii of 0 (32)
ADDLW B'00000110‘ ;+6
MOVWF SUM
HERE GOTO HERE
END
From page 69
10
Assembly Assembled an Linked
Figure 2-8.
11
Files Used and Created
2 MB
Figure 2-9.
13
PIC18 On-Chip Program ROM
Address Range
4k
16 k
32 k
(452)
Figure 2-10
14
PIC18F458 Pin Diagram
15
Example - Powering Up
PIC18F458
16
Programs in ROM
17
PIC18 Program ROM Width
18
PIC18 Program ROM Contents
for Program 2-1 List File
21 bit PC 20
PIC uses Harvard Architecture
21
RISC
• Create project
• Type in code
• Set debugger to simulator
• Add watch windows
• Look at what is happening
23
24
25
26
27
28
29
30
CSE 3442/4442 Lecture 3 31
Dr. Roger Walker
Special File Register Window
in MPLAB Simulator
32
File Register (Data RAM) Window
in MPLAB Simulator
33
Program (Code) ROM Window in
MPLAB Simulator
34
QwikFlash Board
36
PIC Data Sheets
37