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

The Art of Assembly Language Programming Using PIC® Technology

Core Fundamentals

Theresa Schousek

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

Theresa Schousek

Book details
Book preview
Table of contents
Citations

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

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
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.
Do you support text-to-speech?
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.
Is The Art of Assembly Language Programming Using PIC® Technology an online PDF/ePUB?
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