SimCom  the Simple Computer

4
After the triangular numbers, the square numbers should be a breeze:
1
4
9
16
25
  1. Put a one in box A
  2. Put a three in box B
  3. Output box A
  4. Add box B to box A
  5. Add one to box B
  6. Add one to box B
  7. Go to step 3
Check.
We can make things easier if we write out the instructions more like the computer ... like this:

 LDA #1
 STA A
 LDA #3
 STA B
LOOP: OUT A
 LDA A
 ADD B
 STA A
 INC B
 INC B
JMP LOOP
This is just what we do on real computers. This sort of language is known as assembler language. Once you have written your program like this, it is much easier to convert it to the numbers that have to go into the machine.

Write the triangular numbers program in assembler and then convert it to numbers. Check.

[Contents] [Previous] [Next] [SimCom] [Help]