Fibonnaci checks out

A project log for GTXL Gigatron clone computer with keyboard

Microcomputer that runs without a CPU

justin-davisJustin Davis 08/15/2019 at 12:213 Comments

Well, I should have expected the Fibonacci code to work since I already checked out all the previous functions of it.  So I'm wondering what isn't going to be working to prevent the ROM code from working.  I'm running the ROM v3 code because I'm worried about the ROM v4 code is incompatible.  I noticed the new bus expansion board uses the same instruction set hack that I used - it uses the same invalid memory instructions to talk to the expansion board as I use to talk to my control registers.  The v3 does not use these instructions, so it should run ok.

So I'm starting to really scratch my head on what the problem could be here.  I'm starting to think it may be a clock problem - all the code that runs slowly works correctly.  So next I may try to slowly run the rom code and see if it works.  All I really need to see is the 4 LEDs turn on one at a time to show the board has booted.  I need to modify my Arduino flash loader to read the ROM file and dump the whole thing into the flash cartridge.

  // Fibonacci series
  // $[00] = a
  // $[01] = b
  // $[02] = tmp
  byteProgram(0x0000, 0x0000);  // ld   $00    ; outer loop
  byteProgram(0x0001, 0xc200);  // st   [$00]  ; a=0
  byteProgram(0x0002, 0x0001);  // ld   $01    ; b=1
  byteProgram(0x0003, 0xfc0a);  // bra  $0a
  byteProgram(0x0004, 0x0200);  // nop         ; (pipelining)
// inner loop start
  byteProgram(0x0005, 0x0100);  // ld   [$00] 
  byteProgram(0x0006, 0xc202);  // st   [$02]  ; tmp=a
  byteProgram(0x0007, 0x0101);  // ld   [$01]
  byteProgram(0x0008, 0xc200);  // st   [$00]  ; a=b
  byteProgram(0x0009, 0x8102);  // adda [$02]
  byteProgram(0x000a, 0xc201);  // st   [$01]  ; b+=tmp
  byteProgram(0x000b, 0x1800);  // ld 0x00, OUT  ; Prepare XOUT update, hSync goes down, RGB to black
  byteProgram(0x000c, 0x1840);  // ld 0x40, OUT  ; hSync goes up (bit 6), updating XOUT and blinkenlights 

  byteProgram(0x000d, 0xf405);  // bge  $05    ; repeat if bit7 is still 0
  byteProgram(0x000e, 0x0200);  // nop         ; (pipelining)
// inner loop end

  byteProgram(0x000f, 0xfc00);  // bra  $00    ; start over again
  byteProgram(0x0010, 0x0200);  // nop         ; (pipelining)

  // output:
  //0   0000 0000
  //1   0000 0001
  //1   0000 0001
  //2   0000 0010
  //3   0000 0011
  //5   0000 0101
  //8   0000 1000
  //13  0000 1101
  //21  0001 0101
  //34  0010 0010
  //55  0011 0111
  //89  0101 1001
  //144 1001 0000


Marcel van Kervinck wrote 08/15/2019 at 21:55 point

The special instructions that run in ROMv4 (we gave them the 'ctrl' mnemonic) are only in the first few cycles. In fact, it's exactly 1, unless you try to call the SPI functions, which none of the built-in applications do. This single instruction intends to disable the SPI slaves. It's this one:

              |    encoding
              |    |     instruction
              |    |     |    operands
              |    |     |    |
              V    V     V    V
              0003 c17c  ctrl $7c         ;SCLK=0; Disable SPI slaves; Bank=1; Enable RAM

I can't tell if this is harmful or harmless on your board. Its also easy to patch out with a nop.

  Are you sure? yes | no

Justin Davis wrote 08/16/2019 at 15:58 point

Let's see.  This will do two things - it will load ac into [0,$dd] which will be [007c].  Since 0x007c is a user variable, then it's not an issue.  It will also load ac into my CTRL register.  My CTRL does several things - it muxes the input bus with several different inputs (external game controller, keyboard, audio input, expansion bus), it selects the RAM bank, and selects the "hi-res" VGA mode.  Looking at the code, the AC register should contain 0x00.  This is great because that register should be initialized to 0x00 anyway. So looks like there's no issue right now.

Once I get this up and running, I may try to figure out some code which auto-detects which hardware the code is running on to turn on/off functions.

  Are you sure? yes | no

Marcel van Kervinck wrote 08/16/2019 at 19:28 point

Indeed AC will be 0. This instruction also enables the RAM, so its place in the boot sequence is more or less a given.

  Are you sure? yes | no