fix %asminclude by removing scopelabel argument and improving docs to remove false promise about labels

This commit is contained in:
Irmen de Jong 2021-05-16 00:14:57 +02:00
parent bc731e6f8e
commit 0416aacbbd
9 changed files with 41 additions and 40 deletions

View File

@ -195,7 +195,7 @@ sub print_f (float value) {
}}
}
%asminclude "library:c64/floats.asm", ""
%asminclude "library:c64/floats_funcs.asm", ""
%asminclude "library:c64/floats.asm"
%asminclude "library:c64/floats_funcs.asm"
}

View File

@ -158,7 +158,7 @@ sub print_f (float value) {
}}
}
%asminclude "library:c64/floats.asm", ""
%asminclude "library:c64/floats_funcs.asm", ""
%asminclude "library:c64/floats.asm"
%asminclude "library:c64/floats_funcs.asm"
}

View File

@ -3,5 +3,5 @@
; Written by Irmen de Jong (irmen@razorvine.net) - license: GNU GPL 3.0
math {
%asminclude "library:math.asm", ""
%asminclude "library:math.asm"
}

View File

@ -3,8 +3,8 @@
; Written by Irmen de Jong (irmen@razorvine.net) - license: GNU GPL 3.0
prog8_lib {
%asminclude "library:prog8_lib.asm", ""
%asminclude "library:prog8_funcs.asm", ""
%asminclude "library:prog8_lib.asm"
%asminclude "library:prog8_funcs.asm"
uword @zp retval_interm_uw ; to store intermediary expression results for return values (hopefully allocated on ZP to reduce code size)
word @zp retval_interm_w ; to store intermediary expression results for return values (hopefully allocated on ZP to reduce code size)

View File

@ -691,8 +691,8 @@ internal class AstChecker(private val program: Program,
"%asminclude" -> {
if(directive.parent !is INameScope || directive.parent is Module)
err("this directive may only occur in a block")
if(directive.args.size!=2 || directive.args[0].str==null || directive.args[1].str==null)
err("invalid asminclude directive, expected arguments: \"filename\", \"scopelabel\"")
if(directive.args.size!=1 || directive.args[0].str==null)
err("invalid asminclude directive, expected argument: \"filename\"")
checkFileExists(directive, directive.args[0].str!!)
}
"%asmbinary" -> {

View File

@ -1236,12 +1236,7 @@ $repeatLabel lda $counterVar
when(stmt.directive) {
"%asminclude" -> {
val sourcecode = loadAsmIncludeFile(stmt.args[0].str!!, stmt.definingModule().source)
val scopeprefix = stmt.args[1].str ?: ""
if(scopeprefix.isNotBlank())
out("$scopeprefix\t.proc")
assemblyLines.add(sourcecode.trimEnd().trimStart('\n'))
if(scopeprefix.isNotBlank())
out(" .pend\n")
}
"%asmbinary" -> {
val offset = if(stmt.args.size>1) ", ${stmt.args[1].int}" else ""

View File

@ -142,15 +142,15 @@ Directives
The optional offset and length can be used to select a particular piece of the file.
The file is located relative to the current working directory!
.. data:: %asminclude "<filename>", "scopelabel"
.. data:: %asminclude "<filename>"
Level: block.
This directive can only be used inside a block.
The assembler will include the file as raw assembly source text at this point,
prog8 will not process this at all, with one exception: the labels.
The scopelabel argument will be used as a prefix to access the labels from the included source code,
otherwise you would risk symbol redefinitions or duplications.
If you know what you are doing you can leave it as an empty string to not have a scope prefix.
prog8 will not process this at all. Symbols defined in the included assembly can not be referenced
from prog8 code. However they can be referenced from other assembly code if properly prefixed.
Be careful: you risk symbol redefinitions or duplications if you include a piece of
assembly into a prog8 block that already defines symbols itself.
The compiler first looks for the file relative to the same directory as the module containing this statement is in,
if the file can't be found there it is searched relative to the current directory.

View File

@ -8,7 +8,7 @@ TODO
StatementOptimizer line 60: only optimize when it's a known constant literal
IMPROVE DOCUMENTATION ABOUT STRINGS AND DEDUP and (NON)IMMUTABILITY.
- test all examples 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
- c64: make the graphics.BITMAP_ADDRESS configurable (VIC banking)

View File

@ -1,24 +1,30 @@
%import textio ; txt.*
%zeropage basicsafe
main {
sub start() {
txt.print("a")
txt.print("a")
txt.print("bb")
txt.print("bb")
txt.print("\n")
txt.print("\n\n")
; txt.print("hello\n")
; txt.print("hello\n")
; txt.print("hello\n")
; txt.print("hello\n")
; txt.print("hello22\n")
; txt.print("hello22\n")
; txt.print("hello22\n")
; txt.print("hello22\n")
; txt.print("hello666\n")
; txt.print("hello666\n")
; txt.print("hello666\n")
; txt.print("hello666\n")
}
sub start() {
str string1 = "stringvalue"
str string2 = "stringvalue"
str string3 = "stringvalue"
txt.print("a")
txt.print("a")
txt.print("bb")
txt.print("bb")
txt.print("\n")
txt.print("\n\n")
txt.print(string1)
txt.nl()
txt.print(string2)
txt.nl()
txt.print(string3)
txt.nl()
txt.print("hello\n")
txt.print("hello\n")
txt.print("hello\n")
txt.print("bye\n")
txt.print("bye\n")
txt.print("bye\n")
}
}