Skip to content

Instantly share code, notes, and snippets.

@gnacu
Last active March 9, 2017 21:57
Show Gist options
  • Save gnacu/952a8acbe67e46ec8cd91ea66ec88816 to your computer and use it in GitHub Desktop.
Save gnacu/952a8acbe67e46ec8cd91ea66ec88816 to your computer and use it in GitHub Desktop.
salloc ;Struct Allocate
.block
lda offset
sta ptr ;Set lo addr byte
bne incoff
pha
lda #1 ;Alloc one page
jsr pgalloc
tay ;Page addr -> .Y
lda #0
jsr memset ;Zero the page
sty page
lda rootpg
bne skip
sty rootpg ;Assign root ptr
skip pla
incoff clc
adc #entrysize
sta offset
lda page
sta ptr+1 ;Set hi addr byte
rts
page .byte 0 ;Current struct page.
offset .byte 0 ;Current page offset.
.bend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment