It's Alive!

Posted on Tue 08 October 2024 in MUPS16

It's alive! I got the first successful run of the whole system today, booting into a simple test program that just displays a Knight Rider-like pattern on the S1 register LEDs. The only component that's not on a PCB now is the clock (which I haven't documented yet), which is still running my breadboard version while I wait for a new combined reset/clock board to arrive. The control boards are also in their temporary plug-in card form that allows for quicker iteration, but they're functionally complete.

The code is simple: the standard boilerplate for setting up a minimal page table for the user process (so that it can use the stack), then nested loops for animating the value in S1:

.loop_left:
   mts     s1, r1          ; display current frame
   slli    r1, r1, 1       ; shift frame left
   srli    r2, r2, 1       ; shift remaining bit right
   jal     .delay
   bnz     r2, .loop_left

   liw     r2, 0x4000      ; r2 starts with 0100 0000 0000 0000

.loop_right:
   mts     s1, r1          ; display current frame
   srli    r1, r1, 1       ; shift frame right
   srli    r2, r2, 1       ; shift remaining bit right
   jal     .delay
   bnz     r2, .loop_right

   j       .loop_kr        ; done, start again

.delay:
   sw      [0]sp, r1       ; save r1
   sw      [-2]sp, r2      ; save r2
   mov     r1, r0
   mov     r2, r0
   liw     r3, 512         ; at 3 cycles per instruction, two instructions in the tight
                           ; loop below, this will give us a delay of 3000 cycles

There are some instabilities here which I'll have to dig into, but for now I'm very happy to see something running at last.