1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-22 16:31:02 +00:00

Documentatin update

This commit is contained in:
Karol Stasiak 2019-04-18 17:20:35 +02:00
parent 00d190c3d8
commit 41e6bddfd9
2 changed files with 21 additions and 10 deletions

View File

@ -16,6 +16,8 @@ The flag is enabled by default, but you can disable it if you need to.
Millfork has different operator precedence compared to most other languages. From highest to lowest it goes:
* `->` and `[]`
* `*`, `*'`
* `+`, `+'`, `-`, `-'`, `|`, `&`, `^`, `>>`, `>>'`, `<<`, `<<'`, `>>>>`
@ -169,7 +171,7 @@ An expression of form `a[f()] += b` may call `f` an undefined number of times.
* `=`: normal assignment
`mutable enum = enum`
`mutable byte = byte`
`mutable word = word`
`mutable word = word`
`mutable long = long`
* `+=`, `+'=`, `|=`, `^=`, `&=`: modification in place
@ -206,13 +208,21 @@ While Millfork does not consider indexing an operator, this is a place as good a
An expression of form `a[i]`, where `i` is an expression of type `byte`, is:
* when `a` is an array that has numeric index type: an access to the `i`-th element of the array `a`
* when `a` is an array that has numeric index type and `T` value type:
an access to the `i`-th element of the array `a`
* when `a` is a pointer variable: an access to the byte in memory at address `a + i`
* when `a` is a raw pointer variable:
an access to the byte in memory at address `a + i`
Those expressions are of type `byte`. If `a` is any other kind of expression, `a[i]` is invalid.
* when `a` is a typed pointer variable to a 1-byte type `T`:
an access to the value pointed to by `a`
If the zeropage register is enabled, `i` can also be of type `word`.
* when `a` is a typed pointer variable to a 2-byte type `T` and `i` is zero:
an access to the value pointed to by `a`
* otherwise: a compile error
On 8080-like targets, and on 6502 if the zeropage register is enabled, `i` can also be of type `word`.
An expression of form `a[i]`, where `i` is an expression of a enumeration type, is:

View File

@ -23,12 +23,9 @@ Millfork puts extra limitations on which types can be used in which contexts.
* `ubyte` unsigned 1-byte value
* `pointer` the same as `word`, but variables of this type default to be zero-page-allocated
and you can index `pointer` variables (not arbitrary `pointer`-typed expressions though, `f()[0]` won't compile)
* `pointer` raw pointers; the same as `word`, but variables of this type default to be zero-page-allocated
and you can index `pointer`-typed expressions.
You can create pointer values by suffixing `.addr` to the name of a variable, function or array.
**Work in progress**:
There's no reason to make a function return `pointer` yet, since currently to dereference it,
you need to put it in a variable first anyway.
You can access single bytes of variables by using the following notations:
@ -56,6 +53,10 @@ For every type `T`, there is a pointer type defined called `pointer.T`.
Unlike raw pointers, they are not subject to arithmetic.
If the type `T` is of size 1, you can index the pointer like a raw pointer.
If the type `T` is of size 2, you can index the pointer only with the constant 0.
Examples:
pointer.t p