External laboratory board
PORTB (RB7–RB0) is an eight-bit data bus. RA3–RA0 select a board latch, and a rising RA4 edge clocks the byte into it. RA4 is treated as having an external pull-up. Configure TRISA = 0 and TRISB = 0 for output. The board is an external teaching accessory, not extra PIC memory or instructions.
| Latch | Output |
|---|
| Latch 0 | LED bank |
| Latches 1–4 | 4-digit 7-segment display |
| Latches 5 / 6 | 2×16 character LCD |
| Latch 7 / RB0 INT | Buttons & buzzer |
| Latch 8 | Serial terminal |
BANKSEL ADCON1
MOVLW 6
MOVWF ADCON1
BSF STATUS, RP0
CLRF TRISA
CLRF TRISB
BCF STATUS, RP0
CLRF PORTA ; select LED latch; RA4 low
MOVLW 0xAA
MOVWF PORTB
BSF PORTA, 4 ; rising clock: capture data
BCF PORTA, 4
To read inputs, choose their source above the lab and set TRISB to 0xFF. Switches return eight bits; keypad returns 0–15 or 255; buttons return a bit mask. PORT writes and bit operations follow PIC read-modify-write behaviour, so always configure direction first.
PIC16F877 device model
Original PIC16F877: 8,192 × 14-bit program words, 368 bytes of RAM in four banks, 256 EEPROM bytes, 33 I/O pins across PORTA–PORTE, an eight-level return stack and all 35 instructions. STATUS RP1:RP0 select the direct bank; IRP extends FSR for indirect addressing. BANKSEL emits two real instructions. CALL/GOTO take an 11-bit operand and use PCLATH for program pages.
RAM: 020–07F, 0A0–0EF, 110–16F and 190–1EF. The top 16 addresses in each bank share RAM 070–07F. Enter a three-digit memory address to inspect any bank. PORTA/PORTE start in analogue mode. Set ADCON1=6 for the external digital lab.
On-chip peripheral lab
AN0–AN7 inputs accept 0–5 V. ADCON0 starts conversion; ADCON1 controls channel configuration, voltage references and result alignment. Conversion completes after 12 simulated instruction cycles. Set voltages after loading a demo. Timer0 supports internal and external clocks; Timer1 supports prescaling, overflow and external pulses; Timer2 supports PR2, prescaling and postscaling. CCP capture uses the edge buttons (rising except mode 4); compare uses Timer1 and PWM uses Timer2 on RC2/RC1. The display samples pin levels; it does not draw a waveform.
The hardware USART supports asynchronous byte transmit and a two-byte receive FIFO with overrun. Enable SPEN/TXEN/CREN in code. At 4 MHz the simulator applies baud-rate frame delays; receive bytes are injected by the lab. The original parallel serial bridge remains available independently.
MSSP supports deterministic byte exchanges with a configurable reply and completion flags, plus I²C start, restart, stop, receive and acknowledge control completion. PSP host write/read simulates PORTD buffer strobes and flags. These are register-level teaching models: synchronous/9-bit USART, I²C slave addressing/arbitration, SPI clock phase waveforms and electrical bus contention are not modelled.
EEPROM and single-word flash writes require the 55/AA EECON2 unlock sequence. EEPGD selects flash; completion takes four simulated cycles. Reverse Step restores flash, EEPROM, peripheral buffers, counters, output and CPU state. Already played sound cannot be reversed. SLEEP pauses the runner; use an enabled interrupt to wake. Watchdog timing is nominal. This is an educational instruction simulator, not a silicon timing validation tool.
Microchip PIC16F87X datasheet, DS30292D
Assembly and Hex
All 35 documented instructions are assembled, decoded and executed. File destinations are W/0 or F/1; omitted destination defaults to F. Decimal is the default; use 0xAA, H'AA', B'10101010', or D'170'. Supports labels, EQU, CBLOCK/ENDC, ORG, DW, __CONFIG and DE at ORG 0x2100. Standard device symbols are built in. Macros and external include processing are not implemented; LIST/INCLUDE device headers are accepted for compatibility.
Hex mode accepts standard Intel HEX with checksums, or four-digit 14-bit words such as 000: 30AA 0086. Intel HEX uses byte addresses; the listing and word-entry format use word addresses. Saving Hex exports Intel HEX. Assembly/Hex switching reassembles or disassembles; original comments and labels cannot be reconstructed from opcodes.
Debugging
F7 executes one instruction. Gold register highlights remain until another instruction executes. F8 steps over CALL; Pause can interrupt it. Click an execution address to toggle a breakpoint. Run stops before that address; Step executes through it. Full Reset clears CPU, memories, breakpoints, trace and hardware while retaining the editor text. MCLR retains program and EEPROM.
Choose a demo, press Assemble & load, then Step or Run. Input demos loop: use Pause to inspect them. Font settings include a master Panel font control and independent window controls.