Building Robots at School

October 25, 2009

PIC Assembly Language Using PICBots

Filed under: Uncategorized — dtengineering @ 11:20 am

Assembly language is cool.  Not just because it is the most fundamental level at which one can write a computer program… using the bare hardware instructions of the microcontroller itself… but because it forces the programmer to develop a fundamental understanding of what, exactly, a processor is doing when it is running any program.  Teaching assembly teaches fundamental skills such as binary and hexadecimal representations of numbers, the difference between a bit, byte and word, the importance of interrupts and — most importantly — forces a logical, procedural thought process.
The Set Up Screen From PICBots
Unfortunately there isn’t a lot of material out there to introduce high school students to assembly language, and even less of it is free.  So about ten years ago I started writing some handouts for my students, and in 2003 I consolidated them into a roughly 20-hour introduction to PIC assembly language.  The key to this was a wonderful little software simulation of the PIC 16c74 microcontroller called “PICBOTS”.  (See the post, below, for a download link.)  Unfortunately the company that wrote PICBOTS, Innovatus, has long since disappeared… but their freely downloadable code has survived, and when combined with the equally free MPLAB compiler from Microchip (still very much in business) has kept my worksheets reasonably relevant.  Some of the references to “the RISC chips from Motorola in Apple computers” are a bit dated, but the fundamentals will be sound for a long time to come.

I’ve posted my handouts… about 40 pages worth… here in .pdf format in the hopes that they will be of use to other teachers looking for a low-cost way to introduce low-level computer fundamentals to their students in an intereactive and engaging manner.

1 Binary Worksheet  An introduction to Hexadecimal and Binary
2 DIGITAL LOGIC worksheet How transistors form logic gates, and how logic gates can create useful functions
3 The PIC Microcontroller A brief introduction to the PIC 16f84a Microcontroller
3a The PIC 16f627a Microcontroller Worksheet 3 updated a few years later for the more current 16f627a
4 First MPLAB program Getting started in MPLAB
4c Inside The PIC Microcontroller How compilers create machine code for you… there is no Worksheet 4b
5 Loops and Input Getting into PICBOTS and creating some useful routines — the decfsz command.
6 Shortcuts and Math Cleaning up the code a bit and the subwf command
7 Interrupts I really, really, really like interrupts.  An intro to a very powerful tool and a PICBOTS assignment.
8 Pic Control Stepping away from PICBOTS, how do you get a real PIC to do a something real?
9 PIC Inputs How can you get a real PIC to read a real input?
11b The Sony IR Protocol and PIC BASIC I’m too lazy to program an IR reading code in Assembly, so I used PIC Basic from MELABs.  If you’ve got the cash, though, PIC BASIC PRO, from the same company is much more complete and definitely worth getting.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: