mirror of
https://github.com/irmen/prog8.git
synced 2025-02-02 19:32:21 +00:00
doc about array index restriction
This commit is contained in:
parent
f37564c49c
commit
353d6cfc55
@ -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!
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user