Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   

General knowledge about instructions

The PIC family has a very short range of instructions. With just about 35 instructions, there may be times where you need to find complicated solutions for operations that you thought as standard, such as a division or multiplications for example, that there is no direct instruction for them.

All instructions have just about the same format. First comes the name of the instructions. Then, comes the instructions fields. The fields may be none, one or two, according to he instruction. They could be filled with wither a register file address (f), a bit address (b), a literal field, constant data or label (k) or a destination selection (d).

Register file address (f)

A register file address is a field that indicates the absolute position of a register within the RAM. This field could be filled with either a number (e.g. 0x05h for the PORTA register) or a register name, as long as this name has been previously declared.

Bit address (b)

Each byte is composed by bits. For the 8-bit PIC 16F88 that we use, each byte is composed by 8 bits. When a field requires a bit address, this means that a number from 0 to 7 must be placed. Number 0 corresponds to the Less Significant Bit (LSB) and it is the most right placed bit in within the byte. Number 7 on the other hand corresponds to the Most Significant Bit (MSB) and it is the most left placed bit in within the byte.

Literal field, constant data or label (k)

This field is generally a number. This number may be from a previous-defined constant data, or from a label within the code.

Destination selection (d)

This field can be either 0 or one. It is used in instructions that will return a byte as a result of an operation. The destination field will define where this byte will be stored. If this field is 0, then the byte will be stored in the working register (W). If the destination is 1, then the byte will be stored back to the register that the specific operation began. If the Microchip header file is included within your code, then you can directly write 'W' for 0 or 'F' for file register.

The W is the one and only Working Register that exists in the PIC 16 series. This is a 8-bit width register used for general operations. The W register will be your best friend and therefore you need to get used to it really quick. For example, there is no direct way to add a 8-bit number with ti a file register. Instead, you need first to load this number to the W register (using the movlw instruction) and then add the W register to the file register (using the addwf instruction).

Previous page ---- Next page

Go back to the book contents

Go to the discussion forum of this book




  Email (shall not be published)


Notify me of new posts via email

Write your comments below:
BEFORE you post a comment:You are welcome to comment for corrections and suggestions on this page. But if you have questions please use the forum instead to post it. Thank you.


  • At 17 August 2011, 12:28:59 user mohsen wrote:   [reply @ mohsen]
    • hi i want totorial winding animation clip plz, tnx

  • At 12 January 2011, 10:28:58 user ashish vishwakarma wrote:   [reply @ ashish vishwakarma]
    • how to write code for 16 bit PIC Microcontroller reset ?

    No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise without the prior written permission of the author.

    Read the Disclaimer

    All trademarks used are properties of their respective owners.
    Copyright © 2007-2009 Lazaridis Giorgos.
    All rights reserved.

     HOT in heaven!

  • Disclaimer
  • Book Contents
  • Discussion forum

  • Basics
  • What will you need
  • Choosing the right PIC
  • The MPLAB
  • Getting familiar with the MPLAB environment
  • Creating a new project
  • Open and close projects
  • Creating new files and including them in the project
  • Your very first assembly program
  • Compile a program and transfer to the PIC
  • Section 1: Beginner's theory
  • Memory Organization
  • The Data Memory Organization
  • The Program Memory Organization
  • The instructions
  • General knowledge about instructions
  • Value Loading Instructions
  • Program Flow Instructions
  • Mathematic Instructions
  • Logic Function Instructions
  • Bit Orientated Instructions
  • Byte Orientated Instructions
  • Miscellaneous Instructions
  • The Basic Special Function Registers
  • The Status Register
  • The Option_Reg Register
  • The TRIS and PORT registers
  • Beginner's PIC Tutorials
  • How to use our PIC Tutorials
  • A Pushbutton turning an LED on and off
  • A Simple LED Flasher
  • Interfacing Multiple Switches - The internal Pull-Up resistors
  • An LED Sequencer
  • Interface a Single 7seg Digit
  • Interface Multiple 7seg Digits
  • A 3-digits Decimal Counter
  • A Clever Button
  • Section 2: Intermediate theory
  • Instruction Cycle Duration and Calculated Delays
  • The Timer Modules - Timer0
  • The Timer Modules - Timer1
  • The Timer Modules-Timer2

  • NEW in heaven!

    New Theory: AC electric motor working principle

     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS   

    Site design: Giorgos Lazaridis
    © Copyright 2008
    Please read the Terms of services and the Privacy policy