warnings, errors and todos

This commit is contained in:
Irmen de Jong 2020-12-01 03:03:50 +01:00
parent 8b981f03bf
commit 63483d1f0e
7 changed files with 171 additions and 12 deletions

View File

@ -211,6 +211,10 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
// Everything else just evaluate via the stack.
// (we can't use the assignment helper functions to do it via registers here,
// because the code here is the implementation of exactly that...)
if(value.parent is Return) {
if (this.asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used for return: $value target=${assign.target.kind} at ${value.position}")
}
asmgen.translateExpression(value)
if(assign.target.datatype in WordDatatypes && assign.source.datatype in ByteDatatypes)
asmgen.signExtendStackLsb(assign.source.datatype)

View File

@ -2,7 +2,8 @@
TODO
====
- check the various math routines that are marked TODO in prog8_lib.asm for correctness...
- fix errors in arith examples
- see if we can group some errors together for instance the (now single) errors about unidentified symbols
- Cx16 target: support full-screen 640x480 and 320x240 graphics? That requires our own custom graphics routines though to draw lines.
- make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_'

View File

@ -21,8 +21,8 @@ main {
div_word(-20000,500,-40)
div_word(-2222,2,-1111)
div_float(0,1,0)
div_float(999.9,111.0,9.008108108108107)
div_float(0,1,0) ; TODO FIX ERROR
div_float(999.9,111.0,9.008108108108107) ; TODO FIX ERROR
}
sub div_ubyte(ubyte a1, ubyte a2, ubyte c) {

View File

@ -1,5 +1,6 @@
%import floats
%import textio
%import test_stack
%zeropage basicsafe
main {
@ -28,9 +29,11 @@ main {
minus_word(0,-3333,3333)
minus_word(-3333,0,-3333)
minus_float(0,0,0)
minus_float(2.5,1.5,1.0)
minus_float(-1.5,3.5,-5.0)
minus_float(0,0,0) ; TODO FIX ERROR
minus_float(2.5,1.5,1.0) ; TODO FIX ERROR
minus_float(-1.5,3.5,-5.0) ; TODO FIX ERROR
test_stack.test()
}
sub minus_ubyte(ubyte a1, ubyte a2, ubyte c) {
@ -95,12 +98,13 @@ main {
sub minus_float(float a1, float a2, float c) {
float r = a1-a2
if abs(r-c)<0.00001
if abs(r-c)<0.00001 ; TODO FIX COMPARISON (it works when only comparing a var)
txt.print(" ok ")
else
else {
txt.print("err! ")
}
txt.print("float ")
txt.print(" float ")
floats.print_f(a1)
txt.print(" - ")
floats.print_f(a2)

View File

@ -22,9 +22,9 @@ main {
mul_word(-10,1000,-10000)
mul_word(1,-3333,-3333)
mul_float(0,0,0)
mul_float(2.5,10,25)
mul_float(-1.5,10,-15)
mul_float(0,0,0) ; TODO FIX ERROR
mul_float(2.5,10,25) ; TODO FIX ERROR
mul_float(-1.5,10,-15) ; TODO FIX ERROR
}
sub mul_ubyte(ubyte a1, ubyte a2, ubyte c) {

View File

@ -25,6 +25,7 @@ main {
plus_word(0,-3333,-3333)
plus_word(-3333,0,-3333)
; TODO FIX ERRORs in float
plus_float(0,0,0)
plus_float(1.5,2.5,4.0)
plus_float(-1.5,3.5,2.0)

View File

@ -6,5 +6,154 @@
main {
sub start() {
uword uw
uword xx
word ww
word yy
uw = shiftruw7()
xx+=uw
uw = shiftruw8()
xx+=uw
uw = shiftruw9()
xx+=uw
uw = shiftruw10()
xx+=uw
uw = shiftruw11()
xx+=uw
uw = shiftruw12()
xx+=uw
uw = shiftruw13()
xx+=uw
uw = shiftruw14()
xx+=uw
uw = shiftruw15()
xx+=uw
ww = shiftrsw7()
yy+=ww
ww = shiftrsw8()
yy+=ww
ww = shiftrsw9()
yy+=ww
ww = shiftrsw10()
yy+=ww
ww = shiftrsw11()
yy+=ww
ww = shiftrsw12()
yy+=ww
ww = shiftrsw13()
yy+=ww
ww = shiftrsw14()
yy+=ww
ww = shiftrsw15()
yy+=ww
ww = shiftrsw16() ; TODO why sub not replaced by const?
yy+=ww
ww = shiftrsw17() ; TODO why sub not replaced by const?
yy+=ww
}
sub shiftruw7() -> uword {
uword q = $a49f
return q >> 7
}
sub shiftruw8() -> uword {
uword q = $a49f
return (q >> 8) ; TODO fix slow? (and for all below)
}
sub shiftruw9() -> uword {
uword q = $a49f
return (q >> 9)
}
sub shiftruw10() -> uword {
uword q = $a49f
return (q >> 10)
}
sub shiftruw11() -> uword {
uword q = $a49f
return (q >> 11)
}
sub shiftruw12() -> uword {
uword q = $a49f
return (q >> 12)
}
sub shiftruw13() -> uword {
uword q = $a49f
return (q >> 13)
}
sub shiftruw14() -> uword {
uword q = $a49f
return (q >> 14)
}
sub shiftruw15() -> uword {
uword q = $a49f
return (q >> 15)
}
sub shiftrsw7() -> word {
word q = -12345
return q >> 7
}
sub shiftrsw8() -> word {
word q = -12345
return (q >> 8) ; TODO why not marked slow? What code is generated? Also for all below.
}
sub shiftrsw9() -> word {
word q = -12345
return (q >> 9)
}
sub shiftrsw10() -> word {
word q = -12345
return (q >> 10)
}
sub shiftrsw11() -> word {
word q = -12345
return (q >> 11)
}
sub shiftrsw12() -> word {
word q = -12345
return (q >> 12)
}
sub shiftrsw13() -> word {
word q = -12345
return (q >> 13)
}
sub shiftrsw14() -> word {
word q = -12345
return (q >> 14)
}
sub shiftrsw15() -> word {
word q = -12345
return (q >> 15)
}
sub shiftrsw16() -> word {
word q = -12345
return (q >> 16)
}
sub shiftrsw17() -> word {
word q = -12345
return (q >> 17)
}
}