mirror of
https://github.com/KarolS/millfork.git
synced 2026-04-27 01:19:37 +00:00
Documentation improvements
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
[< back to index](../index.md)
|
||||
|
||||
# Using assembly within Millfork programs
|
||||
|
||||
There are two ways to include raw assembly code in your Millfork programs:
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
[< back to index](../index.md)
|
||||
|
||||
# Function definitions
|
||||
|
||||
Syntax:
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
[< back to index](../index.md)
|
||||
|
||||
# Interfacing with external code
|
||||
|
||||
## Calling external functions at a static address
|
||||
|
||||
+23
-3
@@ -1,3 +1,5 @@
|
||||
[< back to index](../index.md)
|
||||
|
||||
# Literals and initializers
|
||||
|
||||
## Numeric literals
|
||||
@@ -56,11 +58,29 @@ From the type system point of view, they are constants of type byte.
|
||||
|
||||
## Array initialisers
|
||||
|
||||
An array is initialized with either a string literal,
|
||||
or a list of byte literals and strings, surrounded by brackets:
|
||||
An array is initialized with either:
|
||||
|
||||
* a string literal
|
||||
|
||||
* a `file` expression
|
||||
|
||||
* a `for`-style expression
|
||||
|
||||
* a list of byte literals and/or other array initializers, surrounded by brackets:
|
||||
|
||||
|
||||
array a = [1, 2]
|
||||
array b = "----" scr
|
||||
array c = ["hello world!" ascii, 13]
|
||||
array d = file("d.bin")
|
||||
array e = file("d.bin", 128, 256)
|
||||
array f = for x,0,until,8 [x * 3 + 5] // equivalent to [5, 8, 11, 14, 17, 20, 23, 26]
|
||||
|
||||
Trailing commas (`[1, 2,]`) are not allowed.
|
||||
Trailing commas (`[1, 2,]`) are not allowed.
|
||||
|
||||
The parameters for `file` are: file path, optional start offset, optional length
|
||||
(start offset and length have to be either both present or both absent).
|
||||
|
||||
The `for`-style expression has a variable, a starting index, a direction, a final index,
|
||||
and a parametrizable array initializer.
|
||||
The initializer is repeated for every value of the variable in the given range.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
[< back to index](../index.md)
|
||||
|
||||
# Operators
|
||||
|
||||
Unlike in high-level languages, operators in Millfork have limited applicability.
|
||||
@@ -198,4 +200,9 @@ Those expressions are of type `byte`. If `a` is any other kind of expression, `a
|
||||
`nonet(byte <<' constant byte)`
|
||||
Other kinds of expressions than the above (even `nonet(byte + byte + byte)`) will not work as expected.
|
||||
|
||||
* `hi`, `lo`: most/least significant byte of a word
|
||||
`hi(word)`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
[< back to index](../index.md)
|
||||
|
||||
# Reentrancy
|
||||
|
||||
A function is called reentrant,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
[< back to index](../index.md)
|
||||
|
||||
# Syntax
|
||||
|
||||
For information about types, see [Types](./types.md).
|
||||
@@ -86,6 +88,16 @@ if <expression> {
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
if <expression> {
|
||||
<body>
|
||||
} else if <expression> {
|
||||
<body>
|
||||
} else {
|
||||
<body>
|
||||
}
|
||||
```
|
||||
|
||||
### `return` statement
|
||||
|
||||
Syntax:
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
[< back to index](../index.md)
|
||||
|
||||
# Types
|
||||
|
||||
Millfork puts extra limitations on which types can be used in which contexts.
|
||||
|
||||
Reference in New Issue
Block a user