mirror of
https://github.com/irmen/prog8.git
synced 2024-07-19 19:29:41 +00:00
added %option splitarrays (block level)
This commit is contained in:
parent
bb9d29b061
commit
8f864417c4
@ -800,7 +800,7 @@ internal class AstChecker(private val program: Program,
|
|||||||
err("this directive may only occur in a block or at module level")
|
err("this directive may only occur in a block or at module level")
|
||||||
if(directive.args.isEmpty())
|
if(directive.args.isEmpty())
|
||||||
err("missing option directive argument(s)")
|
err("missing option directive argument(s)")
|
||||||
else if(directive.args.map{it.name in arrayOf("enable_floats", "force_output", "no_sysinit", "align_word", "align_page", "merge")}.any { !it })
|
else if(directive.args.map{it.name in arrayOf("enable_floats", "force_output", "no_sysinit", "align_word", "align_page", "merge", "splitarrays")}.any { !it })
|
||||||
err("invalid option directive argument(s)")
|
err("invalid option directive argument(s)")
|
||||||
}
|
}
|
||||||
else -> throw SyntaxError("invalid directive ${directive.directive}", directive.position)
|
else -> throw SyntaxError("invalid directive ${directive.directive}", directive.position)
|
||||||
|
@ -164,20 +164,25 @@ class AstPreprocessor(val program: Program,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(options.splitWordArrays && (decl.datatype==DataType.ARRAY_W || decl.datatype==DataType.ARRAY_UW)) {
|
if(options.splitWordArrays && (decl.datatype==DataType.ARRAY_W || decl.datatype==DataType.ARRAY_UW)) {
|
||||||
// make all word arrays automatically be tagged as split arrays
|
if(!decl.definingBlock.isInLibrary)
|
||||||
if(!decl.definingBlock.isInLibrary) {
|
return makeSplitArray(decl)
|
||||||
val splitDt = ArrayToElementTypes.getValue(decl.datatype)
|
|
||||||
val newDecl = VarDecl(
|
|
||||||
decl.type, decl.origin, splitDt, decl.zeropage, decl.arraysize, decl.name,
|
|
||||||
decl.value, true, decl.sharedWithAsm, true, decl.position
|
|
||||||
)
|
|
||||||
return listOf(IAstModification.ReplaceNode(decl, newDecl, parent))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if("splitarrays" in decl.definingBlock.options() && (decl.datatype==DataType.ARRAY_W || decl.datatype==DataType.ARRAY_UW))
|
||||||
|
return makeSplitArray(decl)
|
||||||
|
|
||||||
return noModifications
|
return noModifications
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun makeSplitArray(decl: VarDecl): Iterable<IAstModification> {
|
||||||
|
val splitDt = ArrayToElementTypes.getValue(decl.datatype)
|
||||||
|
val newDecl = VarDecl(
|
||||||
|
decl.type, decl.origin, splitDt, decl.zeropage, decl.arraysize, decl.name,
|
||||||
|
decl.value, true, decl.sharedWithAsm, true, decl.position
|
||||||
|
)
|
||||||
|
return listOf(IAstModification.ReplaceNode(decl, newDecl, decl.parent))
|
||||||
|
}
|
||||||
|
|
||||||
override fun after(subroutine: Subroutine, parent: Node): Iterable<IAstModification> {
|
override fun after(subroutine: Subroutine, parent: Node): Iterable<IAstModification> {
|
||||||
// For non-kernal subroutines and non-asm parameters:
|
// For non-kernal subroutines and non-asm parameters:
|
||||||
// inject subroutine params as local variables (if they're not there yet).
|
// inject subroutine params as local variables (if they're not there yet).
|
||||||
|
@ -168,7 +168,7 @@ class IntermediateAstMaker(private val program: Program, private val options: Co
|
|||||||
"align_word" -> alignment = PtBlock.BlockAlignment.WORD
|
"align_word" -> alignment = PtBlock.BlockAlignment.WORD
|
||||||
"align_page" -> alignment = PtBlock.BlockAlignment.PAGE
|
"align_page" -> alignment = PtBlock.BlockAlignment.PAGE
|
||||||
"force_output" -> forceOutput=true
|
"force_output" -> forceOutput=true
|
||||||
"merge" -> { /* ignore this one */ }
|
"merge", "splitarrays" -> { /* ignore this one */ }
|
||||||
else -> throw FatalAstException("weird directive option: ${arg.name}")
|
else -> throw FatalAstException("weird directive option: ${arg.name}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ The compiler will link everything together into one output program at the end.
|
|||||||
If you start the compiler without arguments, it will print a short usage text.
|
If you start the compiler without arguments, it will print a short usage text.
|
||||||
For normal use the compiler can be invoked with the command:
|
For normal use the compiler can be invoked with the command:
|
||||||
|
|
||||||
``$ java -jar prog8compiler-7.3-all.jar sourcefile.p8``
|
``$ java -jar prog8compiler-8.14-all.jar sourcefile.p8``
|
||||||
|
|
||||||
(Use the appropriate name and version of the jar file downloaded from one of the Git releases.
|
(Use the appropriate name and version of the jar file downloaded from one of the Git releases.
|
||||||
Other ways to invoke the compiler are also available: see the introduction page about how
|
Other ways to invoke the compiler are also available: see the introduction page about how
|
||||||
@ -252,12 +252,37 @@ that support these symbol and breakpoint lists.
|
|||||||
Troubleshooting
|
Troubleshooting
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
Compiler doesn't run, complains about "UnsupportedClassVersionError"
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
You need to install and use JDK version 11 or newer to run the prog8 compiler. Check this with "java -version".
|
||||||
|
|
||||||
|
The computer resets unexpectedly (at the end of the program)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
If you are using the default 'zeropage' compiler option, and your program exits, it is not possible
|
||||||
|
to return back to the BASIC prompt. The only reliable course of action is to reboot the system.
|
||||||
|
(this is due to the fact that in the default mode, prog8 can overwrite important BASIC and Kernal
|
||||||
|
variables in memory).
|
||||||
|
To avoid a sudden system reset, use an empty ``repeat`` loop at the end of your program to keep it from exiting.
|
||||||
|
Alternatively, if you want your program to exit cleanly back to the BASIC prompt,
|
||||||
|
you have to use ``%zeropage basicsafe``, see :ref:`directives`.
|
||||||
|
|
||||||
|
Odd text and screen colors at start
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
Prog8 will reset the screen mode and colors to a uniform well-known state. If you don't like the
|
||||||
|
default text and screen colors, you can simply change them to whatever you want using the
|
||||||
|
appropriate routines in the ``textio`` module.
|
||||||
|
Alternatively you can choose to disable this re-initialization altogether
|
||||||
|
using ``%option no_sysinit``, see :ref:`directives`.
|
||||||
|
|
||||||
|
Floats error
|
||||||
|
^^^^^^^^^^^^
|
||||||
Getting an assembler error about undefined symbols such as ``not defined 'floats'``?
|
Getting an assembler error about undefined symbols such as ``not defined 'floats'``?
|
||||||
This happens when your program uses floating point values, and you forgot to import ``floats`` library.
|
This happens when your program uses floating point values, and you forgot to import ``floats`` library.
|
||||||
If you use floating points, the compiler needs routines from that library.
|
If you use floating points, the compiler needs routines from that library.
|
||||||
Fix it by adding an ``%import floats``.
|
Fix it by adding an ``%import floats``.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ Directives
|
|||||||
- ``align_word`` (in a block) will make the assembler align the start address of this block on a word boundary in memory (so, an even memory address).
|
- ``align_word`` (in a block) will make the assembler align the start address of this block on a word boundary in memory (so, an even memory address).
|
||||||
- ``align_page`` (in a block) will make the assembler align the start address of this block on a page boundary in memory (so, the LSB of the address is 0).
|
- ``align_page`` (in a block) will make the assembler align the start address of this block on a page boundary in memory (so, the LSB of the address is 0).
|
||||||
- ``merge`` (in a block) will merge this block's contents into an already existing block with the same name. Useful in library scenarios.
|
- ``merge`` (in a block) will merge this block's contents into an already existing block with the same name. Useful in library scenarios.
|
||||||
|
- ``splitarrays`` (in a block) makes all word-arrays in this block lsb/msb split arrays (as if they all have the @split tag). See Arrays.
|
||||||
|
|
||||||
|
|
||||||
.. data:: %asmbinary "<filename>" [, <offset>[, <length>]]
|
.. data:: %asmbinary "<filename>" [, <offset>[, <length>]]
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
|
- instead of resetting the computer at program exit, reinit screen and print message >PROGRAM EXIT CODE 123;RESET COMPUTER.< + sei + endless loop.
|
||||||
|
change troubleshooting and other references in the docs.
|
||||||
|
|
||||||
|
|
||||||
For 9.0 major changes
|
For 9.0 major changes
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
- DONE: added 'cbm' block in the syslib module that now contains all CBM compatible kernal routines and variables
|
- DONE: added 'cbm' block in the syslib module that now contains all CBM compatible kernal routines and variables
|
||||||
@ -17,6 +21,7 @@ For 9.0 major changes
|
|||||||
- DONE: added sys.irqsafe_xxx irqd routines
|
- DONE: added sys.irqsafe_xxx irqd routines
|
||||||
- DONE: added gfx2.fill() flood fill routine
|
- DONE: added gfx2.fill() flood fill routine
|
||||||
- DONE: added @split storage class for (u)word arrays to store them as split lsb/msb arrays which is more efficient (but doesn't yet support all array operations)
|
- DONE: added @split storage class for (u)word arrays to store them as split lsb/msb arrays which is more efficient (but doesn't yet support all array operations)
|
||||||
|
- DONE: added -splitarrays command line option to treat all word arrays as tagged with @split
|
||||||
|
|
||||||
- [much work:] more support for (64tass) SEGMENTS ?
|
- [much work:] more support for (64tass) SEGMENTS ?
|
||||||
- (What, how, isn't current BSS support enough?)
|
- (What, how, isn't current BSS support enough?)
|
||||||
|
Loading…
Reference in New Issue
Block a user