From 9a2df072ccf668fffb10246882a05c48e98dde6a Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 24 Jan 2023 22:48:44 +0100 Subject: [PATCH 1/3] tiny correction --- docs/source/programming.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/programming.rst b/docs/source/programming.rst index 01a78c40c..02eb1caa7 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -638,7 +638,7 @@ In most places where a number or other value is expected, you can use just the n If possible, the expression is parsed and evaluated by the compiler itself at compile time, and the (constant) resulting value is used in its place. Expressions that cannot be compile-time evaluated will result in code that calculates them at runtime. Expressions can contain procedure and function calls. -There are various built-in functions such as sin(), cos() that can be used in expressions (see :ref:`builtinfunctions`). +There are various built-in functions that can be used in expressions (see :ref:`builtinfunctions`). You can also reference identifiers defined elsewhere in your code. Read the :ref:`syntaxreference` chapter for all details on the available operators and kinds of expressions you can write. From 8b05abb80dc2a84dbabae8fa4283b4eeadedff4f Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 25 Jan 2023 23:41:08 +0100 Subject: [PATCH 2/3] proper error when attempting to refer to parameters of asmsub by name --- compiler/src/prog8/compiler/astprocessing/AstChecker.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index a084d939a..a0f971603 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -61,6 +61,14 @@ internal class AstChecker(private val program: Program, } } + override fun visit(identifier: IdentifierReference) { + val targetParam = identifier.targetVarDecl(program)?.subroutineParameter + if(targetParam!=null) { + if((targetParam.parent as Subroutine).isAsmSubroutine) + errors.err("cannot refer to parameter of asmsub by name", identifier.position) + } + } + override fun visit(returnStmt: Return) { val expectedReturnValues = returnStmt.definingSubroutine?.returntypes ?: emptyList() if(expectedReturnValues.size>1) { From f1a7d5ecf76ba02a35554a63005822e3b929c330 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 26 Jan 2023 00:37:30 +0100 Subject: [PATCH 3/3] docs --- docs/source/libraries.rst | 6 ++++-- docs/source/targetsystem.rst | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index fd3d6ffcd..83a76005a 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -31,12 +31,14 @@ syslib The "system library" for your target machine. It contains many system-specific definitions such as ROM/Kernal subroutine definitions, memory location constants, and utility subroutines. -Depending on the compilation target, other routines may also be available in here specific to that target. -Best is to check the source code of the correct syslib module. Many of these definitions overlap for the C64 and Commander X16 targets so it is still possible to write programs that work on both targets without modifications. +This module is usually imported automatically and can provide definitions in the ``sys``, ``c64``, ``cx16``, ``c128``, ``atari`` blocks +depending on the chosen compilation target. Read the `syslib source code `_ for the correct compilation target to see exactly what is there. + + sys (part of syslib) -------------------- ``target`` diff --git a/docs/source/targetsystem.rst b/docs/source/targetsystem.rst index d4d3a9deb..a15a08308 100644 --- a/docs/source/targetsystem.rst +++ b/docs/source/targetsystem.rst @@ -159,7 +159,9 @@ And for the Commander X16:: cx16.restore_irq() ; set everything back to the systems default irq handler -The Commander X16 provides two additional routines that should be used *in your IRQ handler routine* if it uses the Vera registers:: +The Commander X16 syslib provides two additional routines that should be used *in your IRQ handler routine* if it uses the Vera registers. +They take care of saving and restoring the Vera state of the interrupted main program, otherwise the IRQ handler's manipulation +will corrupt any Vera operations that were going on in the main program. The routines are:: cx16.push_vera_context() ; ... do your work that uses vera here...