diff --git a/docs/abi/inlining.md b/docs/abi/inlining.md index 23fb81ee..c362fc32 100644 --- a/docs/abi/inlining.md +++ b/docs/abi/inlining.md @@ -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 diff --git a/docs/lang/operators.md b/docs/lang/operators.md index 69761125..4463b0bf 100644 --- a/docs/lang/operators.md +++ b/docs/lang/operators.md @@ -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; diff --git a/docs/lang/types.md b/docs/lang/types.md index 02b42c3a..ff0e1d21 100644 --- a/docs/lang/types.md +++ b/docs/lang/types.md @@ -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 diff --git a/docs/various/cdiff.md b/docs/various/cdiff.md index 0dfee5a7..ee28fe0f 100644 --- a/docs/various/cdiff.md +++ b/docs/various/cdiff.md @@ -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.