SlideShare a Scribd company logo
MICROPROCESSORS
&
MICROCONTROLLERS
Khalil Zeineddine
2021
KAFAZ
Microprocessors & Microcontrollers KAFAZ- 7
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
Chapter_2:
To know:
1. Programming of PIC16F877a
2. Addressing modes
3. Instructions set
4. Directives of assembly
5. Exercises
Contents_2:
PROGRAMMING OF PIC 16F877A
INTRODUCTION
The microcontroller executes the program loaded in its FLASH memory.
Binary words (on 14 bits for the PIC16F877A) are considered by the CPU as a
command.
But programming in binary or even in hexadecimal is impossible.
Programmers use languages like assembler or C, which uses abbreviations.
Transforming this more readable code into binary code ready for storage is
called compilation.
Microprocessors & Microcontrollers KAFAZ- 8
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
Note: Assembler is a low-level language closely related to the type of
microcontroller.
C is a higher level language than assembler and in theory allows it to be
portable, therefore adapting to any microcontroller.
Addressing modes
1. Immediate (literal)
MOVLW 0x55; load the value 0x55 into the W register
2. Direct
MOVF 0x55, W; load the contents of address 0x55 into W
Use the STATUS register (RP0, RP1)
3. Indirect
Uses FSR, INDF and STATUS (IRP) registers.
Microprocessors & Microcontrollers KAFAZ- 9
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
INSTRUCTIONS SET
All instructions understandable by microcontrollers form what is called
the instruction set
 Instructions on registers
Registers: W  the accumulator W and F  a RAM register.
d = 0  W is therefore the destination,
d = 1  F is therefore the destination.
ADDWF 70h,1 or ADDWF 70h,f
Means: add the content of W with the content of the address memory box
70h and place the result in the memory box 70h
XORWF 35h,0 or XORWF 35h,w
Means: make an exclusive or between W and the content of the address
memory box 35h and place the result in the accumulator W
Microprocessors & Microcontrollers KAFAZ- 10
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
 Instructions on bits
F  RAM register ; b  position (7 – 0) of bit in the register F ;
For instructions acting on a bit, the parameter F indicates the register
which contains the bit to be modified and the parameter b indicates the
number of the bit to be modified; we count from zero, starting on the
right.
BSF STATUS, 2;
Means: set bit 2 (3rd bit from the right) of the STATUS register to 1
BCF 45h, 6;
Means: set bit 6 (7th bit from the right) to 0 of the register of the 45h
address memory slot
 immediate Instructions (W)
K  immediate data (value) ;
 Control Instructions (W)
K  immediate data (value) ; L  address (or label)
Microprocessors & Microcontrollers KAFAZ- 11
Version 2021 Khalil Zeineddine
P
I
C
1
6
F
8
7
7
A
The directives of the assembly MPASM
The assembly directives are instructions that are added to the program and
which will be interpreted by the MPASM assembler. These are not
instructions for the PIC.
 LIST: Example:
LIST p=16F876, r=dec
 INCLUDE :
INCLUDE "p16f876.inc"
 EQU : defines a constant or variable:
XX EQU 0x20
 CBLOCK/ENDC : allows you to define a set of constants
 ORG : defines the position in the program memory from which the
following instructions will be written.
 #DEFINE : works a bit like the EQU directive but is a little more
general, because it allows a whole string to be assigned to an
abbreviation
 DE : to declare data which will be stored in the data EEPROM
when the program is installed on the PIC
 DT : to declare a RETLW array
 END : indicates the end of the program

More Related Content

PDF
Embedded system (Chapter 2) part 2
PPT
Chp5 pic microcontroller instruction set copy
PPT
Microcontroller 8051
PPT
Chp2 introduction to the 68000 microprocessor copy
PPT
Chp7 pic 16 f84 interfacing - copy
TXT
PIC and LCD
PPT
Io (2)
PPT
Z-GPRS2 – ALL-IN-ONE SOLUTION MODEM & PLC
Embedded system (Chapter 2) part 2
Chp5 pic microcontroller instruction set copy
Microcontroller 8051
Chp2 introduction to the 68000 microprocessor copy
Chp7 pic 16 f84 interfacing - copy
PIC and LCD
Io (2)
Z-GPRS2 – ALL-IN-ONE SOLUTION MODEM & PLC

What's hot (19)

PDF
Unit 3-1 (1)
PPTX
The 8051 microcontroller
PPTX
PPT
Chapter5 dek3133
PPTX
Pic16 f84a
PDF
2014 ii c08t-sbc pic para ecg
PDF
Galil ioc7007 catalog
PPTX
8051 microcontroller
PPT
branch ins 8051
PPTX
Introduction to ARM
PPT
subroutines and interrupts
PPTX
8255:ppi & 8259:pic
PDF
Adf4110 1 2 3
PDF
Pdf tp3076 national
PPS
Robotix Tutorial 8
PDF
SimLogic
PPTX
8255 Programmble Peripheral Interface
PPT
8255_utkarsh_kulshrestha
Unit 3-1 (1)
The 8051 microcontroller
Chapter5 dek3133
Pic16 f84a
2014 ii c08t-sbc pic para ecg
Galil ioc7007 catalog
8051 microcontroller
branch ins 8051
Introduction to ARM
subroutines and interrupts
8255:ppi & 8259:pic
Adf4110 1 2 3
Pdf tp3076 national
Robotix Tutorial 8
SimLogic
8255 Programmble Peripheral Interface
8255_utkarsh_kulshrestha
Ad

Similar to MICROPROCESSORS & MICROCONTROLLERS (20)

PDF
MICROPROCESSORS & MICROCONTROLLERS
PPTX
MPMC Architecture of 8085 Microprocessor and Programming.pptx
PDF
Microcontroller pic 16f877 addressing modes instructions and programming
PPT
Picmico
PDF
Pic assembly launguage
PPTX
Instruction Set Architecture
PDF
Microprocessor and its applications third edition
PPT
My seminar new 28
PPTX
Module -4_microprocessor (1).pptx
PDF
8085 microprocessor
PDF
PDF
Architecture OF 8085
PDF
Module 2 instruction set
PPTX
PPT
LCDF3_Chap_10_P2.pptytttttyyyyyyyyyyyyyy
PDF
Micrcontroller iv sem lab manual
DOCX
8086 MICROPROCESSOR
PPTX
Microcontroller
PPT
Unit_4 8051_PPT_Architecture_pin_Addressing mode.ppt
MICROPROCESSORS & MICROCONTROLLERS
MPMC Architecture of 8085 Microprocessor and Programming.pptx
Microcontroller pic 16f877 addressing modes instructions and programming
Picmico
Pic assembly launguage
Instruction Set Architecture
Microprocessor and its applications third edition
My seminar new 28
Module -4_microprocessor (1).pptx
8085 microprocessor
Architecture OF 8085
Module 2 instruction set
LCDF3_Chap_10_P2.pptytttttyyyyyyyyyyyyyy
Micrcontroller iv sem lab manual
8086 MICROPROCESSOR
Microcontroller
Unit_4 8051_PPT_Architecture_pin_Addressing mode.ppt
Ad

Recently uploaded (20)

PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PPT
Total quality management ppt for engineering students
PPTX
Current and future trends in Computer Vision.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PPT
Occupational Health and Safety Management System
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
737-MAX_SRG.pdf student reference guides
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
PPTX
UNIT - 3 Total quality Management .pptx
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
86236642-Electric-Loco-Shed.pdf jfkduklg
Total quality management ppt for engineering students
Current and future trends in Computer Vision.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Occupational Health and Safety Management System
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
UNIT 4 Total Quality Management .pptx
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
737-MAX_SRG.pdf student reference guides
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Abrasive, erosive and cavitation wear.pdf
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
UNIT - 3 Total quality Management .pptx

MICROPROCESSORS & MICROCONTROLLERS

  • 2. Microprocessors & Microcontrollers KAFAZ- 7 Version 2021 Khalil Zeineddine P I C 1 6 F 8 7 7 A Chapter_2: To know: 1. Programming of PIC16F877a 2. Addressing modes 3. Instructions set 4. Directives of assembly 5. Exercises Contents_2: PROGRAMMING OF PIC 16F877A INTRODUCTION The microcontroller executes the program loaded in its FLASH memory. Binary words (on 14 bits for the PIC16F877A) are considered by the CPU as a command. But programming in binary or even in hexadecimal is impossible. Programmers use languages like assembler or C, which uses abbreviations. Transforming this more readable code into binary code ready for storage is called compilation.
  • 3. Microprocessors & Microcontrollers KAFAZ- 8 Version 2021 Khalil Zeineddine P I C 1 6 F 8 7 7 A Note: Assembler is a low-level language closely related to the type of microcontroller. C is a higher level language than assembler and in theory allows it to be portable, therefore adapting to any microcontroller. Addressing modes 1. Immediate (literal) MOVLW 0x55; load the value 0x55 into the W register 2. Direct MOVF 0x55, W; load the contents of address 0x55 into W Use the STATUS register (RP0, RP1) 3. Indirect Uses FSR, INDF and STATUS (IRP) registers.
  • 4. Microprocessors & Microcontrollers KAFAZ- 9 Version 2021 Khalil Zeineddine P I C 1 6 F 8 7 7 A INSTRUCTIONS SET All instructions understandable by microcontrollers form what is called the instruction set  Instructions on registers Registers: W  the accumulator W and F  a RAM register. d = 0  W is therefore the destination, d = 1  F is therefore the destination. ADDWF 70h,1 or ADDWF 70h,f Means: add the content of W with the content of the address memory box 70h and place the result in the memory box 70h XORWF 35h,0 or XORWF 35h,w Means: make an exclusive or between W and the content of the address memory box 35h and place the result in the accumulator W
  • 5. Microprocessors & Microcontrollers KAFAZ- 10 Version 2021 Khalil Zeineddine P I C 1 6 F 8 7 7 A  Instructions on bits F  RAM register ; b  position (7 – 0) of bit in the register F ; For instructions acting on a bit, the parameter F indicates the register which contains the bit to be modified and the parameter b indicates the number of the bit to be modified; we count from zero, starting on the right. BSF STATUS, 2; Means: set bit 2 (3rd bit from the right) of the STATUS register to 1 BCF 45h, 6; Means: set bit 6 (7th bit from the right) to 0 of the register of the 45h address memory slot  immediate Instructions (W) K  immediate data (value) ;  Control Instructions (W) K  immediate data (value) ; L  address (or label)
  • 6. Microprocessors & Microcontrollers KAFAZ- 11 Version 2021 Khalil Zeineddine P I C 1 6 F 8 7 7 A The directives of the assembly MPASM The assembly directives are instructions that are added to the program and which will be interpreted by the MPASM assembler. These are not instructions for the PIC.  LIST: Example: LIST p=16F876, r=dec  INCLUDE : INCLUDE "p16f876.inc"  EQU : defines a constant or variable: XX EQU 0x20  CBLOCK/ENDC : allows you to define a set of constants  ORG : defines the position in the program memory from which the following instructions will be written.  #DEFINE : works a bit like the EQU directive but is a little more general, because it allows a whole string to be assigned to an abbreviation  DE : to declare data which will be stored in the data EEPROM when the program is installed on the PIC  DT : to declare a RETLW array  END : indicates the end of the program