Est. 1993 Advanced

Assembler (PIC/14-bit)

The assembly language for Microchip PIC16 microcontrollers with 14-bit instruction words, among the most commercially successful embedded processor families, powering billions of devices since the early 1990s.

Created by Microchip Technology (PIC16 midrange family); architecture originally conceived at General Instrument for the PIC1650 circa 1976

Paradigm Assembly, Imperative, Low-level
Typing None (untyped)
First Appeared 1993
Latest Version Architecture-dependent (PIC16 enhanced midrange devices with 49 instructions continue to extend the base 35-instruction ISA)

Assembler (PIC/14-bit) is the assembly language for Microchip Technology’s PIC16 family of microcontrollers, which use a 14-bit instruction word encoding. Built on a modified Harvard RISC architecture with just 35 single-word instructions, the PIC16 assembly language provides direct control over one of the most commercially successful embedded processor families in history. The landmark PIC16C84, introduced on March 16, 1993, was widely regarded as the first commercially successful microcontroller with on-chip EEPROM program memory – a breakthrough that made rapid prototyping accessible and affordable, and earned it a place in the IEEE Spectrum Chip Hall of Fame. From automotive systems to medical devices to university classrooms, PIC16 assembly has been the foundation for billions of embedded devices over more than three decades.

History & Origins

The PIC1650: A Peripheral Controller (1976)

The PIC architecture traces its origins to General Instrument, which introduced the PIC1650 in 1976. PIC originally stood for “Peripheral Interface Controller” (sometimes cited as “Programmable Interface Controller”) – the device was designed as a simple, fast I/O handler to compensate for the complex multiplexed bus of General Instrument’s CP1600 16-bit processor. The PIC1650 featured a 12-bit instruction word, 8-bit data path, Harvard architecture, and a 2-level hardware stack. It came in a 40-pin DIP package with 32 bytes of RAM and 512 words of ROM.

The PIC1650’s design philosophy – extreme simplicity, minimal instruction count, and predictable execution timing – would prove to be its most enduring legacy.

From General Instrument to Microchip Technology

In 1985, General Instrument sold its microelectronics division. The new owners redesigned the aging NMOS PIC line into CMOS technology, creating the PIC16C5x baseline family with 12-bit instruction words and 33 instructions. In 1987, Microchip Technology was formally incorporated as a spin-off. By 1989, Microchip became fully independent through an acquisition led by Sequoia Capital, and began aggressively marketing 8-bit RISC microcontrollers.

The 14-Bit Midrange Architecture Emerges (1992-1993)

Around 1992, Microchip introduced the PIC16C71, one of the first devices in the 14-bit midrange family. The wider instruction word (14 bits versus the baseline’s 12 bits) enabled a larger address space, deeper hardware stack (8 levels instead of 2), and interrupt capability – features the baseline family lacked. The PIC16C71 also included an on-chip analog-to-digital converter, a significant integration achievement for the time.

The defining moment came on March 16, 1993, when Microchip introduced the PIC16C84. Widely regarded as the first commercially successful microcontroller with on-chip EEPROM program memory, it could be electrically erased and reprogrammed in-circuit. Before the PIC16C84, reprogramming a microcontroller required UV erasure (a slow, cumbersome process involving a special windowed ceramic package and an EPROM eraser) or purchasing new one-time-programmable (OTP) parts. The PIC16C84 eliminated this barrier entirely, making rapid prototyping accessible to hobbyists and small engineering teams. At an introductory price of $3.72 in quantities of 10,000, it was affordable as well.

That same year, Microchip conducted its IPO – Fortune magazine cited it as the best-performing IPO of 1993.

The PIC16F84 and Mass Adoption (1998)

In 1998, Microchip released the PIC16F84, a flash-memory-based replacement for the PIC16C84. Nearly completely backward-compatible, the PIC16F84 offered improved program security and faster erase/write cycles. The improved PIC16F84A variant followed, supporting clock speeds up to 20 MHz. These devices became arguably the most popular microcontrollers in the hobbyist and educational communities, with an enormous ecosystem of tutorials, project books, and community forums growing around them.

The PIC16F877 (appearing around 1999-2001) extended the family with 40 pins, 8K words of flash program memory, 368 bytes of data RAM, multiple timers, USART, I2C, SPI, and a 10-bit ADC – a comprehensive feature set that made it a workhorse for more complex applications.

Design Philosophy

The PIC16 14-bit architecture reflects deliberate design choices that prioritized simplicity and deterministic behavior:

  • RISC-like minimalism: Just 35 instructions, all single-word (14 bits wide), all fitting on a single reference card. This extreme simplicity meant a programmer could memorize the entire instruction set and write code without constant reference to documentation.
  • Harvard architecture: Separate program memory bus (14-bit wide) and data memory bus (8-bit wide). Because the instruction word is wider than the data word, each instruction can encode both an opcode and operands in a single fetch – a key enabler of the one-instruction-per-cycle execution model.
  • Deterministic timing: All instructions execute in exactly one instruction cycle (4 clock cycles), except branches which take two cycles. At 20 MHz, this means 200 nanoseconds per instruction – predictable timing that is invaluable for real-time control applications.
  • Accumulator-based operation: The W (Working) register serves as an implicit operand in most two-operand instructions, keeping the instruction encoding simple and compact.

Key Features

14-Bit Instruction Word Format

The 14-bit instruction word encodes different instruction types with distinct formats:

Instruction TypeFormatDescription
Byte-Oriented6-bit opcode, 1-bit destination (d), 7-bit file register (f)d=0 stores result in W; d=1 stores result in file register
Bit-Oriented4-bit opcode, 3-bit bit number (b), 7-bit file register (f)Operates on individual bits within any register
Literal6-bit opcode, 8-bit literal value (k)Immediate data operations
Control (GOTO/CALL)3-bit opcode, 11-bit address (k)Allows addressing 2K words directly

The 35-Instruction Set

The complete instruction set consists of exactly 35 single-word instructions:

Byte-Oriented (18 instructions): ADDWF, ANDWF, CLRF, CLRW, COMF, DECF, DECFSZ, INCF, INCFSZ, IORWF, MOVF, MOVWF, NOP, RLF, RRF, SUBWF, SWAPF, XORWF

Bit-Oriented (4 instructions): BCF, BSF, BTFSC, BTFSS

Literal and Control (13 instructions): ADDLW, ANDLW, CALL, CLRWDT, GOTO, IORLW, MOVLW, RETFIE, RETLW, RETURN, SLEEP, SUBLW, XORLW

Register File and Banking

Data memory is organized into banks of 128 bytes each (up to 4 banks in standard midrange devices). Each bank contains Special Function Registers (SFRs) in the lower addresses and General Purpose Registers (GPRs) in the upper addresses.

Key registers include:

  • W (Working Register): 8-bit accumulator, one operand in all two-operand instructions
  • STATUS: Arithmetic flags (C, DC, Z), bank select bits (RP0, RP1), and power-on status
  • FSR / INDF: File Select Register and Indirect File register for pointer-based memory access
  • INTCON: Interrupt control and flags
  • PCL / PCLATH: Program counter low byte and latch high byte for computed jumps
  • TRIS registers: Data direction for I/O ports (TRISA, TRISB, etc.)
  • PORT registers: I/O port data (PORTA, PORTB, etc.)

Bank switching is performed by setting or clearing the RP0 and RP1 bits in the STATUS register. The MPASM assembler provides the BANKSEL directive to generate appropriate bank selection code automatically.

Hardware Stack

The PIC16 has an 8-level deep, 13-bit wide hardware stack. The stack is not memory-mapped and not directly accessible to the programmer – it is used automatically by CALL, RETURN, RETLW, RETFIE instructions, and interrupt vectoring. There is no hardware overflow or underflow detection; exceeding 8 levels of nesting causes the stack to wrap around silently, a common source of bugs in deeply nested code.

Interrupt Handling

The 14-bit midrange architecture supports a single interrupt vector at address 0x004. When an interrupt occurs, the processor saves the return address on the hardware stack and jumps to 0x004. The interrupt service routine must manually save and restore context (W register, STATUS register) since there is no automatic context save mechanism in the standard midrange devices. The RETFIE instruction returns from the interrupt and re-enables the global interrupt enable bit.

Syntax and Assembly Conventions

PIC16 assembly uses MPASM-style syntax with several distinctive conventions:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
    list      p=16F84A          ; Target processor declaration
    #include  <p16F84A.inc>     ; Processor-specific definitions

    __CONFIG  _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF

;--- Variable allocation ---
COUNTER EQU   0x20              ; Assign RAM address
TEMP    EQU   0x21

;--- Reset vector ---
    ORG       0x000             ; Reset vector address
    GOTO      MAIN              ; Jump to main program

;--- Interrupt vector ---
    ORG       0x004             ; Interrupt vector address
    RETFIE                      ; Return (placeholder)

;--- Main program ---
MAIN
    BSF       STATUS, RP0       ; Select Bank 1
    CLRF      TRISB             ; Set all PORTB pins as outputs
    BCF       STATUS, RP0       ; Back to Bank 0
    CLRF      PORTB             ; Clear all outputs

LOOP
    BSF       PORTB, 0          ; Set bit 0 of PORTB (LED on)
    CALL      DELAY             ; Wait
    BCF       PORTB, 0          ; Clear bit 0 (LED off)
    CALL      DELAY             ; Wait
    GOTO      LOOP              ; Repeat forever

;--- Delay subroutine ---
DELAY
    MOVLW     D'250'            ; Load decimal 250 into W
    MOVWF     COUNTER
OUTER
    MOVLW     D'250'
    MOVWF     TEMP
INNER
    DECFSZ    TEMP, F           ; Decrement, skip next if zero
    GOTO      INNER
    DECFSZ    COUNTER, F
    GOTO      OUTER
    RETURN

    END                         ; End of source file

Key syntax features:

  • Numeric formats: Decimal D'255', hexadecimal 0x1F or H'1F', binary B'10110011', octal O'377'
  • Destination bit: ADDWF REG, F (result to file register) vs ADDWF REG, W (result to W)
  • Comments: Semicolons (;)
  • Labels: Start at column 1, optionally followed by a colon
  • Directives: ORG, EQU, END, __CONFIG, #include, list, CBLOCK/ENDC, BANKSEL

Assemblers and Development Tools

MPASM (Microchip’s Official Assembler)

MPASM was Microchip’s universal macro assembler, available from the mid-1990s. It supported all PIC microcontroller families and provided full macro capabilities, conditional assembly, and multiple output formats. The final version was MPASMx v5.87. Microchip discontinued MPASM in MPLAB X v5.40 (circa 2020), replacing it with pic-as, bundled with the XC8 compiler toolchain (v2.20+). The pic-as assembler is not syntax-compatible with MPASM; Microchip provides an official migration guide for converting legacy code.

MPLAB IDE

The original MPLAB IDE was a Windows-based development environment available by the mid-1990s. The legacy MPLAB 8.x series (the final release was v8.92, approximately mid-2013) was built in Visual C++ and supported Windows only. MPLAB X IDE, released in 2011, was built on the open-source NetBeans platform and brought cross-platform support for Windows, macOS, and Linux for the first time. MPLAB X remains the current official IDE, integrating the XC8 compiler, pic-as assembler, simulator, and in-circuit debugger/programmer support.

gputils (GNU PIC Utilities)

gputils is an open-source GPL-licensed toolchain for PIC microcontrollers. It originated as gpasm, first released on July 13, 1998 by James Bowman (version 0.0.3). Craig Franklin expanded it into a full tool suite (gputils v0.0.4, March 2001), adding gplink (linker) and gplib (librarian). gputils was designed to be compatible with MPASM syntax and is available for Linux, macOS, and Windows. The companion gpsim simulator provides a compatible debugging environment.

Evolution

From PIC16C to PIC16F (1993-1998)

The transition from OTP/EEPROM-based PIC16C devices to flash-based PIC16F devices in 1998 was transformative. Flash memory offered faster erase/write cycles, better endurance, and lower cost than EEPROM. The PIC16F84 and its successors (PIC16F877, PIC16F628, PIC16F88, and many others) made PIC16 development practical for everything from one-off prototypes to mass production.

Enhanced Midrange Architecture

Microchip later introduced the PIC16F1xxxx “enhanced midrange” series, which extends the original 14-bit architecture with:

  • 49 instructions (14 additional instructions beyond the original 35)
  • Larger program and data memory
  • Automatic context save on interrupt (saving W, STATUS, BSR, FSR, and PCLATH)
  • A linear data memory access mode eliminating banking headaches
  • New peripherals including configurable logic cells (CLC), numerically controlled oscillators (NCO), and complementary waveform generators (CWG)

These enhanced devices maintain backward compatibility with the original 35-instruction set while addressing many of the architecture’s longstanding limitations.

The MPASM to pic-as Transition

The 2020 discontinuation of MPASM and transition to pic-as represented a significant ecosystem shift. While the underlying PIC16 hardware is unchanged, the assembler syntax differences mean that decades of existing MPASM code examples and tutorials require modification to work with modern tools. Key differences include changes to directives, configuration word syntax, and how processor-specific definitions are included. Microchip’s migration guide documents the necessary changes, but the transition has been a point of friction in the community.

Current Relevance

The PIC16 family remains actively manufactured and supported by Microchip Technology. New PIC16 variants continue to be released, and the architecture occupies a strong position in several market segments:

Active product lines: Microchip’s current catalog includes hundreds of PIC16 variants ranging from 6-pin devices with a few hundred bytes of memory to 64-pin devices with extensive peripheral sets. The PIC16F1xxxx enhanced midrange series represents the current state of the art within the 14-bit architecture family.

Tool support: MPLAB X IDE and the XC8 compiler (including the pic-as assembler) provide the current official development environment. Third-party tools like MikroElektronika’s mikroC/mikroASM and the open-source gputils also continue to support PIC16 development.

Market position: While ARM Cortex-M microcontrollers have overtaken 8-bit architectures in overall market share, Microchip remains a leading MCU manufacturer, and PIC-based 8-bit devices continue to be the appropriate choice for many cost-sensitive, low-pin-count, and battery-powered applications where a 32-bit processor would be unnecessary.

Community and education: A vast body of tutorials, textbooks, application notes, and forum discussions exists for PIC16 assembly programming. While new educational projects increasingly use ARM-based boards (Arduino, STM32), the PIC16 remains a valuable teaching platform for understanding fundamental microcontroller concepts due to the architecture’s simplicity.

Why It Matters

The PIC16 14-bit architecture occupies a unique position in the history of embedded computing. The PIC16C84’s 1993 introduction of affordable, electrically reprogrammable program memory was a genuine inflection point – it democratized microcontroller development by making rapid prototyping accessible and affordable for hobbyists, students, and small engineering teams who could not justify the cost and complexity of UV-erasable EPROM development workflows.

The 35-instruction set, which fits on a single reference card, proved that extreme simplicity could be a strength rather than a limitation. The architecture’s minimal instruction count and deterministic timing made it possible for engineers to understand the processor completely – a rarity as computing hardware grew increasingly complex. This transparency made PIC16 an exceptional teaching platform; generations of embedded engineers learned assembly language programming on PIC16F84A and PIC16F877A devices.

The architecture’s commercial success – Microchip became the world’s leading 8-bit microcontroller supplier by 2002, with PIC devices shipping in the billions – demonstrated that a well-designed simple architecture could compete effectively against more complex alternatives. The PIC16’s continued production more than three decades after the 14-bit midrange family’s introduction is a testament to the enduring value of architectural simplicity, deterministic behavior, and a mature ecosystem.

Timeline

1976
General Instrument introduces the PIC1650 peripheral interface controller, an 8-bit microcontroller with 12-bit instruction words designed as a companion to the CP1600 16-bit processor
1985
General Instrument sells its microelectronics division; the PIC architecture is redesigned into CMOS as the PIC16C5x baseline family with 12-bit instruction words and 33 instructions
1989
Microchip Technology becomes fully independent after acquisition by investors led by Sequoia Capital, inheriting the PIC product line
1992
PIC16C71 introduced as one of the first 14-bit midrange devices, adding interrupt capability and an on-chip A/D converter to the PIC family
1993
PIC16C84 introduced on March 16 at $3.72 per unit -- widely regarded as the first commercially successful microcontroller with on-chip EEPROM program memory, enabling electrical in-circuit reprogramming; later inducted into IEEE Spectrum's Chip Hall of Fame
1993
Microchip Technology conducts its IPO, cited by Fortune magazine as the best-performing IPO of the year
1998
PIC16F84 released as a flash-memory-based replacement for the PIC16C84, becoming one of the most popular microcontrollers for hobbyists and education worldwide
2002
Microchip becomes the number-one supplier of 8-bit microcontrollers worldwide
2011
MPLAB X IDE released, bringing cross-platform support (Windows, macOS, Linux) via the NetBeans platform; named one of EDN Magazine's Hot 100 products
2017
PIC16C84 inducted into the IEEE Spectrum Chip Hall of Fame for its pioneering role in making microcontrollers electrically reprogrammable
2020
Microchip discontinues MPASM assembler in MPLAB X v5.40, replacing it with pic-as (part of XC8 compiler v2.20+), marking the end of the classic assembler syntax era

Notable Uses & Legacy

Automotive Electronics

PIC16 microcontrollers are used in automotive sensor interfaces, dashboard displays, keyless entry systems, and communication modules, with Microchip offering AEC-Q100 automotive-qualified variants.

Industrial Control Systems

Widely used in motor controllers, process monitoring (temperature, pressure, flow sensors), conveyor automation, and PLC implementations across manufacturing environments.

Embedded Systems Education

The PIC16F84A and PIC16F877A became standard teaching platforms worldwide, with numerous university curricula and textbooks (including John Peatman's 'Design with PIC Microcontrollers') built around the 14-bit PIC16 architecture.

Consumer Electronics

PIC16 devices are found in remote controls, home appliances, electronic toys, smart home sensors, and a wide range of battery-powered consumer products due to their low cost and low power consumption.

Medical Devices

Used in patient monitoring equipment, infusion pumps, blood glucose meters, and portable diagnostic instruments where reliability, low power, and small footprint are critical.

Language Influence

Influenced By

General Instrument PIC1650 Machine Code

Influenced

Parallax SX

Running Today

Run examples using the official Docker image:

docker pull
Last updated: