mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-09-29 03:56:15 +00:00
63 lines
1.1 KiB
NASM
63 lines
1.1 KiB
NASM
// Tests creating, assigning returning and calling pointers to non-args no-return functions
|
|
// Commodore 64 PRG executable file
|
|
.file [name="function-pointer-noarg-call-3.prg", type="prg", segments="Program"]
|
|
.segmentdef Program [segments="Basic, Code, Data"]
|
|
.segmentdef Basic [start=$0801]
|
|
.segmentdef Code [start=$80d]
|
|
.segmentdef Data [startAfter="Code"]
|
|
.segment Basic
|
|
:BasicUpstart(main)
|
|
.segment Code
|
|
fn2: {
|
|
.label BG_COLOR = $d021
|
|
// (*BG_COLOR)++;
|
|
inc BG_COLOR
|
|
// }
|
|
rts
|
|
}
|
|
fn1: {
|
|
.label BORDER_COLOR = $d020
|
|
// (*BORDER_COLOR)++;
|
|
inc BORDER_COLOR
|
|
// }
|
|
rts
|
|
}
|
|
main: {
|
|
.label __0 = 3
|
|
.label i = 2
|
|
lda #0
|
|
sta.z i
|
|
__b2:
|
|
// (*getfn(++i))();
|
|
inc.z i
|
|
// getfn(++i)
|
|
lda.z i
|
|
jsr getfn
|
|
// (*getfn(++i))()
|
|
jsr bi___0
|
|
jmp __b2
|
|
bi___0:
|
|
jmp (__0)
|
|
}
|
|
// getfn(byte register(A) b)
|
|
getfn: {
|
|
.label return = 3
|
|
// b&1
|
|
and #1
|
|
// if((b&1)==0)
|
|
cmp #0
|
|
beq __b1
|
|
lda #<fn2
|
|
sta.z return
|
|
lda #>fn2
|
|
sta.z return+1
|
|
rts
|
|
__b1:
|
|
lda #<fn1
|
|
sta.z return
|
|
lda #>fn1
|
|
sta.z return+1
|
|
// }
|
|
rts
|
|
}
|