CSE 510 Project Milestone: An assembler for the PIC 16C84 Microcontroller
My Project Milestone was to put together a portable PIC 16C84 assembler
and disassembler and demonstrate their correct operation. In
particular, I need to demonstrate that the assembler can assemble code
into an object format (INHX8M), which the disassembler can correctly
disassemble back to a reasonable approximation of the original code.
For details on the 16C84 chip look here.
(The INHX8M object format doesn't have symbol tables, so I can't do
symbols in the disassembly.)
Assembler "features" as of the present:
- It is a mostly Microchip-compatible (MPALC) assembler, with no Parallax
- Is a one-pass assembler (sort of). Nodes containing forward references or
other undefined symbols are added to a list linked to the symbol structure.
When the symbol is finally defined, all the nodes that reference it are
changed to constants. Whenever all of an opcode's arguments are constants,
the opcode is evaluated and code for it is generated.
- Has no INCLUDE psuedo-op (hooks are in the code, but time is short).
- Has no macros.
- No IF, ELIF, ELSE, or ENDIF.
- Only the INHX8M output format is available.
- Assembly listings aren't too good, thanks to the forward reference
- It does have a BIT psuedo-op for easy "file_reg,bit"
- It has separate address counters, memory allocation and ORG commands
for the data and EEPROM memory spaces (DORG, EORG, DBYTE, EEBYTE, etc).
- The PIC 16C84 register and bit declarations are built into the
assembler. No INCLUDE "PICEQU.H" need be done (nor is possible at the
- Not all of MPALC's odd constant formats are supported.
- It has standard C-like operator precedences, not simple left-to-right
precedence, plus has all of C's integral operators.
- No GUI, or any frills like that. It should run with almost any ANSI C
compiler and POSIX-compatible standard C library package.
- The lexical analyzer is made using flex features, so flex is required.
The parser works with standard yacc, byacc, and bison.
The assembler and disassembler worked, and were used to:
- assemble a simple test program
- disassemble the resulting hex file
- load the program into a 16C84 and test it
The PIC 16C84 is an 8-bit CMOS EEPROM microcontroller. Here is the overview
from its manual:
High performance RISC-like CPU:
- Only 35 single-word instructions to learn
- All instructions are single-cycle (400 ns) except for program branches,
which are two-cycle
- Operating speed: DC - 10 MHz clock (DC - 400 ns instruction cycle)
- 14-bit wide instructions
- 8-bit wide data path
- 1024 x 14 on-chip EEPROM program memory
- 36 x 8 general purpose registers (SRAM)
- 15 special function hardware registers
- 64 x 8 EEPROM data memory
- 8 level deep hardware stack
- Direct, indirect, and relative addressing modes
- Four interrupt sources:
- External INT pin
- RTCC timer overflow
- PortB<7:4> interrupt-on-change
- Data EEPROM write complete
- 13 I/O pins with individual direction control
- High current sink/source for direct LED drive
- 25 mA sink max. per pin
- 20 mA source max. per pin
- 8-bit real time clock/counter (RTCC) with 8-bit programmable prescaler
Special microcontroller features:
- Power-on reset
- Power-up timer
- Oscillator start-up timer
- Watchdog timer (WDT) with its own on-chip RC oscillator for reliable
- Security EEPROM fuse for code-protection
- Power saving SLEEP mode
- User selectable oscillator options:
- RC oscillator: RC
- Crystal / resonator: XT
- High-speed crystal / resonator: HS
- Power-saving low-frequency crystal: LP
- Serial, In-System Programming (ISP) of EEPROM program and data memory
using only two pins
- Low-power, high-speed CMOS EEPROM technology
- Fully static design
- Wide operating voltage range:
- Commercial: 2.0V to 6.0V
- Industrial: 2.0V to 6.0V
- Low power consumption:
- < 2 mA @ 5V, 4 MHz
- 15 uA typical @ 2V, 32 KHz
- < 1 uA typical standby current @ 2V
For more information:
Here's a link to the PIC 16C84's manufacturer:
And, here's a link to a manufacturer of many PIC products:
This is a pointer to the link to the GNUPIC page:
There's more information here:
Andy's PIC Project Page
Don McKenzie maintains a large collection of PIC info, plus sells PC
boards and kits here:
James Cleverdon / firstname.lastname@example.org