From 353d6cfc557fe12472d88b845394b453629cbf41 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 17 Oct 2020 20:35:36 +0200 Subject: [PATCH] doc about array index restriction --- docs/source/building.rst | 2 +- docs/source/libraries.rst | 2 +- docs/source/programming.rst | 16 ++++++++-------- docs/source/targetsystem.rst | 5 +++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/source/building.rst b/docs/source/building.rst index ef87493f6..79a569911 100644 --- a/docs/source/building.rst +++ b/docs/source/building.rst @@ -41,7 +41,7 @@ of that build task, you can start the compiler with: (You should probably make an alias...) -.. note:: +.. hint:: Development and testing is done on Linux, but the compiler should run on most operating systems. If you do have trouble building or running the compiler on another operating system, please let me know! diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index e31a380af..05e1f8edb 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -16,7 +16,7 @@ with Prog8 are written like this. You can ``%import`` and use these modules explicitly, but the compiler may also import one or more of these library modules automatically as required. -.. note:: +.. caution:: The resulting compiled binary program *only works on the target machine it was compiled for*. You must recompile the program for every target you want to run it on. diff --git a/docs/source/programming.rst b/docs/source/programming.rst index 3a5454315..1cfa43841 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -254,12 +254,19 @@ Array types are also supported. They can be made of bytes, words or floats, stri This means byte arrays should be <= 256 elements, word arrays <= 128 elements, and float arrays <= 51 elements. +.. note:: + To avoid slow and complex assembly code generation, Prog8 currently enforces some limits on + what you can index the array with. *It is not possible to use an arbitrary expression/calculation as an index value*. + You can use a numerical constant value or a single variable as an index value. + + You can split an array initializer list over several lines if you want. Note that the various keywords for the data type and variable type (``byte``, ``word``, ``const``, etc.) can't be used as *identifiers* elsewhere. You can't make a variable, block or subroutine with the name ``byte`` for instance. + It's possible to assign a new array to another array, this will overwrite all elements in the original array with those in the value array. The number and types of elements have to match. For large arrays this is a slow operation because every element is copied over. It should probably be avoided. @@ -307,7 +314,7 @@ as newlines, quote characters themselves, and so on. The ones used most often ar read the syntax reference on strings. -.. note:: +.. hint:: Strings and uwords (=memory address) can often be interchanged. An array of strings is actually an array of uwords where every element is the memory address of the string. You can pass a memory address to assembly functions @@ -372,13 +379,6 @@ address you specified, and setting the varible will directly modify that memory &word SCREENCOLORS = $d020 ; a 16-bit word at the addres $d020-$d021 -.. note:: - Directly accessing random memory locations is not yet supported without the - intermediate step of declaring a memory-mapped variable for the memory location. - The advantages of this however, is that it's clearer what the memory location - stands for, and the compiler also knows the data type. - - Converting types into other types ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/source/targetsystem.rst b/docs/source/targetsystem.rst index ea18b6ad1..e01fc0e77 100644 --- a/docs/source/targetsystem.rst +++ b/docs/source/targetsystem.rst @@ -16,8 +16,9 @@ Currently there are two machines that are supported as compiler target (selectab This chapter explains the relevant system details of these machines. -.. note:: - If you only use standard kernel and prog8 library routines, it is possible to compile the *exact same program* for both machines (just change the compiler target flag)! +.. hint:: + If you only use standard kernel and prog8 library routines, + it is possible to compile the *exact same program* for both machines (just change the compiler target flag)! Memory Model