Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

According to his latest Tweet, he's planning on going through the code and adding comments. https://twitter.com/billb/status/301403958415618049


There's some nifty tricks that Budge did in the code. Just looking at this, for example:

           LDA (PARAM),Y ;JUMP TO SELECTION
           STA DOMNU6+1
           INY
           LDA (PARAM),Y
           STA DOMNU6+2
    DOMNU6 JMP $FFFF
Instead of creating a 16-bit lookup table and doing an indirect indexed branch (which I can't even remember if you can do on a 6502), Budge just modifies the code inline and lets the jump happen naturally. Very nice.


This is probably the most common way to handle jump tables on the 6502. If you're writing ROMable code you'll have to use indirect jmp (vector) instead of selfmod. It's more efficient to split the jump table into two halves though, with the LSB in one table and the MSB in another, and access it like so:

        lda param_lo,y
        sta vector
        lda param_hi,y
        sta vector+1
  vector = * + 1
        jmp $5e1f      ; dummy address, written with selfmod




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: