1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-05-29 04:41:30 +00:00

Various documentation updates

This commit is contained in:
Karol Stasiak 2020-10-05 22:20:08 +02:00
parent e94ccd164f
commit 963fae8275
4 changed files with 13 additions and 5 deletions

View File

@ -12,6 +12,8 @@ It implies the following:
* cannot be `inline`, `noinline` or `extern`
* cannot contain variable or array declarations
* can be `asm` - in this case, they should **not** end with a return instruction
* do not have an address

View File

@ -310,7 +310,8 @@ but not
some enum → `word`
* `sizeof`: size of the argument in bytes; the argument can be an expression or a type,
and the result is a constant of either `byte` or `word` type, depending on the actual value
and the result is a constant of either `byte` or `word` type, depending on the actual value.
In case of aligned types, this returns the aligned size.
* `call`: calls a function via a pointer;
the first argument is the pointer to the function;

View File

@ -269,8 +269,11 @@ If the struct is smaller that its alignment, then arrays of it are faster
sizeof(a) // equals 16
sizeof(b) // equals 12
return a[i].x // requires XXXX cycles on 6502
return b[i].x // requires XXXX cycles on 6502
return a[i].x // requires 22 or 24 cycles on 6502
return b[i].x // requires 18 cycles on 6502
A struct that contains substructs or subunions with non-trivial alignments has its alignment equal
to the least common multiple of the alignments of the substructs and its own declared alignment.
## Unions

View File

@ -34,7 +34,9 @@ This prevents most ambiguities in bit-twiddling code, but requires care when por
* Integer literals starting with zero and containing just digits are decimal, not octal.
For octal literals, use the `0o` prefix.
* String literals are not null-terminated by default. Use the `z` suffix for null-terminated strings.
* String literals are not null-terminated by default. Use the `z` suffix for null-terminated strings.
Note: this is the opposite of what KickC does!
Keep this in mind when migrating KickC code to Millfork or the other way around.
* In `if`, `do/while`, `while` and `for` statements, parentheses are not required, but braces are.
The `else` branch also requires braces, unless the only statement in the `else` block is an `if` statement.
@ -70,7 +72,7 @@ Unlike `#define`, such definitions are not visible within the preprocessor.
This issue applies mostly to the `*` and `<<` operators.
* There is no padding in structs.
* There is no padding in structs, except before fields whose type is a struct or a union with a non-trivial alignment.