Program Counter Simulator

PC trace

Use labels like loop:, sequential instructions such as LOAD or ADD, branches such as BR label or BR +8, plus JMP, CALL, RET and HALT.

This teaching simulator assigns an address to each non-empty instruction line and traces how a simplified program counter (PC) moves. It is not a line, statement or token counter and does not compile or execute a programming language.

How to trace a listing

  1. 1

    Enter a short listing

    Use one fixed-width instruction per line, with optional ASCII labels such as loop:.

  2. 2

    Choose the address model

    Set the start address, 1-, 2-, 4- or 8-byte instruction size, 16-, 24- or 32-bit width and address display.

  3. 3

    Set trace behavior

    Treat every recognized branch as taken or not taken, choose 1–80 steps, then inspect each PC transition.

Supported model

Listing item Simulator behavior
Other opcode, such as LOAD or ADD Advance by the selected fixed instruction size
BR, BRA, BRANCH, BEQ, BNE, BGT, BGE, BLT, BLE, BZ, BNZ, JZ, JNZ Follow the global taken/not-taken setting
JMP, JUMP, GOTO Jump to a label or numeric target
CALL, JSR, BL / RET, RETURN Push / pop a simulated return address
HALT, HLT, STOP Stop at the current PC

Targets may be ASCII labels, decimal addresses or 0x hexadecimal addresses. A signed target such as +8 is relative to the next sequential PC; an unsigned number is absolute. Addresses wrap to the chosen 16-, 24- or 32-bit width. // and ; start comments. Operands are displayed but never evaluated.

Limits and privacy

  • Input is truncated to 1,800 characters and parsing stops after 200 instructions.
  • The trace is limited to 1–80 steps. All recognized conditional branches share one global branch choice.
  • The model does not emulate registers, memory, flags, pipelines, delay slots, instruction encoding or variable instruction lengths.
  • In the standard tool the listing is sent to this site. Funnel mode also includes it in the page URL. Do not paste confidential or proprietary code.

Frequently Asked Questions

No. It assigns addresses to instruction lines and traces PC control flow; it does not report source lines, statements or tokens.

No. It recognizes a small generic set of control-flow opcode names. All other opcodes simply advance the PC, and operands are not executed.

The signed offset is added to the next sequential PC. At PC 0x1000 with 4-byte instructions, BR +8 targets 0x100C.

It is sent to this site for server-side rendering, and funnel mode places it in the URL. No external code-analysis API is used, but confidential code should not be pasted.

Related Tools

Tool available in other languages