mirror of
https://github.com/irmen/prog8.git
synced 2025-02-16 22:30:46 +00:00
max 16 subroutine params
This commit is contained in:
parent
3307f673f6
commit
b91aabd3c0
@ -2,9 +2,10 @@
|
|||||||
%import syslib
|
%import syslib
|
||||||
%import textio
|
%import textio
|
||||||
|
|
||||||
; bitmap pixel graphics module for the CommanderX16
|
; Bitmap pixel graphics module for the CommanderX16
|
||||||
; wraps the graphics functions that are in ROM.
|
; wraps the graphics functions that are in ROM.
|
||||||
; only black/white monchrome 320x200 for now.
|
; only black/white monchrome 320x200 for now. (i.e. truncated at the bottom)
|
||||||
|
; For full-screen 640x480 or 320x240 graphics, use the "gfx2" module instead. (but that is Cx16-specific)
|
||||||
|
|
||||||
graphics {
|
graphics {
|
||||||
const uword WIDTH = 320
|
const uword WIDTH = 320
|
||||||
@ -133,5 +134,3 @@ graphics {
|
|||||||
cx16.FB_set_pixel(1)
|
cx16.FB_set_pixel(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,6 +202,9 @@ internal class AstChecker(private val program: Program,
|
|||||||
if(subroutine.name in BuiltinFunctions)
|
if(subroutine.name in BuiltinFunctions)
|
||||||
err("cannot redefine a built-in function")
|
err("cannot redefine a built-in function")
|
||||||
|
|
||||||
|
if(subroutine.parameters.size>16)
|
||||||
|
err("subroutines are limited to 16 parameters")
|
||||||
|
|
||||||
val uniqueNames = subroutine.parameters.asSequence().map { it.name }.toSet()
|
val uniqueNames = subroutine.parameters.asSequence().map { it.name }.toSet()
|
||||||
if(uniqueNames.size!=subroutine.parameters.size)
|
if(uniqueNames.size!=subroutine.parameters.size)
|
||||||
err("parameter names must be unique")
|
err("parameter names must be unique")
|
||||||
|
@ -47,21 +47,19 @@ internal class FunctionCallAsmGen(private val program: Program, private val asmg
|
|||||||
// just a single parameter, no risk of clobbering registers
|
// just a single parameter, no risk of clobbering registers
|
||||||
argumentViaRegister(sub, IndexedValue(0, sub.parameters.single()), stmt.args[0])
|
argumentViaRegister(sub, IndexedValue(0, sub.parameters.single()), stmt.args[0])
|
||||||
} else {
|
} else {
|
||||||
// multiple register arguments, risk of register clobbering.
|
|
||||||
// evaluate arguments onto the stack, and load the registers from the evaluated values on the stack.
|
|
||||||
when {
|
when {
|
||||||
stmt.args.all {it is AddressOf ||
|
stmt.args.all {it is AddressOf ||
|
||||||
it is NumericLiteralValue ||
|
it is NumericLiteralValue ||
|
||||||
it is StringLiteralValue ||
|
it is StringLiteralValue ||
|
||||||
it is ArrayLiteralValue ||
|
it is ArrayLiteralValue ||
|
||||||
it is IdentifierReference} -> {
|
it is IdentifierReference} -> {
|
||||||
// no risk of clobbering for these simple argument types. Optimize the register loading.
|
// There's no risk of clobbering for these simple argument types. Optimize the register loading directly from these values.
|
||||||
for(arg in sub.parameters.withIndex().zip(stmt.args)) {
|
for(arg in sub.parameters.withIndex().zip(stmt.args)) {
|
||||||
argumentViaRegister(sub, arg.first, arg.second)
|
argumentViaRegister(sub, arg.first, arg.second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// Risk of clobbering due to complex expression args. Work via the stack.
|
// Risk of clobbering due to complex expression args. Work via the evaluation stack.
|
||||||
registerArgsViaStackEvaluation(stmt, sub)
|
registerArgsViaStackEvaluation(stmt, sub)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
|
%target cx16
|
||||||
%import textio
|
%import textio
|
||||||
%import graphics
|
%import graphics
|
||||||
%import test_stack
|
%import test_stack
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
|
|
||||||
; TODO full-screen graphics mode library, in development. (as replacement for the graphics routines in ROM that are constrained to 200 vertical pixels and lores mode only)
|
; Bitmap pixel graphics module for the CommanderX16
|
||||||
|
; Custom routines to use the full-screen 640x480 and 320x240 screen modes.
|
||||||
|
; This is only compatible with the Cx16.
|
||||||
|
; For compatible graphics code that words on C64 too, use the "graphics" module instead.
|
||||||
|
|
||||||
|
|
||||||
|
; TODO this is in development.
|
||||||
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
@ -23,12 +23,16 @@ main {
|
|||||||
|
|
||||||
sub start () {
|
sub start () {
|
||||||
txt.chrout('!')
|
txt.chrout('!')
|
||||||
ubyte bank = 1
|
uword bank = 1
|
||||||
uword address = 1000
|
uword address = 1000
|
||||||
ubyte value = 123
|
ubyte value = 123
|
||||||
bank++
|
bank++
|
||||||
vpoke(bank, address, value)
|
|
||||||
vpokeasm(address, bank, value) ; TODO generates params on stack if expression is used such as lsb(bank). CHECK STACK UNWINDING!!!
|
test_stack.test()
|
||||||
|
vpoke(lsb(bank), address, value)
|
||||||
|
test_stack.test()
|
||||||
|
vpokeasm(address, lsb(bank), value) ; TODO generates params on stack if expression is used such as lsb(bank). CHECK STACK UNWINDING!!!
|
||||||
|
test_stack.test()
|
||||||
; TODO also see if we can do this via R0-R15 temp registers rather than using the estack???
|
; TODO also see if we can do this via R0-R15 temp registers rather than using the estack???
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user