chitselb / pettil

6502 Forth-83 dialect for the Commodore PET 2001
http://pettil.tumblr.com
34 stars 3 forks source link

Code sharing for C@+ and @+ ? #87

Open barrym95838 opened 3 years ago

barrym95838 commented 3 years ago

This suggestion shaves four bytes and makes @+ faster, but adds seven ticks to your C@+ ... worth it?

#if 0
name=C@+
stack=( addr -- addr+1 c )
tags=nucleus,memory,primitive
Fetches the byte at addr, increments addr

!!!pronounced: "c-fetch-plus"
#endif
cfetchplus
    clc
    .byt $29                    ; AND #
    ;fall through

;--------------------------------------------------------------
#if 0
name=@+
stack=( addr -- addr+2 w )
tags=nucleus,memory,primitive
Fetches word `w` at `addr`, increments addr by 2

!!!pronounced: "fetch-plus"
#endif
fetchplus
    sec
    ldy #0
fetchplus01
    lda (tos),y
    jsr inctos
    bcc fetchplus02
    pha
    lda (tos),y
    jsr inctos
    tay
    pla
fetchplus02
    jmp pushya