The Art of Assembly Language Programming Using PIC® Technology,
Edition 1 Core Fundamentals
By Theresa Schousek

Publication Date: 25 Apr 2019
Description

The Art of Assembly Language Programming using PIC® Technology thoroughly covers assembly language as used in programming the PIC® Microcontroller (MCU). Using the minimal instruction set, characteristic of most PIC® products, the author elaborates on the nuances of how to execute loops. Fundamental design practices are presented based on Orr’s Structured Systems Development using four logical control structures. These control structures are presented in Flowcharting, Warnier-Orr® diagrams, State Diagrams, Pseudocode, and an extended example using SysML®. Basic math instructions of Add and Subtract are presented, along with a cursory presentation of advanced math routines provided as proven Microchip® utility Application Notes.

Appendices are provided for completeness, especially for the advanced reader, including several Instruction Sets, ASCII character sets, Decimal-Binary-Hexadecimal conversion tables, and elaboration of ten ‘Best Practices.’ Two datasheets (one complete datasheet on the 10F20x series and one partial datasheet on the 16F88x series) are also provided in the Appendices to serve as an important reference, enabling the new embedded programmer to develop familiarity with the format of datasheets and the skills needed to assess the product datasheet for proper selection of a microcontroller family for any specific project.

The Art of Assembly Language Programming Using PIC® Technology is written for an audience with a broad variety of skill levels, ranging from the absolute beginner completely new to embedded control to the embedded C programmer new to assembly language.

With this book, you will be guided through the following areas:

  • Symbols and terminology used by programmers and engineers in microcontroller applications
  • Programming using assembly language through examples
  • Familiarity with design and development practices
  • Basics of mathematical knowledge in hexadecimal
  • Resources for advanced mathematical functions

Approaches to locate resources

Key Features

  • Teaches how to start writing simple code, e.g., PICmicro® 10FXXX and 12FXXX
  • Offers unique and novel approaches on how to add your personal touch using PICmicro® ‘bread and butter’ enhanced mid-range 16FXXX and 18FXXX processors
  • Teaches new coding and math knowledge to help build skillsets
  • Shows how to dramatically reduce product cost by achieving 100% control
  • Demonstrates how to gain optimization over C programming, reduce code space, tighten up timing loops, reduce the size of microcontrollers required, and lower overall product cost
About the author
By Theresa Schousek, Vital Innovations LLC
Table of Contents

Preface

    • Purpose
    • Scope
    • Author’s Note
    • Dare we call it fun?

Chapter F1:

INTRODUCTION

    • Practical Applications
    • Why Assembly?
    • Core Families (‘Baseline,’ ‘ Midrange,’ enhanced ‘Midrange’)
    • Data Sheet Walk Through
    • Straightline Program Implementation
    • Practice Exercise – Walk Through
    • Microchip Microcontroller Course Information
    • Jargon Introduction – italics
    • Further Reading

Chapter F2:

MICROCHIP 8-BIT ARCHITECTURE

    • The Microprocessor
    • System Clock
    • Bus for Data and Program
    • Hardware Interfaces
    • Hardware Organization of Memory Address Space
    • Memory Interface
    • Program Data Storage Memory Circuits
    • Input/output Interface
    • Further Reading

Chapter F3:

INSTRUCTION SETS

    • Fields of an Instruction (See Table 2-1 in 6809)
    • Instruction Set for PICmicro® Controllers
    • General Purpose Registers
    • Special Function Registers
    • Addressing: Direct, Indirect, Indexed, and Relative
      • Compare and Status Flags
      • Calculating Relative Offsets
      • Conditional Branches

    • Code Example
    • Further Reading

Chapter F4:

BEGINNING CODE

    • 8-bit Data Transfer
    • 8-bit Addition
    • 8-bit Subtraction
    • Shift left 1 bit (Multiply by two)
    • Shift left 2 bits (Multiply by four)
    • Clear a Memory Location
    • Set a Memory Location to All Ones
    • Find Larger of Two Numbers
    • Find Smaller of Two Numbers
    • Further Reading

Chapter F5:

LOOPING CODE

    • 8-bit Sum of Data
    • 16-bit Sum of Data
    • Maximum Value
    • Minimum Value
    • Check-sum of Data
    • Number of Zero, Positive, and Negative Numbers
    • Count ‘1’ Bits
    • Further Reading

Chapter F6:

EMBEDDED CONTROL FUNDAMENTALS

    • Electrical Wiring Diagrams (how to read diagrams)
    • Breadboards (how to use standard breadboards)
    • Basic GPIO I/O
    • Specialized I/O
    • Timer Modules and Registers
    • Comparator Module
    • Paging Consideration
    • Evaluation Boards
    • Further Reading

Chapter F7:

FUNDAMENTALS of GOOD PRACTICE

Program Development

    • Structured Programming
    • Concept of Design Patterns and Interfaces
    • Pseudocode
    • Using Include files to Create Reusable Code

Program Design and Documentation

    • Programming Flow Charts
    • Warnier-Orr Diagrams

Systems Development

    • State Machine Diagrams
    • SYSML Systems Definition Language
    • Further Reading

Chapter F8:

PROGRAMMING DATA STRUCTURES

Assembly Language Concepts

    • Arrays: String Handling and Character Operations
    • Pointer Constructs
    • Procedures
    • Functions

Assembly Language Basics

    • Simple Instructions
    • Config Word
    • Flags
    • Subroutines
    • Indexing

Assembly Language Advanced

    • Interrupts
    • Jump tables
    • Stack processing
    • Using DEFINE
    • Creating MACROS
    • Further Reading

Chapter F9:

BOOLEAN LOGIC and NUMBERING SYSTEMS

Logical Operators

    • Sets and Truth Tables
    • AND
    • OR
    • Exclusive OR
    • Mask Off Most Significant 4 bits
    • Mask Off Least Significant 4 bits
    • Conditional functions (>,<,=,!=,>=,<=)
    • Complementing

Mathematical Numbering Systems

    • Binary, Hex and Decimal (with a mention of the existence of octal)
    • Multi-byte Integer Types
    • Signed Integers – cover 2s compliment extensively, but mention 1s compliment and sign-magnitude, because these still come out of some sensors and FPGAs.
    • Unsigned Integers
    • Floating Point (I doubt many people will want to use it in a PIC, but they may be given it and need to deal with it.)
    • BCD as a Type
    • Further Reading

Chapter F10:

MATHEMATICAL OPERATIONS

    • Arithmetic Operations on Bytes
    • Arithmetic Operations on Multi-byte Numbers (Using carry properly, detecting overflow, how to treat signed and unsigned differently)
    • 16-bit Data Transfer
    • 16-bit Addition
    • 16-bit Ones Complement
    • 16-bit Twos Complement

Advanced Mathematical Operations

    • Shifting and Rotating, and How to Use Instructions in a Multi-Byte Shift
    • Application Notes Review:

            • Multiplication Algorithms, Both Signed and Unsigned
            • Division Algorithms
            • Floating Point

    • Further Reading

Appendices:

A: Instruction Set Reference Tables

B: Datasheet for PICmicro 10F

C: Decimal-Hexadecimal-Binary Tables

D: ASCII Table

Book details
ISBN: 9780128126172
Page Count: 458
Retail Price : £47.95
  • Wilmshurst, Designing Embedded Systems with PIC Microcontrollers, 2e, Newnes, 2009, 9781856177504, $51.95
  • Wilmshurst and Toulson, Fast and Effective Embedded Systems Design: Applying the ARM mbed, Newnes, 2012, 9780080977683, $59.95
  • Ibrahim, PIC Microcontroller Projects in C, 2e, Newnes, 2014, 9780080999241, $64.95
Audience

Electrical, Mechanical, Industrial engineers. Software Programmers trained in a higher level language, with no electrical engineering or embedded control background; Embedded/Firmware or Hardware designers, and Undergraduate Engineering students