1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00
kickc/src/test/ref/malloc-0.asm

30 lines
634 B
NASM

// Experiments with malloc() - a byte array
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
// Top of the heap used by malloc()
.label HEAP_TOP = $a000
.label BYTES = malloc.return
bbegin:
jsr malloc
jsr main
rts
main: {
ldx #0
b1:
txa
sta BYTES,x
inx
cpx #0
bne b1
rts
}
// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
malloc: {
.const size = $100
.label mem = HEAP_TOP-size
.label return = mem
rts
}