Teacher answer key

Byte Memory

Gather four kinds of evidence: prediction of relevant state; behavior across varied cases including boundaries; explanation using trace/state evidence; and a reasoned correction of one mismatch. Mark each as emerging, with support or independent using paper or your school’s existing approved process. A challenge pass is machine-behavior evidence, not proof of authorship or complete mastery. Accept equivalent correct programs; the public key is a model, not the only possible answer.

Public teaching material. Solutions are examples; equivalent correct programs may also pass the actual checks.

7. Memory: The Computer’s Notebook

Store and actually retrieve a byte after overwriting R0.

Open this lesson →

1. Predict and trace

Before running the Try program, predict its output and trace the first three executed instructions. Track the relevant registers, flags or memory as needed. Then step the program to compare.

LOAD 42
STORE 0
LOAD 99
STORE 1
LOAD 0
LOAD [0]
PRINT
LOAD [1]
PRINT
HALT

Queue input: None

Initialize memory: All bytes initially zero

Try prediction key

Output: 42, 99

InstructionPC beforePC afterR0 beforeR0 afterRelevant stateOutput
LOAD01042{"registers":[42,0,0,0,0,0,0,0],"flags":{"zero":false,"negative":false,"overflow":false},"sp":255,"stack":[],"callStack":[],"loopStack":[],"memoryReads":[],"memoryWrites":[]}None
STORE124242{"registers":[42,0,0,0,0,0,0,0],"flags":{"zero":false,"negative":false,"overflow":false},"sp":255,"stack":[],"callStack":[],"loopStack":[],"memoryReads":[],"memoryWrites":[0]}None
LOAD234299{"registers":[99,0,0,0,0,0,0,0],"flags":{"zero":false,"negative":false,"overflow":false},"sp":255,"stack":[],"callStack":[],"loopStack":[],"memoryReads":[],"memoryWrites":[]}None

2. Build and check

Read a byte-valued input (0–255), save it at memory address 10, clear R0, then retrieve it from memory and print it.

Required instruction types: INPUT, STORE, LOAD

Example challenge solution

INPUT
STORE 10
LOAD 0
LOAD [10]
PRINT
HALT

Actual checker fixtures

Case 1
Input
9
Initial memory
All bytes initially zero
Expected output
9
Expected final memory
10: 9
Required memory reads
10
Case 2
Input
42
Initial memory
All bytes initially zero
Expected output
42
Expected final memory
10: 42
Required memory reads
10
Case 3
Input
127
Initial memory
All bytes initially zero
Expected output
127
Expected final memory
10: 127
Required memory reads
10

3. Explain the machine

Which code reads memory 10, and which loads the number10?

Reasoning and teaching note

LOAD [10] reads the byte; LOAD 10 is literal. STORE and later retrieval preserve the byte beyond R0 overwrite.