Load r0 7
Load r1 8
Add r2 r0 r1
Store 9 r2
Halt
Challenge:
add 3 numbers, the one stored in memory location 6, 7, and 8.
Store answer in location 9
Branching Example: Add all the numbers between 1 and ???
Put a 1 in location 10 and a 0 in locations 11 and 12.
Location 10 will be the amount you count by
Location 11 will be the total sum
Location 12 will be the next number to add:
LOAD R3 10
LOAD R0 11
LOAD R1 12
ADD R2 R0 R1
STORE 11 R2
ADD R1 R1 R3
STORE 12 R1
BRANCH 1