$\require{cancel}$

8 Bit Computer Programs

These programs run on the 8 bit computer as well as my simulator.

Please note, I will need to clean up the assembly code once I write an assembler.

  • Infinite Loop count up and down, from the videos
    • This is one of Ben's example programs.
    • It counts up by an amount until overflow, then down by the same amount until 0
    • Comments:
      • The numbers are stored at address 15.
      • This is an infinite loop.
      • This is a test of the conditional jumps.
    • Pseudo Assembly
      out
      add 15
      jumpC 4
      jump 0
      sub 15
      out
      jumpz 0
      jump 4
      
      15: 1
      
    • Machine Code:
      0xe0 0x2f 0x74 0x60 0x3f 0xe0 0x80 0x64 0 0 0 0 0 0 0 1
      
    • Expected output: Many values, counting up, then down, then up, then down, .
  • Multiply two numbers, from the videos
    • This is one of Ben's example programs.
    • This will multiply two numbers and store the results.
    • Comments:
      • The numbers are stored at address 13(x*y), 14(x), and 15(y).
      • The constant 1 is stored at 12
      • This is an infinite loop.
    • Pseudo Assembly
      load 14
      subtract 12
      jumpc 6
      load 13
      output
      halt
      store 14
      load 13
      add 15
      store 13
      jump 0
      
      12: 1
      13: 0
      14: 12 
      15: 5
      
    • Machine Code:
      0x1e 0x3c 0x76 0x1d 0xe0 0xf0 0x4e 0x1d 0x2f 0x4d 0x60 0 1 0 12 5 
      
    • The multiples of x up to x*y, x = 12, y = 5 in this case.
  • Fibonacci Sequence, From The Shamblog
    • This is a modified version of Ben's example programs.
    • This will compute the Fibonacci sequence.
    • Comments:
        x = 1
        y = 0
        while no overflow
           x = x + y
           tmp = x + y // just to cause overflow before next computation
                 
    • Pseudo Assembly
      loadI 1
      store 14
      loadI  0
      store 15
      out
      load 14
      add 15
      store 14
      out
      load 15
      add 14
      jumpc 13
      jump 3
      halt
      
    • Machine Code:
      0x51 0x4e 0x50 0x4f 0xe0 0x1e 0x2f 0x4e 0xe0 0x1f 0x2e 0x7d 0x63 0xf0