1
0
mirror of https://github.com/KarolS/millfork.git synced 2026-04-22 00:17:03 +00:00

Changes to macros and parameter list syntax:

* non-asm macros can now take `const` and `call` parameters
* register parameters to asm functions and macros can be given names if annotated explicitly
This commit is contained in:
Karol Stasiak
2020-03-30 19:23:48 +02:00
parent 5cdc599b1d
commit 63ff28e94e
50 changed files with 465 additions and 191 deletions
+4 -2
View File
@@ -151,9 +151,11 @@ Non-macro functions can only have their parameters passed via registers:
* `word xa`, `word ax`, `word ay`, `word ya`, `word xy`, `word yx`: a 2-byte word byte passed via given two CPU registers,
with the high byte passed through the first register and the low byte passed through the second register; any 2-byte type can be used
* the above, but written more explicitly: `byte register(a) paramname`, `byte register(x) paramname`, `word register(ax) paramname` etc.
For example, this piece of code:
asm void f(word ax) @F_ADDR extern
asm void f(word register(ax) value) @F_ADDR extern
f(5)
@@ -179,7 +181,7 @@ Macro assembly functions can have maximum one parameter passed via a register.
An external function should be declared with a defined memory address
and the `extern` keyword instead of the body:
asm void putchar(byte a) @$FFD2 extern
asm void putchar(byte register(a) char) @$FFD2 extern
## Safe assembly
+2
View File
@@ -120,6 +120,8 @@ Non-macro functions can only have their parameters passed via registers:
* `word d`, `word x`, `word y`: a 2-byte word byte passed via given 16-bit register; any 2-byte type can be used
* the above, but written more explicitly: `byte register(a) paramname`, `byte register(b) paramname`, `word register(x) paramname` etc.
Parameters passed via other registers (`U`, `S` etc.) or combinations of registers do not work yet.
**Work in progress**:
+2
View File
@@ -160,6 +160,8 @@ Non-macro functions can only have their parameters passed via registers:
* `word hl`, `word bc`, `word de`: a 2-byte word byte passed via given 16-bit register; any 2-byte type can be used
* the above, but written more explicitly: `byte register(a) paramname`, `byte register(b) paramname`, `word register(hl) paramname` etc.
Parameters passed via other registers (`I`, `IX`, `IY`, `IXH` etc.) or combinations of registers do not work yet.
**Work in progress**:
+1 -1
View File
@@ -14,7 +14,7 @@ Examples:
void do_nothing() { }
inline byte two() = 2
extern asm void chkout(byte a) @ $FFD2
extern asm void chkout(byte register(a) char) @ $FFD2
segment(prgrom0) void main_loop(word w, byte x) align(fast) { // body omitted
+3 -3
View File
@@ -7,10 +7,10 @@
To call an external function, you need to declare it as `asm extern`. For example:
```
asm void putchar(byte a) @$FFD2 extern
asm void putchar(byte register(a) char) @$FFD2 extern
```
The function parameter will be passed via the accumulator,
In this example, the function parameter will be passed via the accumulator,
the function itself is located in ROM at $FFD2. A call like this:
```
@@ -36,7 +36,7 @@ To call a function that has its address calculated dynamically,
you just need to do the same as what you would do in assembly; 6502 example:
```
asm void call_function(byte a) {
asm void call_function(byte register(a) param) {
JMP (function_address)
}
```