This document provides an overview and syllabus for a course on PIC microcontroller programming. It discusses the objectives of the course, which are to expose students to PIC architecture and peripherals, advanced PIC features, and assembly and C programming. The syllabus covers addressing modes, instruction sets, assembly, and C programming over 5 lectures. It also provides details on the PIC16F877 instruction set, which includes 35 instructions grouped into data transfer, arithmetic/logic, bit operations, program flow control, and other categories. Addressing modes for the PIC include immediate, register, memory, direct, and indirect.
The 8051 microcontroller has an 8-bit CPU, 4K ROM, 128 bytes RAM, two 16-bit timers, 32 I/O lines, and serial port. It uses an accumulator, B register, program status word and stack pointer along with arithmetic logic unit and instruction decoder to perform operations. The memory includes internal ROM, RAM, and external memory accessed via a 16-bit data pointer and program counter.
The document describes the 8051 microcontroller, its features which include 4 I/O ports, 2 timers, serial communication interface, and interrupts. It discusses the internal architecture such as memory organization, registers, and oscillator circuit. The document also provides details on the ports, timers, serial communication, and power modes of the 8051 microcontroller.
The document discusses interfacing a stepper motor with an 8051 microcontroller. A stepper motor can divide a full rotation into discrete steps through energizing coils in different sequences. The stepper motor can be interfaced with an 8051 using an L293D motor driver connected to ports P1.0, P1.2, P1.3, and P1.4 of the 8051. Both full-step and half-step sequences are described for energizing the coils to precisely control the motor's position without feedback. Assembly and C code examples are provided to demonstrate clockwise and counterclockwise rotation of the stepper motor connected to the 8051.
register file structure of PIC controllerNirbhay Singh
The document discusses the register file structure in PIC microcontrollers. It describes that the register file consists of general purpose registers and special function registers. The general purpose registers include the working register and status register, while the special function registers include the program counter, stack pointer and other control registers. The register file is divided into four banks to provide expanded addressable memory. The bank selection bits in the status register allow accessing any of the four banks through direct or indirect addressing modes.
The PIC microcontroller uses a Harvard architecture with separate program and data memories. It has a CPU with an ALU, memory unit, and control unit. The memory includes program memory to store instructions, data memory including registers for temporary data storage, and EEPROM for storing variables. It has advantages like a small instruction set, low cost, and built-in interfaces like I2C, SPI, and analog components.
The 8051 microcontroller has 128 bytes of internal RAM and 4Kbytes of internal ROM memory. It uses the same addresses for code and data but accesses the correct memory based on whether an operation is for code or data. The 128 bytes of internal RAM are organized into 4 banks of 32 bytes each. External memory can be added if more memory is needed for program code or variable data storage. The document also provides information on interfacing external program and data memory with the 8051 microcontroller.
Presents features of ARM Processors, ARM architecture variants and Processor families. Further presents, ARM v4T architecture, ARM7-TDMI processor: Register organization, pipelining, modes, exception handling, bus architecture, debug architecture and interface signals.
The 8051 microcontroller has an 8-bit CPU, 4K ROM, 128 bytes RAM, two 16-bit timers, 32 I/O lines, and serial port. It uses an accumulator, B register, program status word and stack pointer along with arithmetic logic unit and instruction decoder to perform operations. The memory includes internal ROM, RAM, and external memory accessed via a 16-bit data pointer and program counter.
The document describes the 8051 microcontroller, its features which include 4 I/O ports, 2 timers, serial communication interface, and interrupts. It discusses the internal architecture such as memory organization, registers, and oscillator circuit. The document also provides details on the ports, timers, serial communication, and power modes of the 8051 microcontroller.
The document discusses interfacing a stepper motor with an 8051 microcontroller. A stepper motor can divide a full rotation into discrete steps through energizing coils in different sequences. The stepper motor can be interfaced with an 8051 using an L293D motor driver connected to ports P1.0, P1.2, P1.3, and P1.4 of the 8051. Both full-step and half-step sequences are described for energizing the coils to precisely control the motor's position without feedback. Assembly and C code examples are provided to demonstrate clockwise and counterclockwise rotation of the stepper motor connected to the 8051.
register file structure of PIC controllerNirbhay Singh
The document discusses the register file structure in PIC microcontrollers. It describes that the register file consists of general purpose registers and special function registers. The general purpose registers include the working register and status register, while the special function registers include the program counter, stack pointer and other control registers. The register file is divided into four banks to provide expanded addressable memory. The bank selection bits in the status register allow accessing any of the four banks through direct or indirect addressing modes.
The PIC microcontroller uses a Harvard architecture with separate program and data memories. It has a CPU with an ALU, memory unit, and control unit. The memory includes program memory to store instructions, data memory including registers for temporary data storage, and EEPROM for storing variables. It has advantages like a small instruction set, low cost, and built-in interfaces like I2C, SPI, and analog components.
The 8051 microcontroller has 128 bytes of internal RAM and 4Kbytes of internal ROM memory. It uses the same addresses for code and data but accesses the correct memory based on whether an operation is for code or data. The 128 bytes of internal RAM are organized into 4 banks of 32 bytes each. External memory can be added if more memory is needed for program code or variable data storage. The document also provides information on interfacing external program and data memory with the 8051 microcontroller.
Presents features of ARM Processors, ARM architecture variants and Processor families. Further presents, ARM v4T architecture, ARM7-TDMI processor: Register organization, pipelining, modes, exception handling, bus architecture, debug architecture and interface signals.
This presentation discusses the Serial Communication features in 8051, the support for UART. It also discusses serial vs parallel communication, simplex, duplex and full-duplex modes, MAX232, RS232 standards
Port 0 of the 8051 microcontroller can be used as a bidirectional I/O port or for address/data interfacing with external memory. When used as an input port, writing a 1 to the latch causes the output MOSFETs to turn off, allowing the pin value to be read directly. When used as an output port, a pull-up resistor is needed to write a 1 since the upper MOSFET turns off. Port 1 has internal pull-up resistors so no external resistors are needed, but the external device must sink current when writing a 0. Port 2 is similar to Port 1 for I/O but can also be used for higher address bytes. Port 3 pins each have alternate functions in
The document discusses the 8051 microcontroller, including its architecture, pin configuration, memory organization, timers, interrupts, and interfacing capabilities. It describes the 8051's features like on-chip RAM, ROM, timers and low power consumption which make it suitable for control applications. The document outlines the differences between microprocessors and microcontrollers, and covers various interfacing examples like switches, LEDs, 7-segment displays, LCDs, ADCs and relay interfacing. It concludes with common applications of the 8051 such as in automobiles, industrial processing, robotics and consumer electronics.
The document discusses the PIC-18 microcontroller. It describes the PIC-18 as an 8-bit microcontroller with 16-bit instruction sets, 256 bytes of EPROM, 2KB of SRAM, and 32KB of flash memory. It operates at 40MHz and has features like a 10-bit A/D converter, instruction pipelining, and low power consumption. The document also provides details on the pin diagram, architecture, memory organization, addressing modes, and pipelining of the PIC-18 microcontroller.
The 8051 microcontroler based embedded systemsmanishpatel_79
This document provides an overview of chapter 1 from a textbook on 8051 microcontrollers and embedded systems. The chapter introduces microcontrollers by comparing them to microprocessors and microcomputers. It describes the basic components of a computer system and how microcontrollers integrate CPU, memory and I/O components onto a single chip. The chapter also covers classifications of microcontrollers based on word length, memory architecture and instruction set, and provides examples of their applications in embedded systems.
Semiconductor Memory Fundamentals
Memory Types
Memory Structure and its requirements
Memory Decoding
Examples
Input - Output Interfacing
Types of Parallel Data Transfer or I/O Techniques
The document discusses the 8051 microcontroller. It lists advantages of microcontroller-based systems such as lower cost, smaller size, and higher reliability compared to microprocessor-based systems. It describes some 8051 family members and compares their features such as ROM type, RAM size, and number of timers. It also discusses important components of the 8051 like ROM, RAM, I/O ports, timers, and serial port. The document provides block diagrams of the 8051 internal architecture and pinout. It describes the functions of various pins and registers.
Describes ARM7-TDMI Processor Instruction Set. Explains classes of ARM7 instructions, syntax of data processing instructions, branch instructions, load-store instructions, coprocessor instructions, thumb state instructions.
This document provides an introduction to PIC microcontrollers. It discusses the architecture of PIC microcontrollers, including the 16C6x and 16C7x architectures. It describes the registers, memory, and instruction set of PIC microcontrollers. Some key points covered include the Harvard architecture, pipelining, addressing modes, arithmetic, logical, and conditional instructions. Peripherals like timers and interrupts are also mentioned.
Microcontrollers are small computers that integrate RAM, ROM, I/O ports and other components onto a single chip. They are used in applications where cost, power and space are critical. The document compares microprocessors and microcontrollers, noting that microcontrollers have all components on one chip while microprocessors have separate chips. It then describes the typical internal blocks of a microcontroller, including the CPU, memory, I/O ports, timers and serial ports. Block diagrams show the connections between these internal components.
The document discusses programming the 8051 microcontroller. It can be programmed using low-level assembly language or high-level languages like C. Assembly language code is faster but more difficult to write and less portable, while C code is easier but slower. The document provides examples of adding two numbers in both C and assembly. It also discusses the 8051 instruction set, addressing modes, subroutines, and arithmetic operations.
This document provides an overview of the 8051 microcontroller architecture. It describes the basic components of the 8051 including 4K bytes of internal ROM, 128 bytes of internal RAM, four 8-bit I/O ports, two timers/counters, one serial interface, and other features. It also discusses the different addressing modes for 8051 assembly language programming including immediate, register, direct, register indirect, and external direct addressing.
This presentation discusses the support for interrupts in 8051. The interrupt types, interrupts versus polling etc are discussed. The register formats of IE, IP register are discussed. The concept of priority among the interrupts is discussed.
A microcontroller is an integrated circuit that can be programmed to control electronic devices. It contains a processor, memory, and input/output ports on a single chip. Microcontrollers come in various sizes based on their word length and internal bus width, from 4-bit to 32-bit. They also differ based on their memory architecture and instruction set. A microcontroller allows easy programming to control devices in embedded systems and provides advantages like low cost, small size, and flexibility.
The SPI (Serial Peripheral Interface) is a synchronous serial communication protocol used for communication between devices. It uses a master-slave architecture with a single master device initiating data transfer. Key features include using separate clock and data lines, operating in full duplex mode, and allowing multiple slave devices through individual chip selects. It provides a lower pin count solution than parallel buses at the cost of slower communication speeds.
This Presentation describes the ARM CORTEX M3 core processor with the details of the core peripherals. Soon a CORTEX base controller(STM32F100RBT6) ppt will be uploaded. For more information mail me at:gaurav.iitkg@gmail.com.
Introduction of memory Segmentation
Segmentation is the process in which the main memory of the computer is logically divided into different segments and each segment has its own base address.
Memory segmentation is the methods where whole memory is divided into the smaller parts called segments of various sizes.
A segment is just an area in memory.
The process of dividing memory this way is called segmentation.
This document discusses interrupts in the 8051 microcontroller. It describes the interrupt organization and sources, including external, timer, and serial port interrupts. It explains how to enable and prioritize interrupts, and how the interrupt service routines are handled, including saving context and returning from interrupts. Examples are provided of using timer and external interrupts to toggle outputs and respond to events.
1. The document discusses embedded systems and Microchip PIC microcontrollers. It describes what embedded systems are and provides examples of application areas.
2. It explains the differences between microprocessors and microcontrollers, and discusses the architecture and features of Microchip's PIC microcontrollers.
3. The document provides an overview of programming PIC microcontrollers, including the instruction set, device structure, and basic circuit requirements.
This document provides an overview of microcontroller architecture and assembly language programming. It discusses the following key points in 3 sentences:
The document introduces PIC microcontrollers and assembly language, noting that assembly language uses mnemonic instructions that must be translated to machine code by an assembler. It explains the assembling and linking process used to convert assembly code to machine code that can be burned into the PIC's program memory. Various PIC assembly language instructions are also described, including MOVLW, MOVWF, logic instructions, and bit manipulation instructions to set and clear bits on I/O ports.
This presentation discusses the Serial Communication features in 8051, the support for UART. It also discusses serial vs parallel communication, simplex, duplex and full-duplex modes, MAX232, RS232 standards
Port 0 of the 8051 microcontroller can be used as a bidirectional I/O port or for address/data interfacing with external memory. When used as an input port, writing a 1 to the latch causes the output MOSFETs to turn off, allowing the pin value to be read directly. When used as an output port, a pull-up resistor is needed to write a 1 since the upper MOSFET turns off. Port 1 has internal pull-up resistors so no external resistors are needed, but the external device must sink current when writing a 0. Port 2 is similar to Port 1 for I/O but can also be used for higher address bytes. Port 3 pins each have alternate functions in
The document discusses the 8051 microcontroller, including its architecture, pin configuration, memory organization, timers, interrupts, and interfacing capabilities. It describes the 8051's features like on-chip RAM, ROM, timers and low power consumption which make it suitable for control applications. The document outlines the differences between microprocessors and microcontrollers, and covers various interfacing examples like switches, LEDs, 7-segment displays, LCDs, ADCs and relay interfacing. It concludes with common applications of the 8051 such as in automobiles, industrial processing, robotics and consumer electronics.
The document discusses the PIC-18 microcontroller. It describes the PIC-18 as an 8-bit microcontroller with 16-bit instruction sets, 256 bytes of EPROM, 2KB of SRAM, and 32KB of flash memory. It operates at 40MHz and has features like a 10-bit A/D converter, instruction pipelining, and low power consumption. The document also provides details on the pin diagram, architecture, memory organization, addressing modes, and pipelining of the PIC-18 microcontroller.
The 8051 microcontroler based embedded systemsmanishpatel_79
This document provides an overview of chapter 1 from a textbook on 8051 microcontrollers and embedded systems. The chapter introduces microcontrollers by comparing them to microprocessors and microcomputers. It describes the basic components of a computer system and how microcontrollers integrate CPU, memory and I/O components onto a single chip. The chapter also covers classifications of microcontrollers based on word length, memory architecture and instruction set, and provides examples of their applications in embedded systems.
Semiconductor Memory Fundamentals
Memory Types
Memory Structure and its requirements
Memory Decoding
Examples
Input - Output Interfacing
Types of Parallel Data Transfer or I/O Techniques
The document discusses the 8051 microcontroller. It lists advantages of microcontroller-based systems such as lower cost, smaller size, and higher reliability compared to microprocessor-based systems. It describes some 8051 family members and compares their features such as ROM type, RAM size, and number of timers. It also discusses important components of the 8051 like ROM, RAM, I/O ports, timers, and serial port. The document provides block diagrams of the 8051 internal architecture and pinout. It describes the functions of various pins and registers.
Describes ARM7-TDMI Processor Instruction Set. Explains classes of ARM7 instructions, syntax of data processing instructions, branch instructions, load-store instructions, coprocessor instructions, thumb state instructions.
This document provides an introduction to PIC microcontrollers. It discusses the architecture of PIC microcontrollers, including the 16C6x and 16C7x architectures. It describes the registers, memory, and instruction set of PIC microcontrollers. Some key points covered include the Harvard architecture, pipelining, addressing modes, arithmetic, logical, and conditional instructions. Peripherals like timers and interrupts are also mentioned.
Microcontrollers are small computers that integrate RAM, ROM, I/O ports and other components onto a single chip. They are used in applications where cost, power and space are critical. The document compares microprocessors and microcontrollers, noting that microcontrollers have all components on one chip while microprocessors have separate chips. It then describes the typical internal blocks of a microcontroller, including the CPU, memory, I/O ports, timers and serial ports. Block diagrams show the connections between these internal components.
The document discusses programming the 8051 microcontroller. It can be programmed using low-level assembly language or high-level languages like C. Assembly language code is faster but more difficult to write and less portable, while C code is easier but slower. The document provides examples of adding two numbers in both C and assembly. It also discusses the 8051 instruction set, addressing modes, subroutines, and arithmetic operations.
This document provides an overview of the 8051 microcontroller architecture. It describes the basic components of the 8051 including 4K bytes of internal ROM, 128 bytes of internal RAM, four 8-bit I/O ports, two timers/counters, one serial interface, and other features. It also discusses the different addressing modes for 8051 assembly language programming including immediate, register, direct, register indirect, and external direct addressing.
This presentation discusses the support for interrupts in 8051. The interrupt types, interrupts versus polling etc are discussed. The register formats of IE, IP register are discussed. The concept of priority among the interrupts is discussed.
A microcontroller is an integrated circuit that can be programmed to control electronic devices. It contains a processor, memory, and input/output ports on a single chip. Microcontrollers come in various sizes based on their word length and internal bus width, from 4-bit to 32-bit. They also differ based on their memory architecture and instruction set. A microcontroller allows easy programming to control devices in embedded systems and provides advantages like low cost, small size, and flexibility.
The SPI (Serial Peripheral Interface) is a synchronous serial communication protocol used for communication between devices. It uses a master-slave architecture with a single master device initiating data transfer. Key features include using separate clock and data lines, operating in full duplex mode, and allowing multiple slave devices through individual chip selects. It provides a lower pin count solution than parallel buses at the cost of slower communication speeds.
This Presentation describes the ARM CORTEX M3 core processor with the details of the core peripherals. Soon a CORTEX base controller(STM32F100RBT6) ppt will be uploaded. For more information mail me at:gaurav.iitkg@gmail.com.
Introduction of memory Segmentation
Segmentation is the process in which the main memory of the computer is logically divided into different segments and each segment has its own base address.
Memory segmentation is the methods where whole memory is divided into the smaller parts called segments of various sizes.
A segment is just an area in memory.
The process of dividing memory this way is called segmentation.
This document discusses interrupts in the 8051 microcontroller. It describes the interrupt organization and sources, including external, timer, and serial port interrupts. It explains how to enable and prioritize interrupts, and how the interrupt service routines are handled, including saving context and returning from interrupts. Examples are provided of using timer and external interrupts to toggle outputs and respond to events.
1. The document discusses embedded systems and Microchip PIC microcontrollers. It describes what embedded systems are and provides examples of application areas.
2. It explains the differences between microprocessors and microcontrollers, and discusses the architecture and features of Microchip's PIC microcontrollers.
3. The document provides an overview of programming PIC microcontrollers, including the instruction set, device structure, and basic circuit requirements.
This document provides an overview of microcontroller architecture and assembly language programming. It discusses the following key points in 3 sentences:
The document introduces PIC microcontrollers and assembly language, noting that assembly language uses mnemonic instructions that must be translated to machine code by an assembler. It explains the assembling and linking process used to convert assembly code to machine code that can be burned into the PIC's program memory. Various PIC assembly language instructions are also described, including MOVLW, MOVWF, logic instructions, and bit manipulation instructions to set and clear bits on I/O ports.
The document discusses the architecture and assembly language programming of PIC18 microcontrollers. It covers topics such as:
- PIC18 microcontrollers use a Harvard architecture with separate memory for instructions and data. They have a program memory, data memory, I/O ports, and support devices like timers.
- The PIC18 architecture is based on an advanced RISC design. Key components include registers like WREG for temporary data storage. Special function registers and general purpose registers are used to access I/O ports and timers.
- Assembly language instructions like MOVLW, ADDLW, and MOVWF are used to move data between program memory, registers and I/O ports. The
The document discusses the instruction formats and instruction set of the 8085 microprocessor. It describes the three main instruction formats as 1-byte, 2-byte, and 3-byte instructions. It then categorizes the instruction set into five groups - data transfer instructions, arithmetic instructions, logical instructions, branching instructions, and control instructions. For each group, it provides examples of common instructions and explains what operations they perform.
A 16-bit microprocessor I designed during my final semester (2005) of my Bachelor of Technology program. The microprocessor circuitry design was coded in VHDL and then configured in a Xilinx XC9572 PC84 CPLD kit. Most of the design, the architecture and the instruction set were taken from Computer System Architecture (3rd ed.) by M. Morris Mano. See https://github.com/susam/mano-cpu for VHDL source code and other related files.
This document provides an overview of instruction sets and assembly language programming. It discusses different types of instruction sets including CISC, RISC, and hybrid approaches. The document then describes the classification of instruction sets into categories like data movement, compare, branch, arithmetic, logic, and bit manipulation instructions. It also covers instruction formats, addressing modes, operand sizes, comments, labels and examples of assembly language instructions.
Design and development of a 5-stage Pipelined RISC processor based on MIPSIRJET Journal
This document describes the design and development of a 5-stage pipelined RISC processor based on the MIPS architecture. It discusses the stages of a typical 5-stage pipelined RISC processor: instruction fetch, instruction decode, execution, memory access, and write back. It then provides details on the design of a 32-bit MIPS processor with this 5-stage pipeline in Verilog HDL. The behavioral model is studied and verified to function as intended. Key aspects of the MIPS instruction sets and 5-stage pipelined design are outlined.
What is Microcontroller, Microcontroller vs Microprocessor, Development/Classication of microcontrollers, Harvard vs. Princeton Architecture, RISC AND CISC CONTROLLERS
Features of RISC, Microcontroller for Embedded Systems
10 x86 PC Embedded Applications, Choosing a Microcontroller
Criteria for Choosing a Microcontroller, Mechatronics, and Microcontrollers, A brief history of the PIC microcontroller, PIC Microcontrollers, Feature: PIC16F877, Simplied Features.
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
1. This document describes the FPGA implementation and functional verification of a pipelined MIPS processor using VHDL. It analyzes the MIPS instruction format and the instruction data path.
2. A five-stage pipelined MIPS processor is designed, consisting of instruction fetch, instruction decode, execution, data memory, and write back stages. Pipeline registers are used to separate the stages.
3. The design is implemented on a Xilinx FPGA. Simulation results and hardware utilization summaries are presented.
This document discusses different addressing modes and RISC and CISC microprocessors. It defines eight addressing modes: register, register indirect, immediate, direct, indirect, implicit, relative, and index addressing modes. It provides examples for each mode. The document also defines RISC and CISC architectures, noting that RISC uses simple instructions that perform in one clock cycle while CISC uses more complex instructions that can perform multiple operations. It compares the two approaches using multiplying two numbers as an example.
This document provides an overview of the instruction set of the 8085 microprocessor. It discusses the different types of instructions including one-byte, two-byte, and three-byte instructions. It describes the various instruction categories such as data transfer, arithmetic, logical, branching, and machine control instructions. It also covers addressing modes, assembly language programming, and examples of arithmetic operations and first programs. The document serves as an introduction to understanding the instruction set and programming of the 8085 microprocessor.
The ADD instruction performs 32-bit addition of two register operands and stores the result in a third register. It updates the N, C, Z, and V flags based on the result. There are no limitations. Examples demonstrate adding two values and storing the result in a third register.
This document provides an overview of microprocessors and microcontrollers. It discusses the architecture of the 8085 microprocessor, including its registers, arithmetic logic unit, program counter, stack pointer, and control unit. The 8085 is an 8-bit microprocessor with an 8-bit data bus and 16-bit address bus, allowing it to access up to 64KB of memory. The document describes the various components of the 8085 and their functions in processing instructions.
Microprocessor and microcontroller (MPMC).pdfXyzjakhaAbhuvs
This document provides an overview of microprocessors and microcontrollers. It discusses the architecture of the 8085 microprocessor, including its registers, arithmetic logic unit, program counter, stack pointer, and control unit. The 8085 is an 8-bit microprocessor with an 8-bit data bus and 16-bit address bus, allowing it to access up to 64KB of memory. The document describes the various components of the 8085 and their functions in processing instructions.
Question paper with solution the 8051 microcontroller based embedded systems...manishpatel_79
This document contains a question paper with solutions for the subject Microcontrollers from VTU's 4th semester B.E. examination from June-July 2013. The paper tests knowledge of CPU architectures like CISC, RISC, von Neumann, and Harvard. It also compares microprocessors and microcontrollers and tests understanding of interfacing 8051 microcontrollers to external memory. Finally, it examines the five addressing modes of 8051 - immediate, register, direct, indirect and indexed addressing - providing examples of each.
Design of FPGA based 8-bit RISC Controller IP core using VHDLAneesh Raveendran
This paper describes the design, development and
implementation of an 8-bit RISC controller IP core. The
controller has been designed using Very high speed integrated circuit Hardware Description Language (VHDL). The design constraints are speed, power and area. This controller is efficient for specific applications and suitable for small applications. This non-pipelined controller has four units: - Fetch, Decode, Execute and a stage control unit. It has an in built program and data memory. Also it has four ports for communicating with other I/O devices. A hierarchical approach has been used so that basic units can be modeled using behavioral programming. The basic
units are combined using structural programming. The design
has been implemented using ALTERA STRATIX II FPGA
An Enhanced FPGA Based Asynchronous Microprocessor Design Using VIVADO and ISIMjournalBEEI
This paper deals with the novel design and implementation of asynchronous microprocessor by using HDL on Vivado tool wherein it has the capability of handling even I-Type, R-Type and Jump instructions with multiplier instruction packet. Moreover, it uses separate memory for instructions and data read-write that can be changed at any time. The complete design has been synthesized and simulated using Vivado. The complete design is targeted on Xilinx Virtex-7 FPGA. This paper more focuses on the use of Vivado Tool for advanced FPGA device. By using Vivado we get enhaced analysis result for better view of properly Route & Placed design.
Similar to Microcontroller pic 16f877 addressing modes instructions and programming (20)
Nilesh Bhaskarrao Bahadure presents information on biomedical image processing and signal analysis. The document discusses biomedical signals, their origin and dynamics, and processing techniques. It explains that physiological processes produce signals that can provide information about health and disease states. Advanced signal processing is needed to extract clinically relevant data from complex biomedical signals. The document also describes computer-aided diagnosis systems, which apply computer technology to medical imaging to assist physicians' clinical decision making and improve diagnostic accuracy.
The document provides an overview of various medical imaging techniques used to image the brain including CT, MRI, fMRI, PET, and SPECT. It describes each technique, how they work, what types of images they produce, and what they can be used to detect in the brain. CT uses X-rays to produce 2D images while MRI uses magnetic fields and radio waves to produce detailed 3D images without radiation. fMRI can show which parts of the brain are active during tasks by tracking blood flow and oxygen usage. PET and SPECT involve radioactive tracers to detect biochemical processes.
The document discusses timers in 8051 microcontrollers. It describes the different modes timers can operate in, including 13-bit, 16-bit, and 8-bit auto-reload modes. It explains the timer-related special function registers TMOD, TCON, THx and TLx. It provides steps for initializing timers, programming timers in mode 1, and calculating time delays. The document is intended to provide an understanding of how to generate time delays, measure time, and count pulses using the timers in 8051 microcontrollers.
Total slides: 73
Universal Asynchronous Receiver Transmitter (UART)
Introduction to Serial Communication
Types of Transmission
Simplex Communication
Duplex Communication
Half Duplex Communication
Full Duplex Communication
Methods of Serial data Transmission
Synchronous serial data transfer
Asynchronous serial data transfer
Differences Synchronous Asynchronous
Data Transfer Rate
Calculation of Baud Rate
SCON Register
SBUF Register
Writing to the Serial port
Reading the Serial port
PCON Register
Programming of transmission byte serially
Programming of reception of byte serially
Examples
Programmable Peripheral Interface (PPI) 8255
Features of 8255
Block Diagram of 8255 PPI
3 Modes of operation of 8255 PPI
BSR Mode of 8255 PPI
Parallel IO of 8255 PPI
IC 8155/8156
Features of 8155/8156
Block Diagram of 8155/8156
Chip Enable Logic & Port Addresses (Peripheral I/O Addressing
Scheme
Control Word Register of 8155
Timers of 8155/8156
Modes of Timers of 8155
IC 8355/8755
Block Diagram of 8155/8156
The document discusses the Microprocessor 8085. It describes the architecture of the 8085, which is divided into registers, an arithmetic logic unit, an instruction decoder, address buffers, interrupt control, and timing/control circuitry. It details the registers of the 8085 including general purpose, temporary, special purpose, and 16-bit registers like the program counter and stack pointer. The document also examines the ALU, instruction decoder, addressing mechanisms, interrupt handling, serial I/O, and timing control circuitry of the 8085 microprocessor.
Addressing Modes of 8051
Symbol or nomenclature used for data or memory
Instruction sets of 8051
Assembler and Assembler Directives
Delay Calculation
Examples on Delay Calculation
The Microcontroller 8051 Family
Features of 8051 Microcontroller
Pin Configuration of 8051 Microcontroller
Ports of 8051 Microcontroller
Architecture of 8051 Microcontroller
Registers of 8051
Special Function Registers (SFR's)
Bit addressable RAM
Register Bank and Stack of 8051
Introduction to Interrupts
What happens when the interrupt is occurs
Interrupt Vs Polling
Classfication of Interrupts
Hardware Interrupts of 8085
Software Interrupts of 8085
Maskable Interrupts of Microprocessor 8085
Non - Maskable Interrupts of Microprocessor 8085
Vectored Interrupts of Microprocessor 8085
Non - Vectored Interrupts of Microprocessor 8085
8085 Microprocessor Interrupt Structure
Interrupt Structure of Microprocessor 8085
SIM Instruction
Non - Vectored Interrupt
Pending Interrupts
What is Interrupt
Introduction to 8051 Microcontroller Interrupts
Interrupts of 8051 Microcontroller
Interrupt Vs Polling
IE register
IP register
What happens when an interrupt occurs?
What happens when an interrupt Ends?
Programming Timer Interrupt
Serial Interrupt
External Hardware Interrupt
Examples
The document discusses the instruction sets and programming of the 8085 microprocessor. It covers the various addressing modes of the 8085 including immediate, register, direct, indirect, and implicit addressing modes. It also describes the instruction format, opcode format, and the different instruction groups of the 8085 such as data transfer, arithmetic, logical, branching, and machine control instructions. For each instruction group, it provides the list of instructions, number of bytes, and number of clock cycles.
Introduction
Embedded Operating Systems
Applications of Embedded Systems
Characteristics of Embedded Systems
Architecture of Real Embedded Systems
Embedded Operating System
Real Time Operating Systems (RTOS)
Total slides: 102
Depletion Layer in PN Junction
Barrier Potential in a PN junction
Energy Diagram of PN Junction
Biasing The PN Junction
V-I Characteristics of P-N junction Diode
Applications of Diode - Rectiers
Photodiode
Light Emitting Diodes - LED
Zener Diode
Total slides: 75
What is Transducers
Selection Criteria of the Transducers
Basic Requirements of a Transducers
Strain Gauge
Inductive Transducer - LVDT
Load Cell
Temperature Transducers
Photoelectric Transducer
LDR
Photovoltaic Solar Cells
The document provides an overview of the bipolar junction transistor (BJT) including:
1. A BJT has three terminals connected to three doped semiconductor regions, either NPN or PNP.
2. BJTs act as current-controlled switches, regulating the current flowing from emitter to collector in proportion to the base voltage.
3. There are three common configurations - common base has voltage gain but no current gain, common emitter has both gains, and common collector has current gain but no voltage gain. Each configuration has different characteristics.
Total slides: 109
Light Emitting Diodes
Seven Segment LED
LCD Interfacing
Stepper Motor Interfacing
Digital to Analog Converter
ADC Interfacing
Keyboard Interfacing
This document contains 99 questions related to programmable logic controllers (PLCs). The questions cover topics such as PLC components, ladder logic programming, registers, instructions, numbering systems, and applications. They range from basic questions testing understanding of PLC concepts to more complex questions involving designing PLC programs to solve application problems. The questions are divided into three units, with unit one focusing on basic PLC operation, unit two on registers and instructions, and unit three on numbering systems, subroutines, and advanced instructions.
This document contains a question bank for the subject "Microprocessor & Interfaces" provided by Dr. Nilesh Bhaskarrao Bahadure of the Department of Electronics Engineering. It includes short answer, mid-range, and long answer type questions related to the architecture, operation, registers, pins, signals, addressing modes and instructions of the 8085 microprocessor. The questions cover topics such as the components of a computer system, microprocessor architecture, assembly language, interrupts, memory interfacing, I/O techniques and programming of the 8085 microprocessor.
Comparative analysis between traditional aquaponics and reconstructed aquapon...bijceesjournal
The aquaponic system of planting is a method that does not require soil usage. It is a method that only needs water, fish, lava rocks (a substitute for soil), and plants. Aquaponic systems are sustainable and environmentally friendly. Its use not only helps to plant in small spaces but also helps reduce artificial chemical use and minimizes excess water use, as aquaponics consumes 90% less water than soil-based gardening. The study applied a descriptive and experimental design to assess and compare conventional and reconstructed aquaponic methods for reproducing tomatoes. The researchers created an observation checklist to determine the significant factors of the study. The study aims to determine the significant difference between traditional aquaponics and reconstructed aquaponics systems propagating tomatoes in terms of height, weight, girth, and number of fruits. The reconstructed aquaponics system’s higher growth yield results in a much more nourished crop than the traditional aquaponics system. It is superior in its number of fruits, height, weight, and girth measurement. Moreover, the reconstructed aquaponics system is proven to eliminate all the hindrances present in the traditional aquaponics system, which are overcrowding of fish, algae growth, pest problems, contaminated water, and dead fish.
Literature Review Basics and Understanding Reference Management.pptxDr Ramhari Poudyal
Three-day training on academic research focuses on analytical tools at United Technical College, supported by the University Grant Commission, Nepal. 24-26 May 2024
Understanding Inductive Bias in Machine LearningSUTEJAS
This presentation explores the concept of inductive bias in machine learning. It explains how algorithms come with built-in assumptions and preferences that guide the learning process. You'll learn about the different types of inductive bias and how they can impact the performance and generalizability of machine learning models.
The presentation also covers the positive and negative aspects of inductive bias, along with strategies for mitigating potential drawbacks. We'll explore examples of how bias manifests in algorithms like neural networks and decision trees.
By understanding inductive bias, you can gain valuable insights into how machine learning models work and make informed decisions when building and deploying them.
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...IJECEIAES
Medical image analysis has witnessed significant advancements with deep learning techniques. In the domain of brain tumor segmentation, the ability to
precisely delineate tumor boundaries from magnetic resonance imaging (MRI)
scans holds profound implications for diagnosis. This study presents an ensemble convolutional neural network (CNN) with transfer learning, integrating
the state-of-the-art Deeplabv3+ architecture with the ResNet18 backbone. The
model is rigorously trained and evaluated, exhibiting remarkable performance
metrics, including an impressive global accuracy of 99.286%, a high-class accuracy of 82.191%, a mean intersection over union (IoU) of 79.900%, a weighted
IoU of 98.620%, and a Boundary F1 (BF) score of 83.303%. Notably, a detailed comparative analysis with existing methods showcases the superiority of
our proposed model. These findings underscore the model’s competence in precise brain tumor localization, underscoring its potential to revolutionize medical
image analysis and enhance healthcare outcomes. This research paves the way
for future exploration and optimization of advanced CNN models in medical
imaging, emphasizing addressing false positives and resource efficiency.
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELgerogepatton
As digital technology becomes more deeply embedded in power systems, protecting the communication
networks of Smart Grids (SG) has emerged as a critical concern. Distributed Network Protocol 3 (DNP3)
represents a multi-tiered application layer protocol extensively utilized in Supervisory Control and Data
Acquisition (SCADA)-based smart grids to facilitate real-time data gathering and control functionalities.
Robust Intrusion Detection Systems (IDS) are necessary for early threat detection and mitigation because
of the interconnection of these networks, which makes them vulnerable to a variety of cyberattacks. To
solve this issue, this paper develops a hybrid Deep Learning (DL) model specifically designed for intrusion
detection in smart grids. The proposed approach is a combination of the Convolutional Neural Network
(CNN) and the Long-Short-Term Memory algorithms (LSTM). We employed a recent intrusion detection
dataset (DNP3), which focuses on unauthorized commands and Denial of Service (DoS) cyberattacks, to
train and test our model. The results of our experiments show that our CNN-LSTM method is much better
at finding smart grid intrusions than other deep learning algorithms used for classification. In addition,
our proposed approach improves accuracy, precision, recall, and F1 score, achieving a high detection
accuracy rate of 99.50%.
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsVictor Morales
K8sGPT is a tool that analyzes and diagnoses Kubernetes clusters. This presentation was used to share the requirements and dependencies to deploy K8sGPT in a local environment.
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...amsjournal
The Fourth Industrial Revolution is transforming industries, including healthcare, by integrating digital,
physical, and biological technologies. This study examines the integration of 4.0 technologies into
healthcare, identifying success factors and challenges through interviews with 70 stakeholders from 33
countries. Healthcare is evolving significantly, with varied objectives across nations aiming to improve
population health. The study explores stakeholders' perceptions on critical success factors, identifying
challenges such as insufficiently trained personnel, organizational silos, and structural barriers to data
exchange. Facilitators for integration include cost reduction initiatives and interoperability policies.
Technologies like IoT, Big Data, AI, Machine Learning, and robotics enhance diagnostics, treatment
precision, and real-time monitoring, reducing errors and optimizing resource utilization. Automation
improves employee satisfaction and patient care, while Blockchain and telemedicine drive cost reductions.
Successful integration requires skilled professionals and supportive policies, promising efficient resource
use, lower error rates, and accelerated processes, leading to optimized global healthcare outcomes.
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...shadow0702a
This document serves as a comprehensive step-by-step guide on how to effectively use PyCharm for remote debugging of the Windows Subsystem for Linux (WSL) on a local Windows machine. It meticulously outlines several critical steps in the process, starting with the crucial task of enabling permissions, followed by the installation and configuration of WSL.
The guide then proceeds to explain how to set up the SSH service within the WSL environment, an integral part of the process. Alongside this, it also provides detailed instructions on how to modify the inbound rules of the Windows firewall to facilitate the process, ensuring that there are no connectivity issues that could potentially hinder the debugging process.
The document further emphasizes on the importance of checking the connection between the Windows and WSL environments, providing instructions on how to ensure that the connection is optimal and ready for remote debugging.
It also offers an in-depth guide on how to configure the WSL interpreter and files within the PyCharm environment. This is essential for ensuring that the debugging process is set up correctly and that the program can be run effectively within the WSL terminal.
Additionally, the document provides guidance on how to set up breakpoints for debugging, a fundamental aspect of the debugging process which allows the developer to stop the execution of their code at certain points and inspect their program at those stages.
Finally, the document concludes by providing a link to a reference blog. This blog offers additional information and guidance on configuring the remote Python interpreter in PyCharm, providing the reader with a well-rounded understanding of the process.
ACEP Magazine edition 4th launched on 05.06.2024Rahul
This document provides information about the third edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
Microcontroller pic 16f877 addressing modes instructions and programming
1. Microcontroller (PIC)
PIC Microcontroller Programming
Dr. Nilesh Bhaskarrao Bahadure
nbahadure@gmail.com
https://www.sites.google.com/site/nileshbbahadure/home
July 1, 2021
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 1 / 118
2. Overview
1 Syllabus
2 Course Objectives & Outcomes
3 Objectives
4 Addressing Modes
Immediate addressing mode
Register operand addressing mode
Memory operand addressing mode
Direct addressing mode
Indirect addressing mode
5 Instruction Sets of PIC16F877
Guidelines from Microchip Technology
Instruction Set:
Summary of Instructions
Encoding of instruction:
Instruction Execution Period
Pipelining of instruction fetch successive addressing
Word list
Instruction set - Group Wise
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 2 / 118
3. Syllabus
Unit Heading No. of Lectures
PIC Microcontroller Program-
ming
No of lectures - 5
Addressing modes, Instruction set, Assembly Language and C pro-
gramming.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 3 / 118
4. Course Objectives
1 To expose the students to the fundamentals of PIC Microcontroller
16F877 architecture and its Peripherals.
2 To introduce the advanced features in PIC Microcontroller 16F877.
3 To make student develop and practice assembly language and C
language programming techniques
4 To enable student demonstrate and perform hardware interfacing and
design.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 4 / 118
5. Course Outcomes
At the end of the course, the student shall be able to,
1 Describe how PIC microcontroller and its peripherals function.
2 Interpret advanced features in PIC Microcontroller 16F877.
3 Program an embedded system in assembly and C.
4 Design, implement and test a single-processor embedded systems for
real-time applications
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 5 / 118
6. Objectives
Upon completion of this chapter, you will be able to:
1 Understanding of addressing modes and its importance in writing
programs
2 Manipulate data using the WREG and MOVE instructions
3 Perform simple operations such as ADD and MOVE using the file
register and access bank in the PIC microcontroller
4 Code simple PIC assembly language programming
5 Details the execution of PIC assembly language instructions
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 6 / 118
7. Addressing Modes
To know the working principal and data handling, we need to have clear
knowledge on addressing modes of pic microcontroller. Now we can see
that how we can categorise different addressing modes of pic
microcontroller. In PIC micro controller, it having mainly five addressing
modes. Those are
1 Immediate addressing mode
2 Register operand addressing mode
3 Memory operand addressing mode
4 Direct addressing
5 Indirect addressing.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 7 / 118
8. Immediate addressing mode
In this addressing mode, the operand is a number or constant not an
address as MOVLW 43h, the operand here is data not address. So in this
addressing mode of pic microcontroller data is directly transfer. And data
is immediate after the opcode. That is why this type of addressing is
called immediate addressing. This way is fast in execution.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 8 / 118
9. Register operand addressing mode
In this addressing mode, the operand is a Register which holds the data to
be execute. Register operand addressing mode deals with the registers like:
CLR W
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 9 / 118
10. Memory operand addressing mode
In this addressing mode, the operand is an address of Memory location
which holds the data to be execute. Again memory operand addressing
mode is under two category
Direct addressing like CLRF 13h. We deal with the address or the
memory location.
Indirect addressing. we use in it INDF and FSR registers.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 10 / 118
11. Direct addressing mode
Direct Addressing is done through a 9-bit address. This address is
obtained by connecting 7th bit of direct address. By using an instruction
with two bits (RP1, RP0) from STATUS register. this is shown in Figure
1. Any access to SFR registers can be an example of direct addressing.
Figure : Direct addressing mode
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 11 / 118
12. Indirect addressing mode
It does not take an address from an instruction. But it derives from IRP
bit of STATUS and FSR registers. Addressed location is accessed through
INDF register. And INDF register in fact holds the address indicated by
the FSR. Indirect addressing is very convenient for manipulating data
arrays located in GPR registers. In this case, it is necessary to initialise
FSR register with a starting address of the array, and the rest of the data
can be accessed by increment the FSR register. Figure 2 shows the
indirect addressing concept.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 12 / 118
13. Instruction Sets of PIC16F877
We have already mentioned that microcontroller is not like any other
integrated circuit. When they come out of production most integrated
circuits are ready to be built into devices which is not the case with
microcontrollers. In order to ”make” microcontroller perform a task, we
have to tell it exactly what to do, or in other words we must write the
program microcontroller will execute. We will describe in this chapter
instructions which make up the assembler, or lower-level program language
for PIC microcontrollers.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 13 / 118
14. Instruction Sets of PIC16F877
Complete set which includes 35 instructions is given in the following table.
A reason for such a small number of instructions lies primarily in the fact
that we are talking about a RISC microcontroller whose instructions are
well optimized considering the speed of work, architectural simplicity and
code compactness. The only drawback is that programmer is expected to
master ”uncomfortable” technique of using a reduced set of 35
instructions.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 14 / 118
15. Instruction Sets of PIC16F877
The instruction sets in PIC is developed by the basis of RISC structure.
The instruction sets can be classified into 5 separate categories (depends
on the basis of type of operation). They are
1 DATA TRANSFER GROUP
2 ARITHMETIC AND LOGIC OPERATIONS GROUP
3 BIT OPERATION GROUP INSTRUCTIONS
4 PROGRAM FLOW CONTROL
5 Other instructions (Explained along with Program Flow Control)
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 15 / 118
16. Guidelines from Microchip Technology
For writing assembly language program Microchip Technology has
suggested the following guidelines.
1 Write instruction mnemonics in lower case. (e.g., movwf)
2 Write the special register names, RAM variable names and bit names
in upper case. (e.g., PCL, RP0, etc.)
3 Write instructions and subroutine labels in mixed case. (e.g.,
Mainline, LoopTime)
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 16 / 118
17. Instruction Set: I
The instruction set for PIC16C74A consists of only 35 instructions. Some
of these instructions are byte oriented instructions and some are bit
oriented instructions.
The byte oriented instructions that require two parameters (For example,
movf f, F(W)) expect the f to be replaced by the name of a special
purpose register (e.g., PORTA) or the name of a RAM variable (e.g.,
NUM1), which serves as the source of the operand. ’f’ stands for file
register. The F(W) parameter is the destination of the result of the
operation. It should be replaced by:
F, if the destination is to be the source register.
W, if the destination is to be the working register (i.e., Accumulator or W
register).
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 17 / 118
18. Instruction Set: II
The bit oriented instructions also expect parameters (e.g., btfsc f, b). Here
’f’ is to be replaced by the name of a special purpose register or the name
of a RAM variable. The ’b’ parameter is to be replaced by a bit number
ranging from 0 to 7.
Example
For example: Z equ 2
btfsc STATUS, Z
Z has been equated to 2. Here, the instruction will test the Z bit of the
STATUS register and will skip the next instruction if Z bit is clear.
The literal instructions require an operand having a known value (e.g.,
0AH) or a label that represents a known value.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 18 / 118
19. Instruction Set: III
Example
For example: NUM equ 0AH ; Assigns 0AH to the label NUM ( a constant
)
movlw NUM ; will move 0AH to the W register.
Every instruction fits in a single 14-bit word. In addition, every instruction
also executes in a single cycle, unless it changes the content of the
Program Counter. These features are due to the fact that PIC micro
controller has been designed on the principles of RISC (Reduced
Instruction Set Computer) architecture.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 19 / 118
20. Summary of Instructions
Mnemonics Description Instruction
Cycles
bcf f, b
Clear bit b of register f 1
bsf f, b
Set bit b of register f 1
clrw
Clear working register W 1
clrf f
Clear f 1
movlw k
Move literal ’k’ to W 1
movwf f
Move W to f 1
movf f, F(W)
Move f to F or W 1
swapf f, F(W)
Swap nibbles of f, putting result in F or W 1
andlw k
And literal value into W 1
andwf f, F(W)
And W with F and put the result in W or F 1
andwf f, F(W)
And W with F and put the result in W or F 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 20 / 118
21. Summary of Instructions
Mnemonics Description Instruction
Cycles
iorlw k
inclusive-OR literal value into W 1
iorwf f, F(W)
inclusive-OR W with f and put the result in
F or W
1
xorlw k
Exclusive-OR literal value into W 1
xorwf f, F(W)
Exclusive-OR W with f and put the result in
F or W
1
addlw k
Add the literal value to W and store the result
in W
1
addwf f, F(W)
Add W to f and store the result in F or W 1
sublw k
Subtract the literal value from W and store
the result in W
1
subwf f, F(W)
Subtract f from W and store the result in F
or W
1
rlf f, F(W)
Copy f into F or W; rotate F or W left
through the carry bit
1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 21 / 118
22. Summary of Instructions
Mnemonics Description Instruction
Cycles
rrf f, F(W)
Copy f into F or W; rotate F or W right
through the carry bit
1
btfsc f, b
Test ’b’ bit of the register f and skip the next
instruction if bit is clear
1 / 2
btfss f, b
Test ’b’ bit of the register f and skip the next
instruction if bit is set
1 / 2
decfsz f, F(W)
Decrement f and copy the result to F or W;
skip the next instruction if the result is zero
1 / 2
incfcz f, F(W)
Increment f and copy the result to F or W;
skip the next instruction if the result is zero
1 / 2
goto label
Go to the instruction with the label ”label” 2
call label
Go to the subroutine ”label”, push the Pro-
gram Counter in the stack
2
retrun
Return from the subroutine, POP the Pro-
gram Counter from the stack
2
retlw k
Retrun from the subroutine, POP the Pro-
gram Counter from the stack; put k in W
2
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 22 / 118
23. Summary of Instructions
Mnemonics Description Instruction
Cycles
retie
Return from Interrupt Service Routine and
re-enable interrupt
2
clrwdt
Clear Watch Dog Timer 1
sleep
Go into sleep/ stand by mode 1
nop No operation 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 23 / 118
24. Encoding of instruction:
As has been discussed, each instruction is of 14-bit long. These 14-bits
contain both op-code and the operand. Some examples of instruction
encoding are shown here.
Example
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 24 / 118
26. Instruction Execution Period
All instructions are executed in one cycle except for conditional branch
instructions if condition was true, or if the contents of program counter
was changed by some instruction. In that case, execution requires two
instruction cycles, and the second cycle is executed as NOP (No
Operation). Four oscillator clocks make up one instruction cycle. If we are
using an oscillator with 4MHz frequency, the normal time for executing an
instruction is 1 µs, and in case of conditional branching, execution period
is 2 µs.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 26 / 118
27. Pipelining of instruction fetch successive addressing I
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 27 / 118
28. Pipelining of instruction fetch successive addressing II
Figure : Pipelining of instruction fetch successive addressing
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 28 / 118
29. Pipelining of instruction fetch successive addressing III
Figure : Introduction of extra cycle for a jump/goto instruction
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 29 / 118
30. Word list
f any memory location in a microcontroller
(0x00 to 0x7F)
W work register
b bit position in ’f’ register
d destination bit (d=0:store result in W,
d=1:store result in file register f. Default
is d=1)
label group of eight characters which marks the
beginning of a part of the program
TOS top of stack
[] option
<> bit position inside register
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 30 / 118
31. Instruction set - Group Wise I
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 31 / 118
32. Instruction set - Group Wise II
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 32 / 118
33. 1. MOVLW
MOVLW
Syntax MOVLW k
Desciption 8 - bit contents of k is written in W register
Operation k ⇒ (W )
Operand 0 ≤ k ≤ 255
Flags –
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 33 / 118
34. MOVLW
Example
MOVLW 0x5A
After execution: W = 0x5A
Example
MOVLW REGISTER
Before execution: W = 0x10 and REGISTER = 0x40
After execution: W=0x40
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 34 / 118
35. 2. MOVWF
MOVWF
Syntax MOVWF f
Desciption contents of W register is copied to f register
Operation W ⇒ (f )
Operand 0 ≤ f ≤ 127
Flags –
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 35 / 118
36. MOVWF
Example
MOVWF OPTION REG
Before execution: OPTION REG = 0x20
W=0x40
After execution: OPTION REG = 0x40
W=0x40
Example
MOVWF INDF
Before execution: W=0x17
FSR = 0xC2
Address contents 0xC2 = 0x00
After execution: W=0x17
FSR = 0xC2
Address contents 0xC2 = 0x17
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 36 / 118
37. 3. MOVF f, d
MOVF f, d
Syntax MOVF f, d
Desciption Contents of f register is stored in location
determined by d operand.
If d = 0, destination is W register
If d = 1, destination is f register itself
Option d=1 is used for testing the contents
of f register because execution of this in-
struction affects Z flag in STATUS register.
Operation f ⇒ (d)
Operand 0 ≤ f ≤ 127
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 37 / 118
38. MOVF f, d
Example
MOVF FSR, 0
Before execution: FSR = 0xC2
W=0x00
After execution: W=0xC2
Z=0
Example
MOVF INDF, 0
Before execution: W=0x17
FSR=0xC2
Address contents 0xC2=0x00
After execution: W=0x17
FSR = 0xC2
Address contents 0xC2=0x00
Z=1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 38 / 118
39. 4. CLRW
CLRW
Syntax CLRW
Desciption Contents of W register evens out to zero,
and Z flag in STATUS register is set to one
Operation 0 ⇒ (W )
Operand –
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 39 / 118
40. CLRW
Example
CLRW
Before execution: W = 0x55
After execution: W=0x00
Z=1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 40 / 118
41. 5. CLRF
CLRF
Syntax CLRF
Desciption Contents of f register evens out to zero, and
Z flag in STATUS register is set to one
Operation 0 ⇒ (f )
Operand 0 ≤ f ≤ 127
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 41 / 118
42. CLRF
Example
CLRF STATUS
Before execution: STATUS=0xC2
After execution: STATUS=0x00
Z=1
Example
CLRF INDF
Before execution: FSR=0xC2
Address contents 0xC2=0x33
After execution: FSR=0xC2
Address contents 0xC2=0x00
Z=1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 42 / 118
43. 6. SWAPF f, d
SWAPF f, d
Syntax SWAPF f, d
Desciption Upper and lower half of f register exchange
places
If d = 0, result is stored in W register
If d = 1, result is stored in f register itself
Option d=1 is used for testing the contents
of f register because execution of this in-
struction affects Z flag in STATUS register.
Operation f < 0 : 3 >⇒ d < 4 : 7 >, f < 4 : 7 >⇒
d < 0 : 3 >
Operand 0 ≤ f ≤ 127
Flags –
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 43 / 118
44. SWAPF f, d
Example
SWAP REG, 0
Before execution: REG=0xF3
After execution: REG=0xF3
W=0x3F
Example
SWAP REG, 1
Before execution: REG = 0xF3
After execution: REG=0x3F
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 44 / 118
45. 7. ADDLW k
ADDLW k
Syntax ADDLW k
Desciption Contents of W register are added to 8-bit
contents of k and result is stored in W reg-
ister.
Operation (W ) + k ⇒ (W )
Operand 0 ≤ k ≤ 255
Flags C, DC, and Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 45 / 118
46. ADDLW k
Example
ADDLW 0x15
Before execution: W=0x10
After execution: W=0x25
Example
ADDLW REG
Before execution: W=0x10
Register contents REG=0x37
After execution: W=0x47
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 46 / 118
47. 8. ADDWF f, d
ADDWF f, d
Syntax ADDWF f, d
Desciption Add contents of register W to register f.
If d = 0, result is stored in W register
If d = 1, result is stored in f register itself
Operation (W ) + (f ) ⇒ d
Operand 0 ≤ f ≤ 127
Flags C, DC, and Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 47 / 118
48. ADDWF f, d
Example
ADDWF FSR, 0
Before execution: W=0x17
FSR=0xC2
After execution: W=0xD9
FSR=0xC2
Example
ADDWF INDF, 1
Before execution: W=0x17
FSR = 0xC2
Address contents 0xC2=0x20
After execution= w=0x17
FSR=0xC2
Address contents 0xC2=0x37
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 48 / 118
49. 9. SUBLW k
SUBLW k
Syntax SUBLW k
Desciption Contents of W register are subtracted from
k and result is stored in W register.
Operation k − (W ) ⇒ (W )
Operand 0 ≤ k ≤ 255
Flags C, DC, and Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 49 / 118
50. SUBLW k
Example
SUBLW 0x03
Before execution: W=0x01, C=X, Z=X
After execution: W=0x02, C=1, Z=0
Result > 0
Before execution: W=0x03, C=X, Z=X
After execution: W=0x00, C=1, Z=1
Result = 0
Before execution: W=0x04, C=X, Z=X
After execution: W=0xFF, C=0, Z=0
Result < 0
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 50 / 118
51. 10. SUBWF f, d
SUBWF f, d
Syntax SUBWF f, d
Desciption Contents of register W is subtracted from
register f.
If d = 0, result is stored in W register
If d = 1, result is stored in f register itself
Operation (f ) − (W ) ⇒ d
Operand 0 ≤ f ≤ 127
Flags C, DC, and Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 51 / 118
52. SUBWF f, d
Example
SUBWF REG, 1
Before execution: REG = 3, W=2, C=X, Z=X
After execution: REG = 1, W=2, C=1, Z=0
Result ¿ 0
Before execution: REG = 2, W=2, C=X, Z=X
After execution: REG = 0, W=2, C=1, Z=1
Result = 0
Before execution: REG = 1, W=2, C=X, Z=X
After execution: REG = 0xFF, W=2, C=0, Z=0
Result ¡ 0
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 52 / 118
53. 11. ANDLW k
ANDLW k
Syntax ANDLW k
Desciption Perform operation logic AND over the con-
tents of W register and constant k and re-
sult is stored in W register.
Operation kAND(W ) ⇒ (W )
Operand 0 ≤ k ≤ 255
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 53 / 118
54. ANDLW k
Example
ANDLW 0x5F
Before execution: W=0xA3
After execution: W=0x03
Example
ANDLW REG
Before execution: W=0xA3
REG = 0x37
After execution: W=0x23
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 54 / 118
55. 12. ANDWF f, d
ANDWF f, d
Syntax ANDWF f, d
Desciption Perfrom operation of logic AND over the
contents of register W and register f.
If d = 0, result is stored in W register
If d = 1, result is stored in f register itself
Operation (W )AND(f ) ⇒ d
Operand 0 ≤ f ≤ 127
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 55 / 118
56. ANDWF f, d
Example
ANDWF FSR, 1
Before execution: W=0x17, FSR = 0xC2
After execution: W=0x17, FSR = 02
Example
ANDWF FSR, 0
Before execution: W=0x17, FSR = 0xC2
After execution: W=0x02, FSR = 0xC2
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 56 / 118
57. 13. IORLW k
IORLW k
Syntax IORLW k
Desciption Operation logic OR is performed over the
contents of W register and over 8 bit con-
stant k, and the result is stored in W regis-
ter.
Operation kOR(W ) ⇒ (W )
Operand 0 ≤ k ≤ 255
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 57 / 118
58. IORLW k
Example
IORLW 0x35
Before execution: W=0x9A
After execution: W=0xBF
Z = 0
Example
IORLW REG
Before execution: REG = 0x37, W=0x9A After execution: W=0x9F
Z = 0
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 58 / 118
59. 14. IORWF f, d
IORWF f, d
Syntax IORWF f, d
Desciption Perfrom operation of logical OR over the
contents of register W and register f.
If d = 0, result is stored in W register
If d = 1, result is stored in f register itself
Operation (W )OR(f ) ⇒ d
Operand 0 ≤ f ≤ 127
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 59 / 118
60. IORWF f, d
Example
IORWF REG, 0
Before execution: W=0x13, REG = 0x13
After execution: W=0x93, REG = 0x13
Z=0
Example
IORWF REG, 1
Before execution: W=0x91, REG = 0x13
After execution: W=0x91, REG = 0x93
Z=0
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 60 / 118
61. 15. XORLW k
XORLW k
Syntax XORLW k
Desciption Operation exclusive OR is performed over
the contents of W register and over 8 bit
constant k, and the result is stored in W
register.
Operation kXOR(W ) ⇒ (W )
Operand 0 ≤ k ≤ 255
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 61 / 118
62. XORLW k
Example
XORLW 0xAF
Before execution: W=0xB5
After execution: W=0x1A
Example
XORLW REG
Before execution: REG = 0x37, W=0xAF After execution: W=0x18
Z = 0
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 62 / 118
63. 16. XORWF f, d
XORWF f, d
Syntax XORWF f, d
Desciption Perfrom operation of exclusive OR over the
contents of register W and register f.
If d = 0, result is stored in W register
If d = 1, result is stored in f register itself
Operation (W )OR(f ) ⇒ d
Operand 0 ≤ f ≤ 127
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 63 / 118
64. XORWF f, d
Example
XORWF REG, 0
Before execution: W=0xB5, REG = 0xAF
After execution: W=0x1A, REG = 0xAF
Z=0
Example
XORWF REG, 1
Before execution: W=0xB5, REG = 0xAF
After execution: W=0xB5, REG = 0x1A
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 64 / 118
65. 17. INCF f, d
INCF f, d
Syntax INCF f, d
Desciption Increment register f by one.
If d = 0, result is stored in W register
If d = 1, result is stored in f register itself
Operation (f ) + 1 ⇒ d
Operand 0 ≤ f ≤ 127
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 65 / 118
66. INCF f, d
Example
INCF REG, 0
Before execution: W=X, REG = 0x10, Z=0
After execution: W=0x11, REG = 0x10, Z=0
Example
INCF REG, 1
Before execution: REG = 0xFF, Z=0
After execution: REG = 0x00, Z=1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 66 / 118
67. 18. DECF f, d
DECF f, d
Syntax DECF f, d
Desciption Decrement register f by one.
If d = 0, result is stored in W register
If d = 1, result is stored in f register itself
Operation (f ) − 1 ⇒ d
Operand 0 ≤ f ≤ 127
Flags Z
Number of words 1
Number of cycles 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 67 / 118
68. DECF f, d
Example
DECF REG, 0
Before execution: W=X, REG = 0x13, Z=0
After execution: W=0x12, REG = 0x13, Z=0
Example
DECF REG, 1
Before execution: REG = 0x01, Z=0
After execution: REG = 0x00, Z=1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 68 / 118
69. 19. RLF f, d
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 69 / 118
70. 20. RRF f, d
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 70 / 118
71. 21. COMF f, d
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 71 / 118
72. 22. BCF f, d
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 72 / 118
73. 23. BSF f, d
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 73 / 118
74. 24. BTFSC f, b
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 74 / 118
75. 25. BTFSS f, b
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 75 / 118
76. 26. INCFSZ f, d
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 76 / 118
77. 27. DECFSZ f, d
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 77 / 118
78. 28. GOTO k
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 78 / 118
79. 29. CALL k
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 79 / 118
80. 30. RETURN
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 80 / 118
81. 31. RETLW k
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 81 / 118
82. 32. RETFIE
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 82 / 118
83. 33. NOP
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 83 / 118
84. 34. CLRWDT
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 84 / 118
85. 35. SLEEP
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 85 / 118
86. Pseudo Instructions
It is the instruction used to inform the Assembler about conversion of
Assembly Program into Machine Language Program. It is also called
pseudo or dummy instruction because these instructions are not executed
by Microcontroller. Rather, they are executed by the Assembler. In other
words, we say that Assembler Directives is used for Assembling and they
are not consuming any Memory Location because they are not executed by
Microcontroller.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 86 / 118
87. Pseudo Instructions... I
1 ORG: (ORIGIN)
ORG Assembler Directive is used to initialize starting Memory
Location of the program. There is no memory space allocated for the
ORG Assembler Directive. In the program, ORG is always initialized
at the beginning.
In some of the Assemblers, ORG is used instead of ORG Assembler
Directive. ORG Assembler Directive is always followed by a number
which may be represented in decimal or hexadecimal. If the given
number is in the decimal, then writing D at the end of the number is
optional. But when given number is in the hexadecimal, then put H
at the end of the number. Whenever the number is given in any
format, assembler is always converted into the hexadecimal.
FORMAT OF ORG:
ORG 100 i.e. ORG 0064H, ORG 100H, ORG $
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 87 / 118
88. Pseudo Instructions... II
2 DB: (Define Byte):
This Assembler Directive is used to allocate 1 Memory Location to
each byte. So one memory location is reserved. Along with DB
Assembler Directive, 8-bit number is given either in decimal, binary or
in hexadecimal. If the number is given in the decimal format, then it
is optional to end the number with ’D’. But when the number is given
in the binary format, then put B at the end of the number. If the
number is given in hexadecimal, then put H at the end of the
number. Regardless of this number system, Assembler always
converts the given number into the hexadecimal. Apart from this
number system, it is also possible to allocate or give ASCII numbers
or characters with this DB Assembler Directive. To give the ASCII
value, it always includes either in single or double Quotation mark.
Quotation mark indicates the given string represented in ASCII. Its
simple application is used to display program in LCD Screen. So we
are using DB, to save more number of bytes.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 88 / 118
89. Pseudo Instructions... III
Format of DB:
DB 12((12) d means (0CH). So the starting Memory Location is
allocated.)
DB 1001 0101B (binary is represented as 95H in Hexadecimal.)
DB 45H(Given Number in Hexadecimal.)
DB ’BHEL’/ DB ”BHEL”, both are possible. Since the single
Inverted Comma is possible in Simulator and the Double Inverted
Comma is possible.
For example: ORG 0500H
0500H → DATA1: DB 45H, 67H, 01H.
Given the Data starting memory Location is 0500H.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 89 / 118
90. Pseudo Instructions... IV
3 EQU: (EQUATE)
This Assembler Directive is used to assign constant value to any
value. For example: Label EQU 1000H, then after executing this, the
value of Label becomes 1000H.
Format:
Label EQU value or Expression which may be Register, Accumulator,
Jump.
Use of Equate:
Consider the example of Counter Value. Assume Counter value is 25,
then using EQU it may be defined as
COUNT EQU 25
MOV R2, #Count
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 90 / 118
91. Pseudo Instructions... V
4 END
END means the end of Assembly Process. So, no instruction either
belonging to Assembler or microcontroller is executed after END.
END gives only once in a program and that to be in the last
indicating end of Assembly Process. Some Assembler will Support
.END instead of END Assembler Directive.
5 SET
This directive is used to define a constant value or a fixed address. In
this regard, the SET and EQU directives are identical. The only
difference is the value assigned by the SET directive may be
reassigned later.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 91 / 118
92. Pseudo Instructions... VI
6 LIST directives
Unline ORG and END, which are used by all assemblers, the LIST
directive is unique to the PIC assembler. It indicates to the assembler
the specific PIC chip for which the program should be assembled. It is
used as follows:
LIST P = 16F877
The above tells the PIC assembler to assemble the program
specifically for the PIC16F877 microcontroller. We use LIST to state
the target chip.
7 #include directive
The #include directive tells the PIC assembler to use the libraries
associated with the specific chip for which we are compiling the
program.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 92 / 118
93. Pseudo Instructions... VII
8 config directive
The config directive tells the assembler the configuration bits for the
targeted PIC chip.
9 radix directive
we can use the radix directive to indicate whether the numbering
system is hexadecimal or decimal. The default is hex if we do not use
the radix directive.
Example: radix dec
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 93 / 118
94. Assembly and C Language Programming
Program 1
Write an assembly language programming to add two 8-bit numbers 28h
and 56h and store the result in register W.
Solution
Instructions Comments
movlw 0x28 ; copy data 28h to the W register
movwf 0x20 ; copy contents of W register to memory location/file reg-
ister 20h
movlw 0x56 ; copy data 56h to the W register
addwf 0x20, 0 ; add contents of W register with the contents of file register
20h and store the result in W register
goto $ ; stop execution
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 94 / 118
95. Simulation - Program 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 95 / 118
96. Assembly and C Language Programming
Program 2
Write a program to copy the value 55H into RAM locations 40h to 44h
using
(A) Direct addressing mode
(B) Register indirect addressing mode
(C) A loop
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 96 / 118
97. Solution - (A)
Instructions Comments
org 0x0004 ; interrupt vector location
main: ; start of program
MOVLW 0x55 ; copy data 55h to W register
MOVWF 0x40 ; copy contents of W register to memory location/FSR 40h
MOVWF 0x41
MOVWF 0x42
MOVWF 0x43
MOVWF 0x44
goto $
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 97 / 118
98. Solution - (B)
Instructions Comments
org 0x0004 ; interrupt vector location
main: ; start of program
MOVLW 0x55 ; copy data 55h to W register
MOVWF 0x40 ; copy contents of W register to memory location/FSR 40h
MOVWF 0x41
MOVWF 0x42
MOVWF 0x43
MOVWF 0x44
goto $
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 98 / 118
99. Simulation - Program 1
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 99 / 118
100. Assembly and C Language Programming
Program 3
Write an assembly language programming to add two 16-bit numbers
present in the memory location 21h-20h and 31h-30h and store the result
in memory location 31h-30h.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 100 / 118
101. Assembly and C Language Programming
Solution
Instructions Comments
org 0x0000
x EQU 0x20 ; Define memory location 20h
y EQU 0x30 ; Define memory location 30h
nop ; nop required for icd
goto main ; go to beginning of program
org 0x0004 ; interrupt vector location
main:
movf x,W ; copy contents of 20h to reg W
addwf y,f ; Add contents of Reg W and Mem Loc 30h and store result in ML 30
btfsc STATUS,C ; Check for carry if C = 1 add 1 to the contents of ML 30h
incf y+1,f
movf x+1,W ; copy contents of ML 21h to Reg W
addwf y+1,f ; Add contents of Reg W and Mem Loc 31h and store result in ML 31
goto $ ; stop execution
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 101 / 118
102. Simulation - Program 3
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 102 / 118
103. Assembly and C Language Programming
Program 4
Write an assembly language programming to add two 32-bit numbers
present in the memory location 23h to 20h and 33h to 30h and store the
result in memory location 33h to 30h.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 103 / 118
104. Assembly and C Language Programming
Solution
Instructions Comments
org 0x0000
x EQU 0x20 ; Define memory location 20h
y EQU 0x30 ; Define memory location 30h
nop ; nop required for icd
goto main ; go to beginning of program
org 0x0004 ; interrupt vector location
main:
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 104 / 118
105. Assembly and C Language Programming
Solution
Instructions Comments
movf x,W
addwf y,f ; add byte 0 (LSB)
movf x+1, W
btfsc STATUS, C
incfsz x+1, W
addwf y+1,f ; add byte 1
movf x+2, W
btfsc STATUS, C
incfsz x+2, W
addwf y+2,f ; add byte 2
movf x+3, W
btfsc STATUS, C
incfsz x+3, W
addwf y+3,f ; add byte 3
goto $ ; stop execution
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 105 / 118
106. Simulation - Program 4
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 106 / 118
107. Assembly and C Language Programming
Program 5
Write an assembly language programming to subtract two 16-bit numbers
present in the memory location 21h-20h (LSB) and 31h-30h (MSB) and
store the result in memory location 31h-30h.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 107 / 118
108. Assembly and C Language Programming
Solution
Instructions Comments
org 0x0000
x EQU 0x20 ; Define memory location 20h
y EQU 0x30 ; Define memory location 30h
nop ; nop required for icd
goto main ; go to beginning of program
org 0x0004 ; interrupt vector location
main:
movf x, W ; copy contents of ML 20h to Reg W
subwf y, f ; subtract LSB y-w put result in y
movf x+1, W ; get MSB
btfss STATUS, C ; if borrow from LSB subtraction
incfsz x+1, W ; increment copy of MSB
subwf y+1, f ; subtract MSB
goto $ ; stop execution
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 108 / 118
109. Simulation - Program 5
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 109 / 118
110. Assembly and C Language Programming
Program 6
Write an assembly language programming to subtract two 32-bit numbers
present in the memory location 23h to 20h and 33h to 30h and store the
result in memory location 33h to 30h.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 110 / 118
111. Assembly and C Language Programming
Solution
Instructions Comments
org 0x0000
x EQU 0x20 ; Define memory location 20h
y EQU 0x30 ; Define memory location 30h
nop ; nop required for icd
goto main ; go to beginning of program
org 0x0004 ; interrupt vector location
main:
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 111 / 118
112. Assembly and C Language Programming
Solution
Instructions Comments
movf x,W
subwf y,f ; subtract byte 0 (LSB)
movf x+1, W
btfss STATUS, C
incfsz x+1, W
subwf y+1,f ; subtract byte 1
movf x+2, W
btfss STATUS, C
incfsz x+2, W
subwf y+2,f ; subtract byte 2
movf x+3, W
btfss STATUS, C
incfsz x+3, W
subwf y+3,f ; subtract byte 3
goto $ ; stop execution
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 112 / 118
113. Que - 1
2017 (SLR - TJ-205) - Marks 1
The CALL and GOTO instruction provides . . . . . . bits of address to allow
branching within any . . . . . . program memory page.
(a) 13 bit, 8k
(b) 16 bit, 64k
(c) 11 bit, 2k
(d) none of these
Answer
(c) 11 bit, 2k
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 113 / 118
114. Que - 2
2017 (SLR-VB-179) - Marks 4
Explain the logical instructions named as XORLW, XORWF, IORLW AND
IORWF
Answer
Explain instructions 13, 14, 15 and 16
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 114 / 118
115. Que - 3
2016 (SLR-EP-142) - Marks 1
Before execution of ANDLW 0x5F the working register contents were
0xA3. The contents after execution will be
(a) 0x5F
(b) 0x03
(c) 0xFF
(d) none of these
Answer
(b) 0x03
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 115 / 118
116. Que - 4
2016 (SLR-EP-142) - Marks 5
Explain logical instructions related to PIC
Answer
Explain instructions 11, 12, 13, 14, 15 and 16
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 116 / 118
117. References
[1, 2, 3, 4]
Muhammad Ali Mazidi, Rolin D. McKinlay, and Danny Causey.
PIC Microcontroller and Embedded Systems - Using Assembly and C
for PIC18.
Pearson International Edition, Upper Saddle River, NJ, 2008.
Martin P. Bates.
Programming 8 - bit PIC Microcontrollers in C with Interactive
Hardware Simulation.
Newnes Press Private Limited, United Kingdom, 2008.
Ajay V. Deshmukh.
Microcontrollers Theory and Applications.
Tata McGraw Hill, New Delhi, India, 2008.
John B. Peatman.
Design with PIC Microcontroller.
Prentice Hall, New Delhi, India, 1997.
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 117 / 118
118. Thank you
Please send your feedback at nbahadure@gmail.com
For download [Click Here]
Dr. Nilesh Bhaskarrao Bahadure (PhD) Microcontroller (PIC) July 1, 2021 118 / 118