mirror of
https://github.com/irmen/prog8.git
synced 2025-01-12 19:29:50 +00:00
subroutine parameters can be allocated on the zp now as well
This commit is contained in:
parent
60a9209a14
commit
4a4f8ff5db
@ -270,7 +270,7 @@ open class VarDecl(val type: VarDeclType,
|
||||
|
||||
// a vardecl used only for subroutine parameters
|
||||
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 {
|
||||
|
@ -247,7 +247,6 @@ internal class AsmGen(private val program: Program,
|
||||
out("; vars allocated on zeropage")
|
||||
val variables = statements.filterIsInstance<VarDecl>().filter { it.type==VarDeclType.VAR }
|
||||
for(variable in variables) {
|
||||
// should NOT allocate subroutine parameters on the zero page
|
||||
val fullName = variable.makeScopedName(variable.name)
|
||||
val zpVar = allocatedZeropageVariables[fullName]
|
||||
if(zpVar==null) {
|
||||
|
@ -2,7 +2,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- allocate sub params in zeropage as well (it already allows @zp tag on them!)
|
||||
- optimize assignment codegeneration
|
||||
- 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 '_'
|
||||
|
@ -71,10 +71,9 @@ main {
|
||||
}
|
||||
c2A += 2
|
||||
c2B -= 3
|
||||
uword @zp scrptr = screen
|
||||
for y in 24 downto 0 {
|
||||
for x in 39 downto 0 {
|
||||
@(scrptr) = xbuf[x] + ybuf[y]
|
||||
@(screen) = xbuf[x] + ybuf[y]
|
||||
; %asm {{
|
||||
; ldy x
|
||||
; lda xbuf,y
|
||||
@ -82,9 +81,9 @@ main {
|
||||
; clc
|
||||
; adc ybuf,y
|
||||
; ldy #0
|
||||
; sta (scrptr),y
|
||||
; sta (screen),y
|
||||
; }}
|
||||
scrptr++
|
||||
screen++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,12 @@
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
uword addr=$d020
|
||||
ubyte q =2
|
||||
@(addr) += q
|
||||
|
||||
subje(12345)
|
||||
}
|
||||
|
||||
sub subje(uword xx) {
|
||||
@($c000) = lsb(xx)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user