Getting Started

What is PIC Simulator?

PIC Simulator is a web-based PIC microcontroller assembly language programming and simulation environment. It allows you to write, assemble, and simulate PIC assembly code directly in your browser without any additional software installation.

PIC Simulator main application interface showing editor, simulator, and GPIO controls

System Requirements

  • Modern web browser (Chrome, Firefox, Safari, Edge)
  • JavaScript enabled
  • No additional software required

Quick Start Guide

  1. Open the application in your web browser
  2. Select an example from the Examples menu
  3. Click "Assemble" to compile your code
  4. Click "Run" to start simulation
  5. Use GPIO controls to interact with your program
Tip: Start with the "Blink" example to get familiar with the interface and basic operations.

Editor Features

Code Editor

The built-in code editor provides syntax highlighting and basic editing features for PIC assembly language.

Code editor with syntax highlighting and line numbers

Editor Controls

Syntax Highlighting

Advanced syntax highlighting for PIC assembly language including instructions, registers, directives, numbers, and labels. Variable names with numbers (like 'delay1') are properly highlighted as single tokens.

Line Numbers

Line numbers are displayed to help with debugging and code navigation.

Auto-indentation

Automatic indentation for better code structure and readability.

Error Highlighting

Assembly errors are highlighted in the editor with helpful error messages.

File Operations

  • New: Create a new assembly file with a helpful blank template
  • Open: Load an existing assembly file from your computer
  • Save: Save your current work as a .asm file
  • Examples: Load pre-written example programs
File menu showing New, Open, Save options

New File Template

When you create a new file or start the application, you'll see a helpful blank template that includes:

  • Basic program structure with entry point and main loop
  • Commented examples for common PIC operations
  • Placeholder sections for subroutines and variables
  • Proper PIC16F84A program format
Tip: The blank template provides a solid foundation for your PIC programs with helpful commented examples that you can uncomment and modify as needed.

Dark Mode

PIC Simulator includes a comprehensive dark mode that can be toggled using the dark mode checkbox in the main menu. Dark mode provides:

  • Dark backgrounds for all panels and widgets
  • Light text for better readability
  • Consistent dark theme across the entire application
  • Professional appearance that's easy on the eyes
Tip: Dark mode is especially useful for extended programming sessions and provides a modern, professional development environment.

Assembler

Assembly Process

The assembler converts your PIC assembly code into machine code that can be executed by the simulator.

Assembler output showing machine code and symbol table

Supported Instructions

Data Movement

MOVLW, MOVWF, MOVF, SWAPF, CLRF, CLRW

Arithmetic

ADDWF, SUBWF, ADDLW, SUBLW, INCF, DECF

Logic

ANDWF, IORWF, XORWF, ANDLW, IORLW, XORLW

Control Flow

GOTO, CALL, RETURN, RETLW, RETFIE

Directives

; Define constants MY_CONSTANT EQU 0x20 ; Define variables using CBLOCK CBLOCK 0x20 counter temp result ENDC ; Include files #include "definitions.inc" ; Configuration __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

Error Handling

The assembler provides detailed error messages to help you fix issues in your code:

  • Syntax errors
  • Undefined labels
  • Invalid operands
  • Memory address conflicts
Warning: Always check the assembler output for errors before running your program.

Simulator

Simulation Controls

Simulation control panel with Run, Pause, Continue, Step, and Stop buttons

Control Buttons

Run

Start continuous execution of your program

Pause

Pause the current execution while maintaining state

Continue

Resume execution from where it was paused

Step

Execute one instruction at a time for debugging

Stop

Stop the current execution

Execution Modes

  • Continuous: Run at full speed
  • Paused: Execution paused while maintaining current state
  • Step-by-step: Execute one instruction at a time
  • Breakpoints: Stop at specific instructions for debugging

Register Display

The simulator displays the current state of all PIC registers in real-time:

  • W (Working) Register
  • Status Register (flags)
  • Program Counter
  • Stack Pointer
  • All Special Function Registers
Register display showing current values and flags

Breakpoints

Overview

Breakpoints are a powerful debugging feature that allows you to pause program execution at specific lines of code. This is essential for debugging complex programs and understanding program flow.

Setting Breakpoints

Click to Toggle

Click on any line number in the code editor to set or remove a breakpoint

Visual Indicators

Breakpoints are marked with red circles next to line numbers

Persistent Storage

Breakpoints are automatically saved and restored when you reload the page

Breakpoint Management

Breakpoint panel showing active breakpoints and management controls

Breakpoint Panel Features

  • Active Breakpoints: Shows all currently set breakpoints with their addresses
  • Remove Individual: Click the "×" button to remove a specific breakpoint
  • Clear All: Remove all breakpoints at once
  • Breakpoint Count: Displays the total number of active breakpoints

Using Breakpoints for Debugging

; Example: Debugging a loop start: movlw 0x05 ; Load counter value movwf counter ; Store in counter variable loop: decfsz counter, f ; Decrement counter, skip if zero goto loop ; Continue loop ; Set breakpoint here to check final counter value nop ; Breakpoint location goto start ; Restart program

Debugging Workflow

  1. Set Breakpoints: Click on line numbers where you want to pause execution
  2. Run Program: Click "Run" to start execution
  3. Inspect State: When execution pauses at a breakpoint, examine registers and memory
  4. Continue: Use "Continue" to resume execution until the next breakpoint
  5. Step Through: Use "Step" to execute one instruction at a time from the breakpoint

Breakpoint Best Practices

💡 Tip: Set breakpoints at key decision points, loop boundaries, and after important calculations to understand program flow.
  • Strategic Placement: Set breakpoints at critical points in your code
  • Loop Debugging: Place breakpoints inside loops to monitor iteration behavior
  • Function Entry: Set breakpoints at the start of subroutines to trace function calls
  • Error Conditions: Place breakpoints where you suspect errors might occur
  • Clean Up: Remove breakpoints when debugging is complete

Breakpoint Limitations

  • Breakpoints can only be set on executable lines (not comments or labels)
  • Maximum of 16 breakpoints can be active at once
  • Breakpoints are cleared when loading a new example program

GPIO Controls

Port Configuration

Control the GPIO pins of the simulated PIC microcontroller to interact with your programs.

GPIO controls showing PORTA and PORTB pins

PORTA (5 pins)

RA0-RA4

Individual pin controls with input/output toggle and state display

PORTB (8 pins)

RB0-RB7

Individual pin controls with input/output toggle and state display

Pin States

  • Input: Pin configured as input (high impedance)
  • Output: Pin configured as output (drives high or low)
  • High: Pin state is logic high (5V)
  • Low: Pin state is logic low (0V)

Visual Indicators

Each pin has visual indicators showing:

  • Current state (high/low)
  • Direction (input/output)
  • Activity (blinking for toggling)
Tip: Use the GPIO controls to simulate external devices like buttons, LEDs, and sensors connected to your PIC.

Memory View

Memory Organization

View and monitor the memory contents of the simulated PIC microcontroller.

Memory view showing RAM, Flash, and EEPROM sections

Memory Types

RAM (Data Memory)

68 bytes of general-purpose RAM for variables and data storage

Flash (Program Memory)

1024 words of program memory containing your assembled code

EEPROM (Coming Soon)

64 bytes of non-volatile memory for persistent data storage

Memory Display Features

  • Hexadecimal address display
  • Real-time value updates
  • Memory range highlighting
  • Search and filter capabilities

User Registers

The simulator automatically detects and displays user-defined variables:

  • EQU constants
  • CBLOCK variables
  • Custom labels
User registers panel showing detected variables and their values

Examples

Built-in Examples

PIC Simulator includes several example programs to help you learn PIC assembly programming. When you first start the application, you'll see a blank template instead of an example.

Blink

Simple LED blinking program using RA0 and RB0 pins

Running Lights

Flash LEDS on PORTB

Button Controlled LED

Button input controls LED state

Timer Interrupt Blink

LED blinking using Timer0 interrupt with sleep mode

External RB0 Interrupt

External interrupt example using RB0 pin

RB Change Interrupt

RB4 to RB7 change interrupt example

Seven Segment Test

Single digit counter using seven-segment display patterns

LED Array Test

Example to test LED array functionality

Switch Array Test

Example to test switch array functionality

Loading Examples

  1. Click on the "Examples" menu
  2. Select the example you want to try
  3. The code will load into the editor
  4. Click "Assemble" to compile
  5. Click "Run" to execute
Examples menu showing available programs

Modifying Examples

Feel free to modify the example code to experiment and learn:

  • Change timing delays
  • Modify pin assignments
  • Add new functionality
  • Create your own variations
Tip: Start with simple modifications like changing delay values or pin assignments before attempting major changes.

Troubleshooting

Common Issues

Assembly Errors

Problem: "Unknown instruction" error
Solution: Check spelling and ensure the instruction is supported by the PIC16F84A

Simulation Issues

Problem: Program runs but nothing happens
Solution: Check GPIO pin configuration and ensure pins are set as outputs

Memory Issues

Problem: "Address out of range" error
Solution: Ensure memory addresses are within valid ranges (RAM: 0x00-0x4F)

Debugging Tips

  • Use step-by-step execution to trace program flow
  • Monitor register values during execution
  • Check GPIO pin states and directions
  • Verify memory contents match expectations
  • Use the assembler error messages to fix syntax issues

Performance Tips

  • Keep programs simple for better simulation performance
  • Use appropriate delay values for timing
  • Avoid infinite loops without delays
  • Monitor memory usage to avoid overflow
Tip: If you encounter issues, try the examples first to ensure the simulator is working correctly, then gradually modify them to understand the behavior.