Memory and the processor · A jump

Taking a
different path.

There is still an addition in our program. This time, the processor can pass right over it. A new instruction tells it where to go next.

Memory · eight locations shownAddresses 0–7

Address 3 holds our starting byte. Address 4 is where we will put the result. Values below are decimal.

Select a memory byte to edit

Address 3 starts at 41; address 4 starts at 0.

Select a location to edit it in the explorer below. The read and write always use addresses 3 and 4.

Inside the processorIntel 8080

Register A

0decimal

Binary
0000 0000
Hexadecimal
00
Carry flag CY0

CY starts at 0. If the addition runs, it sets CY to 1 if the sum exceeds 255, or 0 if it fits.

The program in memory

Addresses and bytes below are hexadecimal.

Next instruction · PC0100

← Next (PC) marks the next instruction. Shaded bytes were fetched by the last step.

Runs counts how often each instruction has executed since Start again.

Choose before the first step. This edits the jump’s destination bytes at 0104 and 0105. Start again restores the skip path and unlocks the choice.

The jump’s destination is 0108.

    010B · End of this program

    No instruction has run. PC points to the first instruction.

    PC path so far: 0100.

    Step through the program

    Enable JavaScript to run this experiment.

    Last instruction

    No instruction has run. A starts at 0.

    Change the byte at address 3

    Edits here change memory immediately. They do not change A or run an instruction.

    Byte at address 3Unsigned · 0 to 255

    Enable JavaScript to change this byte. This example shows 41.

    Change the byte

    Hex digit 2

    Hex digit 9

    Add the values of the bits that are on

    32 + 8 + 1 = 41

    See the 8080 instructions

    The first instruction is LDA 0003H: load A from memory address 3. Next comes JMP: continue at the address encoded in its next two bytes. It preserves A and the flags. Depending on its destination, ADI 1 either runs or is skipped. The final instruction is STA 0004H: store A at address 4. The load and store preserve the processor’s flags.

    ADI adds the number encoded in the instruction, regardless of which memory byte is selected. It does not add the incoming carry. Unlike INR A, which preserves carry, ADI updates CY. It also updates sign (S), zero (Z), auxiliary carry (AC), and parity (P); their before/after values appear in the record.

    This view shows the first eight locations of a 65,536-byte RAM. The instructions live elsewhere, starting at hexadecimal address 0100. The program counter, PC, tells the processor where to find its next instruction.

    Current PC: 0100 (hexadecimal). The lesson stops offering steps at 010B, just after the final instruction. This is a lesson boundary; the processor has not executed a halt instruction.

    No instruction has run.

    The record includes the reads that fetch the instruction bytes, as well as the data read or write. Editing a memory byte in the explorer is a separate learner action; it does not alter the last instruction’s record.

    Explore the Intel 8080 guide

    Skip the addition.

    Leave the destination at 0108 · Skip the addition. Take one step: the load puts 41 into A, and PC moves from 0100 to 0103.

    The next instruction is JMP 0108H: jump to address 0108. Take another step and watch PC. A stays 41, but the next-instruction marker moves directly to the store.

    An instruction for PC.

    Until now, each instruction left PC pointing just beyond its own bytes. The jump instead puts its destination address into PC. That is where the processor fetches the next instruction.

    The jump itself occupies three bytes at 0103, 0104, and 0105. The next byte in memory is at 0106, but this jump sets PC to 0108, the destination stored in its operands.

    JMP changes PC without changing A, the flags, or memory. Its destination is an address, not a number to add to A and not a byte to copy into A.

    How is the destination stored?

    C3 is the jump’s opcode. The following two bytes hold its destination, low byte first: 08 01 means address 0108. Thus the whole instruction is C3 08 01. The H in JMP 0108H marks a hexadecimal address.

    Present, but not executed.

    The addition’s bytes, C6 01, are still at 0106 and 0107. The jump does not erase them. They simply are not fetched on this path.

    After the jump, the shaded bytes belong to the jump itself. The store has the next-instruction marker. The addition is marked Skipped · not fetched, and stays visible so you can compare the program in memory with the path taken through it.

    The PC path comes from the instructions that actually ran: 0100 → 0103 → 0108 → 010B. As before, the lesson stops offering steps at the end, 010B. That boundary is not a halt instruction.

    Choose another destination.

    Press Start again, then choose 0106 · Run the addition before stepping. The jump’s bytes become C3 06 01, and its label becomes JMP 0106H. You have edited its destination in RAM; nothing has run yet.

    The jump runs in both versions. We choose its destination in advance; the processor does not make a decision about A’s value. This is an unconditional jump.

    The destination choice locks after the first step. Start again restores the original data, processor state, and skip path. These are lesson controls; the processor itself follows the instruction bytes.

    So far our jumps move forward. A jump back to an earlier instruction can make the processor repeat part of a program. That will be our next step.