Close

ALU is go

A project log for GTXL Gigatron clone computer with keyboard

Microcomputer that runs without a CPU

Justin DavisJustin Davis 08/06/2019 at 20:160 Comments

Finished the next check-out program and the ALU is working.  It isn't an extensive checkout - just enough to make sure my control logic is good.  I also put together a quick clock program on my Arduino to toggle the clock at about half a second.  So the lights changed slowly enough for me to verify the outputs were good.  I also checked the branch-if-equal-to-zero command.   I have to admit I kinda like writing machine-code.  At least for small test programs.  Next up will probably be writing and reading the RAM.  There's several different ways to access the memory and I did a lot of modifications to the MAU.  I wouldn't be surprised if there are problems here.

  // Program to test ADD, SUB, AND, OR, XOR functions of ALU
  byteProgram(0x0000, 0x000F);  // ld (0b1111, AC)      // value to load into blinkenlights LEDs |****|
  byteProgram(0x0001, 0x1800);  // ld (0x00, OUT)       // Prepare XOUT update, hSync goes down, RGB to black
  byteProgram(0x0002, 0x1840);  // ld (0b01000000, OUT) // hSync goes up (bit 6), updating XOUT and blinkenlights

  // top of loop:
  byteProgram(0x0003, 0xF00A);  // beq (0x0A)           // branch if equal to zero to exit loop
  byteProgram(0x0004, 0x0200);  // nop                  // nop for pipelining simplification
  byteProgram(0x0005, 0xA001);  // sub (0x01, AC)       // sub 1 from AC register
  byteProgram(0x0006, 0x1800);  // ld (0x00, OUT)       // Prepare XOUT update, hSync goes down, RGB to black
  byteProgram(0x0007, 0x1840);  // ld (0b01000000, OUT) // hSync goes up (bit 6), updating XOUT and blinkenlights
  byteProgram(0x0008, 0xFC03);  // bra (0x03)           // unconditional branch back to top of loop
  byteProgram(0x0009, 0x0200);  // nop                  // nop for pipelining simplification
  
  // exit loop:
  byteProgram(0x000A, 0x4005);  // or (0x05, AC)        // test OR function (expect 0x05 result) |*0*0|
  byteProgram(0x000B, 0x1800);  // ld (0x00, OUT)       // Prepare XOUT update, hSync goes down, RGB to black
  byteProgram(0x000C, 0x1840);  // ld (0b01000000, OUT) // hSync goes up (bit 6), updating XOUT and blinkenlights
  
  byteProgram(0x000D, 0x600F);  // xor (0x0F, AC)       // test XOR function (expect 0x0A result) |0*0*|
  byteProgram(0x000E, 0x1800);  // ld (0x00, OUT)       // Prepare XOUT update, hSync goes down, RGB to black
  byteProgram(0x000F, 0x1840);  // ld (0b01000000, OUT) // hSync goes up (bit 6), updating XOUT and blinkenlights
  
  byteProgram(0x0010, 0x200C);  // and (0x0C, AC)       // test AND function (expect 0x08 result) |000*|
  byteProgram(0x0011, 0x1800);  // ld (0x00, OUT)       // Prepare XOUT update, hSync goes down, RGB to black
  byteProgram(0x0012, 0x1840);  // ld (0b01000000, OUT) // hSync goes up (bit 6), updating XOUT and blinkenlights
  
  byteProgram(0x0013, 0x8001);  // add (0x01, AC)       // test ADD function (expect 0x09 result)  |*00*|
  byteProgram(0x0014, 0x1800);  // ld (0x00, OUT)       // Prepare XOUT update, hSync goes down, RGB to black
  byteProgram(0x0015, 0x1840);  // ld (0b01000000, OUT) // hSync goes up (bit 6), updating XOUT and blinkenlights
  
  byteProgram(0x0016, 0x80FD);  // add (0xFD, AC)       // test ADD function (expect 0x06 result, should rollover) |0**0|
  byteProgram(0x0017, 0x1800);  // ld (0x00, OUT)       // Prepare XOUT update, hSync goes down, RGB to black
  byteProgram(0x0018, 0x1840);  // ld (0b01000000, OUT) // hSync goes up (bit 6), updating XOUT and blinkenlights
  
  byteProgram(0x0019, 0xFC00);  // bra (0x00)           // unconditional branch back to 0
  byteProgram(0x001A, 0x0200);  // nop                  // nop for pipelining simplification

Discussions