Show HN: 1.5kb Microkernel for Ben Eater's 6502 Computer
Skimming through this, this is the first piece of code that my eyes drilled into more deeply:<p><pre><code>  LCD__clear_video_ram:
    pha                                         ; preserve A via stack
    tya                                         ; same for Y
    pha
    ldy #$20                                    ; set index to 32
  .loop:
    lda #$20                                    ; set character to 'space'
    sta VIDEO_RAM,Y                             ; clean video ram
    dey                                         ; decrease index
    bne .loop                                   ; are we   done? no, repea
    sta VIDEO_RAM                               ; yes, write zero'th location manually
    pla                                         ; restore Y
    tay
    pla                                         ; restore A
    rts
</code></pre>
Surely we don't need to keep loading the space character into A on every iteration?<p>Since Y starts at a hard-coded value that is (well) below $80, this could use "bpl .loop" and drop the "sta VIDEO_RAM" special case.<p>In .select_option, I'd looking into doing a jump table. Ideas here: <a href="https://wiki.nesdev.com/w/index.php/Jump_table" rel="nofollow">https://wiki.nesdev.com/w/index.php/Jump_table</a>