1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-10-25 05:24:11 +00:00

Operator documentation fixes

This commit is contained in:
Karol Stasiak 2018-01-10 13:17:09 +01:00
parent 8e3797e7e4
commit 6e0a750e48

View File

@ -2,6 +2,8 @@
Unlike in high-level languages, operators in Millfork have limited applicability. Unlike in high-level languages, operators in Millfork have limited applicability.
Not every well-formed expression is actually compilable. Not every well-formed expression is actually compilable.
Most expressions involving single bytes compile,
but for larger types usually you need to use in-place modification operators.
Further improvements to the compiler may increase the number of acceptable combinations. Further improvements to the compiler may increase the number of acceptable combinations.
## Precedence ## Precedence
@ -54,12 +56,14 @@ Such expressions have the property that the only register they may clobber is Y.
* `+`, `-`: * `+`, `-`:
`byte + byte` `byte + byte`
`word + word` `constant word + constant word`
`long + long` `constant long + constant long`
* `*`: 8-bit multiplication * `*`: multiplication; the size of the result is the same as the size of the arguments
`byte * constant byte` `byte * constant byte`
`constant byte * byte` `constant byte * byte`
`constant word * constant word`
`constant long * constant long`
There are no division, remainder or modulo operators. There are no division, remainder or modulo operators.
@ -67,9 +71,13 @@ There are no division, remainder or modulo operators.
* `|`, `^`, `&`: OR, EXOR and AND * `|`, `^`, `&`: OR, EXOR and AND
`byte | byte` `byte | byte`
`constant word | constant word`
`constant long | constant long`
* `<<`, `>>`: bit shifting; shifting right pads the result with zeroes * `<<`, `>>`: bit shifting; shifting pads the result with zeroes
`byte << constant byte` `byte << constant byte`
`constant word << constant byte`
`constant long << constant byte`
* `>>>>`: shifting a 9-bit value and returning a byte; `a >>>> b` is equivalent to `(a & $1FF) >> b`, but the latter doesn't compile yet * `>>>>`: shifting a 9-bit value and returning a byte; `a >>>> b` is equivalent to `(a & $1FF) >> b`, but the latter doesn't compile yet
`word >>>> constant byte` `word >>>> constant byte`
@ -80,8 +88,8 @@ These operators work using the decimal arithmetic and will not work on Ricoh CPU
* `+'`, `-'`: decimal addition/subtraction * `+'`, `-'`: decimal addition/subtraction
`byte +' byte` `byte +' byte`
`word +' word` `constant word +' constant word`
`long +' long` `constant long +' constant long`
* `*'`: decimal multiplication * `*'`: decimal multiplication
`constant *' constant` `constant *' constant`
@ -114,7 +122,7 @@ Currently, `>`, `<`, `<=`, `>=` operators perform unsigned comparison
if none of the types of their arguments is signed, if none of the types of their arguments is signed,
and fail to compile otherwise. This will be changed in the future. and fail to compile otherwise. This will be changed in the future.
## Assignment operators ## Assignment and in-place modification operators
* `=`: normal assignment * `=`: normal assignment
`mutable byte = byte` `mutable byte = byte`
@ -139,4 +147,5 @@ and fail to compile otherwise. This will be changed in the future.
* `*=`: multiplication in place * `*=`: multiplication in place
`mutable byte *= constant byte` `mutable byte *= constant byte`
There are no `*'=` operator yet. There is no `*'=` operator yet.