identified asm symbol name scoping bugs

This commit is contained in:
Irmen de Jong 2021-06-01 22:21:50 +02:00
parent 9fbe1b38a5
commit e7f6f0950f
3 changed files with 39 additions and 99 deletions

View File

@ -100,9 +100,10 @@ label_in_sub:
assertThat(asmgen.asmSymbolName(varIdent), equalTo("variable")) assertThat(asmgen.asmSymbolName(varIdent), equalTo("variable"))
assertThat(asmgen.asmVariableName(varIdent), equalTo("variable")) assertThat(asmgen.asmVariableName(varIdent), equalTo("variable"))
val scopedVarIdent = IdentifierReference(listOf("scope", "variable"), Position.DUMMY) // TODO also do a scoped reference
assertThat(asmgen.asmSymbolName(scopedVarIdent), equalTo("scope.variable")) // val scopedVarIdent = IdentifierReference(listOf("scope", "variable"), Position.DUMMY)
assertThat(asmgen.asmVariableName(scopedVarIdent), equalTo("scope.variable")) // assertThat(asmgen.asmSymbolName(scopedVarIdent), equalTo("scope.variable"))
// assertThat(asmgen.asmVariableName(scopedVarIdent), equalTo("scope.variable"))
} }
@Test @Test
@ -115,8 +116,9 @@ label_in_sub:
assertThat(asmgen.asmSymbolName(labelIdent), equalTo("_label")) assertThat(asmgen.asmSymbolName(labelIdent), equalTo("_label"))
assertThat(asmgen.asmVariableName(labelIdent), equalTo("_label")) assertThat(asmgen.asmVariableName(labelIdent), equalTo("_label"))
val scopedLabelIdent = IdentifierReference(listOf("scope", "label"), Position.DUMMY) // TODO also do a scoped reference
assertThat(asmgen.asmSymbolName(scopedLabelIdent), equalTo("scope._label")) // val scopedLabelIdent = IdentifierReference(listOf("scope", "label"), Position.DUMMY)
assertThat(asmgen.asmVariableName(scopedLabelIdent), equalTo("scope._label")) // assertThat(asmgen.asmSymbolName(scopedLabelIdent), equalTo("scope._label"))
// assertThat(asmgen.asmVariableName(scopedLabelIdent), equalTo("scope._label"))
} }
} }

View File

@ -2,6 +2,9 @@
TODO TODO
==== ====
- fix asm symbol name scoping bug and complete the unit tests for this
- add or document example for %asminclude and %asmbinary on how to refer to its contents via label or w/e
- test all examples (including imgviewer, assembler and petaxian) before release of the new version - test all examples (including imgviewer, assembler and petaxian) before release of the new version
- simplify cx16.joystick_get2() once this cx16 rom issue is resolved: https://github.com/commanderx16/x16-rom/issues/203 - simplify cx16.joystick_get2() once this cx16 rom issue is resolved: https://github.com/commanderx16/x16-rom/issues/203

View File

@ -1,109 +1,44 @@
%import textio %import textio
%zeropage basicsafe %zeropage basicsafe
; TODO FIX ASM SYMBOL NAME SCOPING BUGS
; TODO make unit tests for this
main { main {
; test program for the optimization of repeat var allocation (asmgen.createRepeatCounterVar) label:
; output must be: 60 6164 6224 12328
uword xx
sub start() { sub start() {
xx=0 sub2(&label)
sub2(&label_local)
repeat 10 { sub2(&main.sub2.label_in_sub2)
xx++ uword xx = &label_local
} txt.print_uwhex(xx, true)
repeat 10 { txt.nl()
xx++ xx = &label
} txt.print_uwhex(xx, true)
repeat 10 { txt.nl()
xx++ xx = &main.label
} txt.print_uwhex(xx, true)
repeat 10 { txt.nl()
xx++ xx = &main.sub2.label_in_sub2
} txt.print_uwhex(xx, true)
repeat 5 { txt.nl()
repeat 4 { xx = main.sub2.sub2var
xx++ txt.print_uwhex(xx, true)
}
}
txt.print_uw(xx)
txt.nl() txt.nl()
repeat 1000 { label_local:
xx++ return
} }
repeat 1000 {
xx++ sub sub2(uword ad) {
} uword sub2var = 42
repeat 1000 {
xx++ txt.print_uwhex(ad,true)
}
repeat 260 {
repeat 4 {
xx++
}
}
repeat 260 {
repeat 260 {
xx++
}
}
txt.print_uw(xx)
txt.nl() txt.nl()
label_in_sub2:
sub2()
if xx!=12328
txt.print("\n!fail!\n")
else
txt.print("\nok\n")
}
sub sub2() {
repeat 10 {
xx++
}
repeat 10 {
xx++
}
repeat 10 {
xx++
}
repeat 10 {
xx++
}
repeat 5 {
repeat 4 {
xx++
}
}
txt.print_uw(xx)
txt.nl()
repeat 1000 {
xx++
}
repeat 1000 {
xx++
}
repeat 1000 {
xx++
}
repeat 260 {
repeat 4 {
xx++
}
}
repeat 260 {
repeat 260 {
xx++
}
}
txt.print_uw(xx)
txt.nl() txt.nl()
} }
} }