Irmen de Jong
7b54aa0c7d
more consistent naming of the statement classes
2021-12-28 13:56:47 +01:00
Irmen de Jong
6e11b8ada1
GoSub no longer inherits from Jump node, fixes subtle ast/codegen bugs related to jsrs
2021-12-28 01:55:13 +01:00
Irmen de Jong
1c7c4fc3b0
optimized if-goto codegeneration
2021-12-28 00:42:00 +01:00
Irmen de Jong
97e84d0977
tweak if statement handling
2021-12-27 15:04:25 +01:00
Irmen de Jong
9906b58818
tweak while desugaring, moved postfixexpr optimizations to VariousCleanups regardless of optimizer setting because asmgen requires these for conditional expressions
2021-12-27 12:41:26 +01:00
Irmen de Jong
1c10839c14
moved peek/poke desugaring to other walker
2021-12-27 02:08:47 +01:00
Irmen de Jong
c55fdd9834
removed special code generation for while and util expression (replaced by jumps)
...
also added exhaustive parent node checker in validation step
2021-12-27 02:04:28 +01:00
Irmen de Jong
67b0890a6e
remove unneeded var inits when an assignment is already present
2021-12-25 23:31:25 +01:00
Irmen de Jong
4da4f96669
lower code: break -> goto after (simplifies codegen)
2021-12-25 22:30:38 +01:00
Irmen de Jong
d4153da8b9
setup float routine addresses for c128
2021-12-25 02:34:52 +01:00
Irmen de Jong
fc33ab8905
shuffled some system functions back to c64 block to remain compatible with existing code, added missing float and graphics library stubs
2021-12-24 00:08:32 +01:00
Irmen de Jong
8fa84de28e
fix c128 clearscreen and bdmusic sound issue
2021-12-22 22:59:36 +01:00
Irmen de Jong
3e3da38de1
correctly disable charset switching
2021-12-22 21:47:41 +01:00
Irmen de Jong
cabf1e82e8
some shadow registers added to make uppercase()/lowercase() work
2021-12-22 21:20:34 +01:00
Irmen de Jong
836d40072f
c128 evalstack corrections
2021-12-22 00:07:05 +01:00
Irmen de Jong
431401d90e
c128 corrections
2021-12-21 23:37:15 +01:00
Irmen de Jong
6da83e2bd7
first steps to add C128 compiler target
2021-12-21 19:08:33 +01:00
Irmen de Jong
e051e09c1d
trim down number of warnings a bit
2021-12-17 20:21:14 +01:00
Irmen de Jong
77c2b2b326
fix position of @shared in array var declarations so that the order is now type[] @shared
2021-12-16 20:36:05 +01:00
Irmen de Jong
3cf9b9d9a5
code size optimization: subroutine calls with 2 byte arg will pass it via A/Y registers instead of separate param assignments at every call site
2021-12-16 01:48:22 +01:00
Irmen de Jong
629117e594
code size optimization: subroutine calls with 1 int arg will pass it via register instead of separate param assignment at every call site
2021-12-16 00:56:59 +01:00
Irmen de Jong
08f87c321f
fixed capitalization of operator sets to be consistent with other sets names
2021-12-15 23:43:14 +01:00
Irmen de Jong
1ff13723fe
implicit int to float conversion is now an error if floats are not enabled.
2021-12-15 01:52:28 +01:00
Irmen de Jong
510bda1b28
fix compiler crash when using floats in a comparison expression
2021-12-15 01:24:25 +01:00
Irmen de Jong
890327b381
the returnvalue of the diskio.load() function family now is just the last load address+1 (like kernal's LOAD routine).
...
This fixes the inconsistent attempt to calculate a size, just let the caller do this if required.
Added a small helper function in cx16diskio to do this for loads that span multiple banks.
2021-12-14 23:54:42 +01:00
Irmen de Jong
b21f7411dd
fix compiler crash when trying to concatenate string var and string literal.
2021-12-14 23:07:46 +01:00
Irmen de Jong
5df623bd2e
doc
2021-12-14 22:40:03 +01:00
Irmen de Jong
02010170ce
fix compiler crash when attempting to call a non-function
2021-12-11 13:20:13 +01:00
Irmen de Jong
35998142fe
version 7.5
2021-12-10 20:18:17 +01:00
Irmen de Jong
3d743a1ba1
added more constfolding
2021-12-09 23:32:48 +01:00
Irmen de Jong
abca618008
added more constfolding
2021-12-09 23:12:12 +01:00
Irmen de Jong
0d2c3901a3
added more constfolding
2021-12-09 22:12:31 +01:00
Irmen de Jong
d901a1531f
added missing vectors to syslib
2021-12-09 21:38:00 +01:00
Irmen de Jong
d8d56b195f
comments
2021-12-09 21:13:13 +01:00
Irmen de Jong
98315de723
allow using ubyte[] as subroutine parameter type (because it is equivalent to uword pointer var)
2021-12-07 23:28:45 +01:00
Irmen de Jong
dcf487bdc1
fix: correctly insert return statement if needed to prevent 'fall through' into following subroutine
...
this wasn't working correctly anymore when the last statement before the subroutine was a jump/goto
2021-12-07 21:34:50 +01:00
Irmen de Jong
547b1d3720
comment corrections
2021-12-06 23:33:18 +01:00
Irmen de Jong
84f75f4156
tweaked some more .getOrElse
2021-12-06 21:22:00 +01:00
Irmen de Jong
ff69da3fa2
error when 'else' choice in when statemetn isn't the last one, also generate slightly better code for when statements
2021-12-05 21:54:46 +01:00
Irmen de Jong
edffe92a24
astchecker is smarter in detecting rts in inline assembly
2021-12-05 21:28:31 +01:00
Irmen de Jong
837804b231
test for string x and u escape sequences
2021-12-05 18:39:34 +01:00
Irmen de Jong
900cdd3fa1
added cx16diskio with load() and load_raw() that are HIMEM bank-aware
2021-12-05 02:20:48 +01:00
Irmen de Jong
0018dc6ce7
refactor machinedefinition
2021-12-04 19:07:19 +01:00
Irmen de Jong
c92f914081
gradle build settings tweak to avoid jdk version conflict
2021-12-04 18:36:47 +01:00
Irmen de Jong
0498444ef2
moved all unit tests into single project to avoid dependency issues
2021-12-04 18:20:22 +01:00
Irmen de Jong
ce3c34e458
tweak in error output for file links, corrected column number off-by-one
2021-12-04 16:52:03 +01:00
Irmen de Jong
20401b99d8
added cx16.getrambank() / getrombank() to retrieve the current ram and rom bank numbers.
2021-12-04 15:27:54 +01:00
Irmen de Jong
b867d8f731
cleanups
2021-12-04 01:03:51 +01:00
Irmen de Jong
9a68864b67
version 7.5-dev
2021-12-04 00:18:44 +01:00
Irmen de Jong
72d7178762
added diskio.load_raw() to load headerless files
2021-12-04 00:07:21 +01:00
Irmen de Jong
fbcd9a0c1d
reduce number of similar errors for type problem in assignment
2021-12-02 17:44:52 +01:00
Irmen de Jong
5b56e0462d
also deal with zero args
2021-12-01 22:26:36 +01:00
Irmen de Jong
b7fffbb6df
release 7.4.1 - oops, funcion call arg count validation was broken
2021-12-01 21:44:03 +01:00
Irmen de Jong
1f346230e3
release 7.4
2021-11-30 22:50:12 +01:00
Irmen de Jong
3d1d0696b9
refactor compiler arguments passing
2021-11-30 01:40:21 +01:00
Irmen de Jong
9ecf95b075
fix syntaxerror in const processing of ranges if it contained variables
2021-11-29 23:36:41 +01:00
Irmen de Jong
7748c261da
rsave/rrestore moved from sys to builtin function to solve the stack related problem when calling it as a regular subroutine
2021-11-29 23:13:04 +01:00
Irmen de Jong
a2db44f80c
also consider Y register for clobber check for functioncall arguments
2021-11-29 22:09:05 +01:00
Irmen de Jong
b438d8aec0
fix invalid range size check when stepval is not a positive integer
2021-11-29 02:01:19 +01:00
Irmen de Jong
56dc6d7f1e
comment
2021-11-29 01:10:11 +01:00
Irmen de Jong
45b8762188
use inc/ina instead of adc
2021-11-29 00:07:15 +01:00
Irmen de Jong
32068a832a
split some additional binary expressions to avoid stack-based evaluation
2021-11-28 18:27:28 +01:00
Irmen de Jong
47c2c0376a
added some cpu stack related assembly-level optimizations
2021-11-28 17:27:01 +01:00
Irmen de Jong
f0dadc4a43
optimize 1-arg functioncalls
2021-11-28 16:55:10 +01:00
Irmen de Jong
960b60cd2d
tweak
2021-11-28 14:06:12 +01:00
Irmen de Jong
0a568f2530
fix the check of double-defined subroutine variables
2021-11-28 12:52:32 +01:00
Irmen de Jong
c52aa648c0
use an AnonymousScope to contain GoSub changes instead of adding separate statements
2021-11-28 12:09:13 +01:00
Irmen de Jong
f3a4048ebf
improved setting Carry bit as asmsub parameter
2021-11-28 03:31:32 +01:00
Irmen de Jong
1b07637cc4
better error checking for wrong pop()
2021-11-28 02:49:18 +01:00
Irmen de Jong
68b75fd558
fix: also allow pass-by-reference arguments to builtin functions that accept UWORD (adds implicit type cast)
2021-11-28 02:34:53 +01:00
Irmen de Jong
7c5ec1853d
nice error message if pop() argument is wrong
2021-11-28 02:20:35 +01:00
Irmen de Jong
e8f4686430
undid failed attempt of using sys.push/sys.pop for stack args - now using new push(), pushw(), pop(), popw() builtin functions
2021-11-28 01:22:40 +01:00
Irmen de Jong
02348924d0
failed attempt of using sys.push/pop for stack args
2021-11-27 23:52:47 +01:00
Irmen de Jong
c838821615
refactor fuction arguments codegen a bit
2021-11-27 21:14:21 +01:00
Irmen de Jong
8b4ac7801f
fix sys.push() signature for c64
2021-11-27 20:18:41 +01:00
Irmen de Jong
e8e25c6fd6
added sys.push() and sys.pop() to put values on cpu stack. Added missing builtin functions to syntax-files.
2021-11-27 18:09:15 +01:00
Irmen de Jong
54025d2bf5
small refactor and spelling fixes
2021-11-27 14:49:18 +01:00
Irmen de Jong
f5ebf79e71
make sure X register is also saved if needed when GoSub is used
2021-11-26 22:11:52 +01:00
Irmen de Jong
110e047681
replace subroutine calls (statement) by GoSub
2021-11-26 19:47:01 +01:00
Irmen de Jong
17d403d812
Merge branch 'ref-subroutine-param' into v7.4-dev
...
# Conflicts:
# compilerAst/src/prog8/ast/AstToplevel.kt
2021-11-26 01:12:14 +01:00
Irmen de Jong
0a53bd4956
fix parameter name conflict
2021-11-26 01:01:59 +01:00
Irmen de Jong
e52d05c7db
fix some scoping related symbol lookup issues, clarified scoping rules in docs
2021-11-23 23:43:23 +01:00
Irmen de Jong
b00db4f8a2
no longer report unknown type errors as well for unknown symbols,
...
added a bunch more unit tests for symbol scoping rules
2021-11-23 22:45:57 +01:00
Irmen de Jong
0c2f30fd45
links to 6502 bresenham line algorithms
2021-11-23 21:51:18 +01:00
Irmen de Jong
e08871c637
oops! replace phx/plx 65C02 (cx16) instructions by 6502 (c64) compatible alternative.
...
Couldn't assemble code that used some of the routines in conv on c64 before...
2021-11-22 21:02:43 +01:00
Irmen de Jong
ff715881bc
allow scoped identifiers to reference a subroutine parameter directly.
...
also for asmsubroutines, but the asm generation for that is not yet done.
2021-11-21 23:21:39 +01:00
Irmen de Jong
0e2e5ffa52
fix parameter name conflict
2021-11-21 22:12:35 +01:00
Irmen de Jong
8095c4c155
added GoSub node (internal use only later for calling subroutines)
2021-11-21 16:23:48 +01:00
Irmen de Jong
8887e6af91
fix substituting 0 only if its actually the same variable that's substituted
2021-11-21 12:34:57 +01:00
Irmen de Jong
dde4c751da
version 7.4-dev
2021-11-21 03:28:13 +01:00
Irmen de Jong
b292124f3c
replaced many short/int values by unsigned types if appropriate
2021-11-21 00:55:56 +01:00
Irmen de Jong
c0035ba1a2
char encodings now use UByte type instead of short
2021-11-21 00:07:17 +01:00
Irmen de Jong
107935ed31
add some more const folding patterns
2021-11-20 22:47:49 +01:00
Irmen de Jong
adfaddbcf4
give a nicer error when given a wrong compilation target.
2021-11-20 18:30:55 +01:00
Irmen de Jong
74db5c6be7
fix referencesIdentifier() and better removal of unnecessary assignments
2021-11-20 17:41:41 +01:00
Irmen de Jong
f9399bcce7
r=(q+r)-c and r=q+(r-c) are now both also 'augmentable', and BinExprSplitter doesn't check for associativeOperator anymore
2021-11-20 02:03:32 +01:00
Irmen de Jong
87600b23db
fix constvalue parent linkage for prefix and typecast
2021-11-20 00:20:35 +01:00
Irmen de Jong
cedfb17b18
fix too aggressive removal of vars that weren't completely unused
2021-11-19 22:49:35 +01:00
Irmen de Jong
fa4c83df6b
added 3 tests for discovered problems
2021-11-18 23:55:20 +01:00
Irmen de Jong
42c8720e8b
fix float rounding tests
2021-11-18 22:54:49 +01:00
Irmen de Jong
b334d89715
refactor and fix the way memory addresses are checked to be in IO space or regular ram
2021-11-18 22:47:58 +01:00
Irmen de Jong
4f5d36a84d
optimization added: bitwise operations with a negative constant number -> replace the number by its positive 2 complement
2021-11-18 02:51:42 +01:00
Irmen de Jong
fa11a6e18b
removed faulty and too aggressive assembly optimization of double-store
2021-11-18 01:43:22 +01:00
Irmen de Jong
4c82af36e6
fix improperly changed behavior about =0 initializer
2021-11-18 00:17:22 +01:00
Irmen de Jong
dafa0d9138
fix compiler crash bug due to reused ast expression nodes. Now all (relevant) Nodes have a copy() function to make a clone.
2021-11-17 23:05:59 +01:00
Irmen de Jong
2e0450d7ed
fix bug where variable=0 initializer was forgotten if vardecl is followed by an augmented assignment
2021-11-17 22:31:43 +01:00
Irmen de Jong
f48d6ca9f8
simplified NumericLiteral to always just contain a Double instead of a Number for the value
2021-11-16 23:52:54 +01:00
Irmen de Jong
1f60a2d8b9
comments
2021-11-15 01:30:12 +01:00
Irmen de Jong
5fd83f2757
version 7.3
2021-11-14 22:55:13 +01:00
Irmen de Jong
c80df4140b
until-loop condition now also simplified to avoid stack-eval
2021-11-14 22:51:02 +01:00
Irmen de Jong
53e1729e2f
introduce option to use internal scratch variables via prog8_lib definitions (ony for compiler, not for user code!)
2021-11-14 16:01:54 +01:00
Irmen de Jong
ab2d1122a9
conditional expressions are optimized more intelligently (simple ones are not split off in separate assignments)
2021-11-14 12:38:56 +01:00
Irmen de Jong
5190594c8a
added several more assembly-level optimizations to remove redundant instructions
2021-11-14 12:23:46 +01:00
Irmen de Jong
c858ceeb58
compiler shouldn't use cx16.r15 as temp var
2021-11-14 02:38:59 +01:00
Irmen de Jong
f0f52b9166
optimize typecasted binary expression to avoid even more estack use. also fix wrong parent crash in removal of unused variable's assignments.
2021-11-13 14:22:37 +01:00
Irmen de Jong
00c6f74481
tweak temp float
2021-11-13 12:56:59 +01:00
Irmen de Jong
2177ba0ed2
added signed versions of the cx16 virtual registers
2021-11-13 02:42:21 +01:00
Irmen de Jong
3483515346
preparing for more optimizations
2021-11-12 23:23:51 +01:00
Irmen de Jong
75a06d2a40
preparing for more optimizations
2021-11-12 02:17:37 +01:00
Irmen de Jong
53ac11983b
better unused variable removal
2021-11-11 03:03:21 +01:00
Irmen de Jong
69f4a4d4f8
tweak expr.typecastTo() a bit
2021-11-11 00:15:09 +01:00
Irmen de Jong
222bcb808f
optimize load-store-load combo in output asm
2021-11-10 23:47:35 +01:00
Irmen de Jong
8df3da11e3
add cosr8, sinr8, cosr16 and sinr16 builtin functions that take a degree 0..179 (= 0..358 in 2 degree steps)
...
to more easily scale halves/quarters etc of a circle than possible with the ones that take 0..255 'degrees'.
2021-11-09 23:39:26 +01:00
Irmen de Jong
84dafda0e4
fix error message for type mismatch on builtin-function parameter
2021-11-09 22:19:07 +01:00
Irmen de Jong
b909facfe5
fix compiler stackoverflow crash on certain typecasted expressions containing floats.
2021-11-09 19:31:19 +01:00
Irmen de Jong
7780d94de1
discovered crash related to float typecasting in asm assignment codegen
2021-11-09 03:45:07 +01:00
Irmen de Jong
4937e004b5
fix compiler crash where it used wrong datatype in split assignment
...
fixes crash for "ubyte bb ;; uword ww ;; bb = not bb or not ww"
2021-11-09 01:13:23 +01:00
Irmen de Jong
857724c7e6
attempt to make if-statement not use stack eval anymore
2021-11-08 19:07:36 +01:00
Irmen de Jong
2d1e5bbc7e
remove unimportant empty tests
2021-11-08 17:00:10 +01:00
Irmen de Jong
7961a09d16
converting compiler module's testcases to kotest assertions
2021-11-08 16:14:22 +01:00
Irmen de Jong
613efcacc7
converting compiler module's testcases to kotest (ongoing)
2021-11-08 15:08:48 +01:00
Irmen de Jong
7e8db16e18
moved to kotest assertions in compilerAst module tests
2021-11-07 21:18:18 +01:00
Irmen de Jong
f4c4ee78d9
re-use global returnvalue temp var instead of duplicating it in every subroutine that needs it
2021-11-07 14:19:21 +01:00
Irmen de Jong
72a7e61fd0
version 7.2
2021-11-06 23:42:13 +01:00
Irmen de Jong
f40620aa25
"not x" as a condition (if, while, until) is optimized into "x==0", this avoids calculating the value
2021-11-06 23:25:32 +01:00
Irmen de Jong
4270c04856
don't crash but give proper error on "-X" expression where X is not a signed type
2021-11-06 18:06:01 +01:00
Irmen de Jong
62dc824bc0
tweaks
2021-11-06 17:14:07 +01:00
Irmen de Jong
1605791f1b
float swap() no longer uses evaluation stack but a single temp var instead + FAC1
2021-11-06 03:36:14 +01:00
Irmen de Jong
23961f695d
fixed some parse tree node position end-columns. cleanup some todo's
2021-11-05 22:48:28 +01:00
Irmen de Jong
eea3fb48a8
add command line option 'optfloatx' to explicitly re-enable float expr optimization as this can increase code size significantly.
...
The output size of the various example programs using floating point, when not using this optimization, has been reduced significantly.
The resulting code runs a (tiny) bit slower though.
2021-11-03 22:52:08 +01:00
Irmen de Jong
b4fa72c058
fix parent node linkage for reading array parameter
2021-11-03 21:57:31 +01:00
Irmen de Jong
3410aea788
fix regression: don't add 0 initializer when variable is assigned to anyway (or is loopvar in a for-loop)
2021-11-02 21:23:59 +01:00
Irmen de Jong
7e287a5359
proper parent node linkage in generated const values out of typecast expressions. Fixes crash mentioned in #72
2021-11-02 00:47:01 +01:00
Irmen de Jong
1110bd0851
fix vardecl initialization value to not use stack eval anymore but separate assignment
...
(this causes the optimized assignment code gen to be used instead)
but some programs now end up larger in output size
2021-11-01 00:24:15 +01:00
Irmen de Jong
fe17566370
improved reporting of slow stack based evaluation code
2021-10-31 14:18:49 +01:00
Irmen de Jong
03ac9b6956
various cleanups, slight update to dbus
2021-10-30 19:30:19 +02:00
Irmen de Jong
dfbef8495d
got rid of ParsingFailedError
2021-10-30 17:05:23 +02:00
Irmen de Jong
7b17c49d8f
update petscii tables with improvements to box drawing chars. fixes #68
2021-10-30 16:45:23 +02:00
Irmen de Jong
4b3f31c2ee
added option to suppress assembler output (and enabled this in unit tests)
2021-10-30 15:26:40 +02:00
Irmen de Jong
9ccc65bf8f
more petscii tests
2021-10-30 15:15:11 +02:00