diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index cc72440e9..2b9d39b24 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -59,6 +59,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) { 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/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. 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...