The Art of Assembly Language Programming Using PIC® Technology
eBook - ePub

The Art of Assembly Language Programming Using PIC® Technology

Core Fundamentals

  1. 458 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

The Art of Assembly Language Programming Using PIC® Technology

Core Fundamentals

About this book

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- 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

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access The Art of Assembly Language Programming Using PIC® Technology by Theresa Schousek in PDF and/or ePUB format, as well as other popular books in Technology & Engineering & Electrical Engineering & Telecommunications. We have over one million books available in our catalogue for you to explore.
Chapter 1

Introduction

Abstract

This chapter explores practical applications, explains the concept of core families, initiates perusal of the PIC 10F data sheet to locate information, and provides a light introduction to program pseudocode and algorithm development.

Keywords

Pseudocode; Algorithm; Program; Development; Core family; Practical; Data sheet; Embedded control; Assembly; Implementation

Practical Applications

Common applications for embedded control are devices or systems that require simple repeatable programs, with limited interaction from the user, such as switch inputs or light emitting diodes (LED) outputs. Generally, once programmed, the device continues to operate for years without any necessary changes, unless there is a desire to change the performance. The most common occurrence requiring rewriting of the program is, generally, the need to add features or performance improvements in coming years. In this text, the conscientious design of the microcontroller program is laid out in a manner to maintain upward compatibility. If you follow through with using this approach in your own designs, it will pay back in the future.
Some practical applications, suggested by Microchip, include:
  • Identification tags
  • Drug tester
  • Electronic lock
  • Electronic chime
  • Pressure sensor
  • Water consumption gauge
  • Medication dispenser
  • LED flashlight
  • Intelligent power switch
  • Light dimmer
  • Fan controller
  • Smoke/CO alarm
  • Engine governor
  • Protocol handler
  • Flat iron temperature control
  • Capacitive switch
  • Irrigation controller
  • Security monitor
Beginning with the use of Sets and operators (such as op, opcode, or operation) the relationship between real-world applications and program representation is introduced. The set S is a relationship between a set S and itself, where x ρ y is a relation “on S” that represents x and y.
Our program example will show how the elements, coins, and pushbuttons are part of a vending machine program. In this example, x is a coin which will be received prior to the selection pushbutton. They could represent a list of coins that are acceptable. Then y is a list of pushbuttons that may be selected.

Why Assembly?

There are numerous reasons to program in Assembly Language. Generally, Assembly Language is simply more efficient. One of two explanations will be appropriate: the code will take less time to execute and it will take less memory space to execute.
  • From Jan Hext, in his book Programming Structures, an example of simply accessing memory to illustrate how assembly code can use registers to accomplish the task of interchanging the values of A and B. With a high level language, an additional memory location will be necessitated. A total of six memory accesses is required.
  • temp := A ; Memory-to-memory requires 2 accesses
  • A := B; Memory-to-memory requires 2 accesses
  • B := temp ; Memory-to-memory requires 2 accesses
  • With Assembly Language, registers are used which are much faster and do not require a memory access. A total of four memory accesses is required.
  • R ← A ; Memory-to-register requires 1 access
  • A ← B ; Memory-to-memory requires 2 accesses
  • B ← R ; Register-to-memory requires 1 access
  • This code may seem only minimally better than the high level language version. However, four (4) accesses versus six (6) is a savings of 33%. Some compilers do optimize and use registers. However, this is not always the case.
In addition, when some form of a loop structure is used, the net effect is to multiply the number of accesses by the number of control loops. This is where it will clearly show an unhelpful multiplication effect. For example, if the loop was “FOR T = 1 to 10, NEXT,” the total accesses on the high level language side would be 60 (plus 10 for the loop counter) compared with the assembly language approach of 40 (plus 0 for the loop counter executed with the use of a register.) This would result in a savings of (70–40)/70 or approximately 43%.

Core Families (“Baseline,” “Midrange,” “Enhanced Midrange,” “High Performance”)

This text is intended to give the reader thorough information on using Microchip’s 8-bit Core Family Systems. Microchip groups their 8-bit products into three families: Baseline, Midrange, and Midrange Enhanced. These family systems have similar architecture, peripherals, and programming. Embedded control devices, or controllers, differ from processors as the controller user is not concerned, nor aware, with the use of devices to communicate with the controller. For example, the processor will have a keyboard and a monitor through which the user will communicate with the processor. In embedded control, the user will typically interface with the controller by way of switches and LEDs. The controller user will not necessarily even be aware of the controller’s clock speed, instruction cycles, and the like.

Baseline

Baseline families include the PIC10F, PIC12X5, PIC16X5X. The Baseline products have an 8-bit data memory access and a 12-bit wide instruction set. Paging is used to access four banks of program memory. These products have the smallest footprint of all products. There is even a small 6-pin SOT-23 in the 10F2xx series along with the 8-pin PDIP and 8-pin DFN. ...

Table of contents

  1. Cover image
  2. Title page
  3. Table of Contents
  4. Copyright
  5. Dedication
  6. Preface
  7. Chapter 1: Introduction
  8. Chapter 2: Microchip 8-bit architecture
  9. Chapter 3: Instruction sets
  10. Chapter 4: Beginning code
  11. Chapter 5: Looping code
  12. Chapter 6: Embedded control fundamentals
  13. Chapter 7: Fundamentals of good practice
  14. Chapter 8: Data and control structures
  15. Chapter 9: Logic and numbering systems
  16. Chapter 10: Mathematical operations
  17. Chapter 11: Word search solution
  18. Puzzle Solutions
  19. Appendix A: Instruction Sets
  20. Appendix B: ASCII characters
  21. Appendix C: Decimal-binary-hexadecimal characters
  22. Appendix D: Best practices
  23. Appendix E
  24. Appendix F
  25. Index