mirror of
https://github.com/irmen/prog8.git
synced 2024-10-05 18:56:19 +00:00
doc
This commit is contained in:
parent
8a99844140
commit
4be632ae33
57
reference.md
57
reference.md
@ -225,24 +225,21 @@ logic and several utility routines that do I/O, such as ``print_string``.
|
|||||||
|
|
||||||
### Importing, Including and Binary-Including other files or raw assembly code
|
### Importing, Including and Binary-Including other files or raw assembly code
|
||||||
|
|
||||||
```%import "filename[.ill]"```
|
- ``%import "filename[.ill]"``
|
||||||
Must be used *after* any global option directives, and outside of a block,
|
Must be used *after* any global option directives, and outside of a block,
|
||||||
but otherwise can be placed anywhere in the program.
|
but otherwise can be placed anywhere in the program.
|
||||||
Reads and compiles the named IL65 file and stores the resulting definitions
|
Reads and compiles the named IL65 file and stores the resulting definitions
|
||||||
as if they were a part of your current program.
|
as if they were a part of your current program.
|
||||||
|
- ``%asminclude "filename.txt", scopelabel``
|
||||||
```%asminclude "filename.txt", scopelabel```
|
|
||||||
This directive can only be used inside a block.
|
This directive can only be used inside a block.
|
||||||
The assembler will include the file as raw assembly source text at this point, il65 will not process this at all.
|
The assembler will include the file as raw assembly source text at this point, il65 will not process this at all.
|
||||||
The scopelabel will be used as a prefix to access the labels from the included source code,
|
The scopelabel will be used as a prefix to access the labels from the included source code,
|
||||||
otherwise you would risk symbol redefinitions or duplications.
|
otherwise you would risk symbol redefinitions or duplications.
|
||||||
|
- ``%asmbinary "filename.bin" [, <offset>[, <length>]]``
|
||||||
```%asmbinary "filename.bin" [, <offset>[, <length>]]```
|
|
||||||
This directive can only be used inside a block.
|
This directive can only be used inside a block.
|
||||||
The assembler will include the file as binary bytes at this point, il65 will not process this at all.
|
The assembler will include the file as binary bytes at this point, il65 will not process this at all.
|
||||||
The optional offset and length can be used to select a particular piece of the file.
|
The optional offset and length can be used to select a particular piece of the file.
|
||||||
|
- ``%asm {`` [raw assembly code lines] ``}``
|
||||||
```%asm {``` [raw assembly code lines] ``}``
|
|
||||||
This directive includes raw unparsed assembly code at that exact spot in the program.
|
This directive includes raw unparsed assembly code at that exact spot in the program.
|
||||||
The ``%asm {`` and ``}`` start and end markers each have to be on their own unique line.
|
The ``%asm {`` and ``}`` start and end markers each have to be on their own unique line.
|
||||||
|
|
||||||
@ -257,12 +254,10 @@ Blocks and other details are described below.
|
|||||||
|
|
||||||
### Blocks
|
### Blocks
|
||||||
|
|
||||||
``~ blockname [address] {``
|
~ blockname [address] {
|
||||||
|
[directives...]
|
||||||
[directives...]
|
[statements...]
|
||||||
[statements...]
|
}
|
||||||
|
|
||||||
``}``
|
|
||||||
|
|
||||||
Blocks form the separate pieces of code and data of your program. They are combined and
|
Blocks form the separate pieces of code and data of your program. They are combined and
|
||||||
arranged to a single output program. No code or data can occur outside a block.
|
arranged to a single output program. No code or data can occur outside a block.
|
||||||
@ -324,18 +319,20 @@ The syntax is:
|
|||||||
... statements ...
|
... statements ...
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_parameters = comma separated list of "<parametername>:<register>" pairs specifying the input parameters.
|
**proc_parameters =**
|
||||||
You can omit the parameter names as long as the arguments "line up".
|
comma separated list of "<parametername>:<register>" pairs specifying the input parameters.
|
||||||
(actually, the Python parameter passing rules apply, so you can also mix positional
|
You can omit the parameter names as long as the arguments "line up".
|
||||||
and keyword arguments, as long as the keyword arguments come last)
|
(actually, the Python parameter passing rules apply, so you can also mix positional
|
||||||
|
and keyword arguments, as long as the keyword arguments come last)
|
||||||
|
|
||||||
proc_results = comma separated list of <register> names specifying in which register(s) the output is returned.
|
**proc_results =**
|
||||||
If the register name ends with a '?', that means the register doesn't contain a real return value but
|
comma separated list of <register> names specifying in which register(s) the output is returned.
|
||||||
is clobbered in the process so the original value it had before calling the sub is no longer valid.
|
If the register name ends with a '?', that means the register doesn't contain a real return value but
|
||||||
This is not immediately useful for your own code, but the compiler needs this information to
|
is clobbered in the process so the original value it had before calling the sub is no longer valid.
|
||||||
emit the correct assembly code to preserve the cpu registers if needed when the call is made.
|
This is not immediately useful for your own code, but the compiler needs this information to
|
||||||
For convenience: a single '?' als the result spec is shorthand for ``A?, X?, Y?`` ("I don't know
|
emit the correct assembly code to preserve the cpu registers if needed when the call is made.
|
||||||
what the changed registers are, assume the worst")
|
For convenience: a single '?' als the result spec is shorthand for ``A?, X?, Y?`` ("I don't know
|
||||||
|
what the changed registers are, assume the worst")
|
||||||
|
|
||||||
|
|
||||||
Subroutines that are pre-defined on a specific memory location (usually routines from ROM),
|
Subroutines that are pre-defined on a specific memory location (usually routines from ROM),
|
||||||
@ -344,23 +341,25 @@ but instead assign a memory address to it:
|
|||||||
|
|
||||||
sub <identifier> ([proc_parameters]) -> ([proc_results]) = <address>
|
sub <identifier> ([proc_parameters]) -> ([proc_results]) = <address>
|
||||||
|
|
||||||
example: "sub CLOSE (logical: A) -> (A?, X?, Y?) = $FFC3"
|
example:
|
||||||
|
|
||||||
|
sub CLOSE (logical: A) -> (A?, X?, Y?) = $FFC3"
|
||||||
|
|
||||||
|
|
||||||
### Subroutine Calling
|
### Subroutine Calling
|
||||||
|
|
||||||
You call a subroutine like this:
|
You call a subroutine like this:
|
||||||
|
|
||||||
``subroutinename_or_address (`` [arguments...] ``)``
|
subroutinename_or_address ( [arguments...] )
|
||||||
|
|
||||||
or:
|
or:
|
||||||
|
|
||||||
``subroutinename_or_address !``[register(s)] ``( [arguments...] )``
|
subroutinename_or_address ![register(s)] ( [arguments...] )
|
||||||
|
|
||||||
If the subroutine returns one or more values as results, you must use an assignment statement
|
If the subroutine returns one or more values as results, you must use an assignment statement
|
||||||
to store those values somewhere:
|
to store those values somewhere:
|
||||||
|
|
||||||
``outputvar1, outputvar2 = subroutine ( arg1, arg2, arg3 )``
|
outputvar1, outputvar2 = subroutine ( arg1, arg2, arg3 )
|
||||||
|
|
||||||
The output variables must occur in the correct sequence of return registers as specified
|
The output variables must occur in the correct sequence of return registers as specified
|
||||||
in the subroutine's definiton. It is possible to not specify any of them but the compiler
|
in the subroutine's definiton. It is possible to not specify any of them but the compiler
|
||||||
@ -427,7 +426,7 @@ It defaults to 'true' (=='ne', not-zero) if omitted. ('pos' will translate into
|
|||||||
The <expression> is optional. If it is provided, it will be evaluated first. Only the [true] and [not] and [zero]
|
The <expression> is optional. If it is provided, it will be evaluated first. Only the [true] and [not] and [zero]
|
||||||
if-statuses can be used when such a *comparison expression* is used. An example is:
|
if-statuses can be used when such a *comparison expression* is used. An example is:
|
||||||
|
|
||||||
``if_not A > 55 goto more_iterations``
|
if_not A > 55 goto more_iterations
|
||||||
|
|
||||||
|
|
||||||
Conditional jumps are compiled into 6502's branching instructions (such as ``bne`` and ``bcc``) so
|
Conditional jumps are compiled into 6502's branching instructions (such as ``bne`` and ``bcc``) so
|
||||||
|
Loading…
Reference in New Issue
Block a user