mirror of
https://github.com/irmen/prog8.git
synced 2024-11-25 19:31:36 +00:00
identified asm symbol name scoping bugs
This commit is contained in:
parent
9fbe1b38a5
commit
e7f6f0950f
@ -100,9 +100,10 @@ label_in_sub:
|
||||
assertThat(asmgen.asmSymbolName(varIdent), equalTo("variable"))
|
||||
assertThat(asmgen.asmVariableName(varIdent), equalTo("variable"))
|
||||
|
||||
val scopedVarIdent = IdentifierReference(listOf("scope", "variable"), Position.DUMMY)
|
||||
assertThat(asmgen.asmSymbolName(scopedVarIdent), equalTo("scope.variable"))
|
||||
assertThat(asmgen.asmVariableName(scopedVarIdent), equalTo("scope.variable"))
|
||||
// TODO also do a scoped reference
|
||||
// val scopedVarIdent = IdentifierReference(listOf("scope", "variable"), Position.DUMMY)
|
||||
// assertThat(asmgen.asmSymbolName(scopedVarIdent), equalTo("scope.variable"))
|
||||
// assertThat(asmgen.asmVariableName(scopedVarIdent), equalTo("scope.variable"))
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -115,8 +116,9 @@ label_in_sub:
|
||||
assertThat(asmgen.asmSymbolName(labelIdent), equalTo("_label"))
|
||||
assertThat(asmgen.asmVariableName(labelIdent), equalTo("_label"))
|
||||
|
||||
val scopedLabelIdent = IdentifierReference(listOf("scope", "label"), Position.DUMMY)
|
||||
assertThat(asmgen.asmSymbolName(scopedLabelIdent), equalTo("scope._label"))
|
||||
assertThat(asmgen.asmVariableName(scopedLabelIdent), equalTo("scope._label"))
|
||||
// TODO also do a scoped reference
|
||||
// val scopedLabelIdent = IdentifierReference(listOf("scope", "label"), Position.DUMMY)
|
||||
// assertThat(asmgen.asmSymbolName(scopedLabelIdent), equalTo("scope._label"))
|
||||
// assertThat(asmgen.asmVariableName(scopedLabelIdent), equalTo("scope._label"))
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,9 @@
|
||||
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
|
||||
|
||||
- simplify cx16.joystick_get2() once this cx16 rom issue is resolved: https://github.com/commanderx16/x16-rom/issues/203
|
||||
|
121
examples/test.p8
121
examples/test.p8
@ -1,109 +1,44 @@
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
|
||||
; TODO FIX ASM SYMBOL NAME SCOPING BUGS
|
||||
; TODO make unit tests for this
|
||||
|
||||
|
||||
main {
|
||||
|
||||
; test program for the optimization of repeat var allocation (asmgen.createRepeatCounterVar)
|
||||
; output must be: 60 6164 6224 12328
|
||||
|
||||
uword xx
|
||||
|
||||
label:
|
||||
sub start() {
|
||||
|
||||
xx=0
|
||||
|
||||
repeat 10 {
|
||||
xx++
|
||||
}
|
||||
repeat 10 {
|
||||
xx++
|
||||
}
|
||||
repeat 10 {
|
||||
xx++
|
||||
}
|
||||
repeat 10 {
|
||||
xx++
|
||||
}
|
||||
repeat 5 {
|
||||
repeat 4 {
|
||||
xx++
|
||||
}
|
||||
}
|
||||
txt.print_uw(xx)
|
||||
sub2(&label)
|
||||
sub2(&label_local)
|
||||
sub2(&main.sub2.label_in_sub2)
|
||||
uword xx = &label_local
|
||||
txt.print_uwhex(xx, true)
|
||||
txt.nl()
|
||||
xx = &label
|
||||
txt.print_uwhex(xx, true)
|
||||
txt.nl()
|
||||
xx = &main.label
|
||||
txt.print_uwhex(xx, true)
|
||||
txt.nl()
|
||||
xx = &main.sub2.label_in_sub2
|
||||
txt.print_uwhex(xx, true)
|
||||
txt.nl()
|
||||
xx = main.sub2.sub2var
|
||||
txt.print_uwhex(xx, true)
|
||||
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()
|
||||
|
||||
sub2()
|
||||
|
||||
if xx!=12328
|
||||
txt.print("\n!fail!\n")
|
||||
else
|
||||
txt.print("\nok\n")
|
||||
label_local:
|
||||
return
|
||||
}
|
||||
|
||||
sub sub2() {
|
||||
sub sub2(uword ad) {
|
||||
uword sub2var = 42
|
||||
|
||||
repeat 10 {
|
||||
xx++
|
||||
}
|
||||
repeat 10 {
|
||||
xx++
|
||||
}
|
||||
repeat 10 {
|
||||
xx++
|
||||
}
|
||||
repeat 10 {
|
||||
xx++
|
||||
}
|
||||
repeat 5 {
|
||||
repeat 4 {
|
||||
xx++
|
||||
}
|
||||
}
|
||||
txt.print_uw(xx)
|
||||
txt.print_uwhex(ad,true)
|
||||
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)
|
||||
label_in_sub2:
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user