Student worksheet

Arithmetic and Input

Three lesson sections: predict, build, explain. Work on paper or in the local lab. No name, account or student record is requested by the app.

4. Emoji Math

Combine addition, subtraction, and multiplication as ordered steps.

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 10
ADD 5
PRINT
MUL 2
SUB 4
PRINT
HALT

Queue input: None

Initialize memory: All bytes initially zero

InstructionPC beforePC afterR0 beforeR0 afterRelevant stateOutput
       
       
       

2. Build and check

Read one integer x and print (x + 5) × 2 − 4. Your program must work for every supplied input, including negative numbers.

Required instruction types: INPUT, ADD, MUL, SUB

Starter program

INPUT
# Calculate the expression in R0.
PRINT
HALT

Your program and notes

3. Explain the machine

Why is MUL after ADD necessary for (x+5)×2−4?