Decode immediate bytes and record each stack transition.
LET’S PICTURE IT
A calculator worksheet should show the intermediate values and the actual output behavior.
SEE IT FOR YOURSELF
Watch a stack machine execute a tiny programStep 1 / 4
The program bytes are PUSH1 02, PUSH1 03, ADD, STOP. The program counter begins at byte zero.
The program bytes are PUSH1 02, PUSH1 03, ADD, STOP. The program counter begins at byte zero.PUSH1 reads its next byte as an immediate value and places two on the stack. The next instruction begins at byte two.The next PUSH1 places three above two. Stack order matters for operations that are not commutative.ADD consumes the top two values and pushes five. The next instruction is STOP at byte five; no storage write is implied by ADD.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Parse the bytecode
Use 600260030100. The two 60 bytes are PUSH1 opcodes, each followed by one immediate value byte. The next instructions are ADD and STOP.
Track the program counter
The instruction positions are zero, two, four and five. Counting every byte as an instruction would incorrectly execute the immediate data.
Track the stack convention
Write bottom first and top last: empty, then [2], then [2,3], then [5]. State the convention so another reference can be compared correctly.
Separate result and return bytes
STOP succeeds with no explicit output. The remaining stack value is not automatically returned to a caller or written to persistent storage.