subroutine parameters can be allocated on the zp now as well

This commit is contained in:
Irmen de Jong 2020-08-25 16:36:31 +02:00
parent 60a9209a14
commit 4a4f8ff5db
5 changed files with 10 additions and 10 deletions

View File

@ -270,7 +270,7 @@ open class VarDecl(val type: VarDeclType,
// a vardecl used only for subroutine parameters // a vardecl used only for subroutine parameters
class ParameterVarDecl(name: String, declaredDatatype: DataType, position: Position) class ParameterVarDecl(name: String, declaredDatatype: DataType, position: Position)
: VarDecl(VarDeclType.VAR, declaredDatatype, ZeropageWish.NOT_IN_ZEROPAGE, null, name, null, null, false, true, position) : VarDecl(VarDeclType.VAR, declaredDatatype, ZeropageWish.DONTCARE, null, name, null, null, false, true, position)
class ArrayIndex(var index: Expression, override val position: Position) : Node { class ArrayIndex(var index: Expression, override val position: Position) : Node {

View File

@ -247,7 +247,6 @@ internal class AsmGen(private val program: Program,
out("; vars allocated on zeropage") out("; vars allocated on zeropage")
val variables = statements.filterIsInstance<VarDecl>().filter { it.type==VarDeclType.VAR } val variables = statements.filterIsInstance<VarDecl>().filter { it.type==VarDeclType.VAR }
for(variable in variables) { for(variable in variables) {
// should NOT allocate subroutine parameters on the zero page
val fullName = variable.makeScopedName(variable.name) val fullName = variable.makeScopedName(variable.name)
val zpVar = allocatedZeropageVariables[fullName] val zpVar = allocatedZeropageVariables[fullName]
if(zpVar==null) { if(zpVar==null) {

View File

@ -2,7 +2,6 @@
TODO TODO
==== ====
- allocate sub params in zeropage as well (it already allows @zp tag on them!)
- optimize assignment codegeneration - optimize assignment codegeneration
- get rid of all TODO's ;-) - get rid of all TODO's ;-)
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_' - make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_'

View File

@ -71,10 +71,9 @@ main {
} }
c2A += 2 c2A += 2
c2B -= 3 c2B -= 3
uword @zp scrptr = screen
for y in 24 downto 0 { for y in 24 downto 0 {
for x in 39 downto 0 { for x in 39 downto 0 {
@(scrptr) = xbuf[x] + ybuf[y] @(screen) = xbuf[x] + ybuf[y]
; %asm {{ ; %asm {{
; ldy x ; ldy x
; lda xbuf,y ; lda xbuf,y
@ -82,9 +81,9 @@ main {
; clc ; clc
; adc ybuf,y ; adc ybuf,y
; ldy #0 ; ldy #0
; sta (scrptr),y ; sta (screen),y
; }} ; }}
scrptr++ screen++
} }
} }
} }

View File

@ -4,9 +4,12 @@
main { main {
sub start() { sub start() {
uword addr=$d020
ubyte q =2 subje(12345)
@(addr) += q }
sub subje(uword xx) {
@($c000) = lsb(xx)
} }
} }