Here is the sum n values program, properly annotated:
Cell 5: loop counter: initialized from input
Cell 10: sum: initialized to zero
Cell 11: current value read in from input
Cell 20: Starting address of the program
| Cell | Code | Comment |
|---|---|---|
| 20 | 005 | Read in counter: number of values to sum |
| 21 | 400 | Cells 21-23: zero out sum (cell 10) |
| 22 | 300 | |
| 23 | 510 | |
| 24 | 405 | Cells 24-26: Decrement counter (cell 5) |
| 25 | 300 | |
| 26 | 505 | |
| 27 | 740 | Test if done: counter is negative |
| 28 | 630 | Goto iteration of loop: add in another value |
| 30 | 011 | Read in value to sum (cell 11) |
| 31 | 410 | Put sum into ACC |
| 32 | 211 | Add new value to Sum |
| 33 | 510 | Store off new value of sum (cell 10) |
| 34 | 624 | Go test loop counter |
| 40 | 110 | Output sum (cell 10) |
| 41 | 900 | TTFT |