mirror of
https://github.com/irmen/prog8.git
synced 2024-11-27 03:50:27 +00:00
allow address-of to be used as a value for a memory pointer variable
This commit is contained in:
parent
9b66a597bb
commit
def06dbc0b
@ -584,13 +584,15 @@ internal class AstChecker(private val program: Program,
|
||||
}
|
||||
}
|
||||
|
||||
if(decl.value !is NumericLiteralValue) {
|
||||
err("value of memory var decl is not a numeric literal (it is a ${decl.value!!.javaClass.simpleName}).", decl.value?.position)
|
||||
} else {
|
||||
if(decl.value is NumericLiteralValue) {
|
||||
val value = decl.value as NumericLiteralValue
|
||||
if (value.type !in IntegerDatatypes || value.number.toInt() < 0 || value.number.toInt() > 65535) {
|
||||
err("memory address must be valid integer 0..\$ffff", decl.value?.position)
|
||||
}
|
||||
} else if(decl.value is AddressOf) {
|
||||
// we allow this too: the address of another variable
|
||||
} else {
|
||||
err("value of memory var decl is invalid type.", decl.value?.position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -355,7 +355,10 @@ internal class AsmGen(private val program: Program,
|
||||
out("\n; memdefs and kernel subroutines")
|
||||
val memvars = statements.filterIsInstance<VarDecl>().filter { it.type==VarDeclType.MEMORY || it.type==VarDeclType.CONST }
|
||||
for(m in memvars) {
|
||||
out(" ${m.name} = ${(m.value as NumericLiteralValue).number.toHex()}")
|
||||
if(m.value is NumericLiteralValue)
|
||||
out(" ${m.name} = ${(m.value as NumericLiteralValue).number.toHex()}")
|
||||
else
|
||||
out(" ${m.name} = ${asmVariableName((m.value as AddressOf).identifier)}")
|
||||
}
|
||||
val asmSubs = statements.filterIsInstance<Subroutine>().filter { it.isAsmSubroutine }
|
||||
for(sub in asmSubs) {
|
||||
|
Loading…
Reference in New Issue
Block a user