mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
Various typo fixes
This commit is contained in:
parent
434515d957
commit
42ae935496
@ -95,7 +95,7 @@ For normal use the compiler can be invoked with the command:
|
||||
|
||||
By default, assembly code is generated and written to ``sourcefile.asm``.
|
||||
It is then (automatically) fed to the `64tass <https://sourceforge.net/projects/tass64/>`_ assembler tool
|
||||
that creastes the final runnable program.
|
||||
that creates the final runnable program.
|
||||
|
||||
|
||||
Command line options
|
||||
|
@ -150,7 +150,7 @@ Provides string manipulation routines.
|
||||
``length(str) -> ubyte length``
|
||||
Number of bytes in the string. This value is determined during runtime and counts upto
|
||||
the first terminating 0 byte in the string, regardless of the size of the string during compilation time.
|
||||
Don't confuse this with ``len`` and ``sizeof``
|
||||
Don't confuse this with ``len`` and ``sizeof``!
|
||||
|
||||
``left(source, length, target)``
|
||||
Copies the left side of the source string of the given length to target string.
|
||||
@ -176,8 +176,8 @@ Provides string manipulation routines.
|
||||
and the index in the string. Or 0+carry bit clear if the character was not found.
|
||||
|
||||
``compare(string1, string2) -> ubyte result``
|
||||
Returns -1, 0 or 1 depeding on wether string1 sorts before, equal or after string2.
|
||||
Note that you can also directly compare strings and string values with eachother
|
||||
Returns -1, 0 or 1 depending on whether string1 sorts before, equal or after string2.
|
||||
Note that you can also directly compare strings and string values with each other
|
||||
using ``==``, ``<`` etcetera (it will use string.compare for you under water automatically).
|
||||
|
||||
``copy(from, to) -> ubyte length``
|
||||
|
@ -108,7 +108,7 @@ Be careful when importing other modules; blocks in your own code cannot have
|
||||
the same name as a block defined in an imported module or library.
|
||||
|
||||
If you omit both the name and address, the entire block is *ignored* by the compiler (and a warning is displayed).
|
||||
This is a way to quickly "comment out" a piece of code that is unfinshed or may contain errors that you
|
||||
This is a way to quickly "comment out" a piece of code that is unfinished or may contain errors that you
|
||||
want to work on later, because the contents of the ignored block are not fully parsed either.
|
||||
|
||||
The address can be used to place a block at a specific location in memory.
|
||||
@ -353,7 +353,7 @@ It can be correctly displayed on the screen only if a iso-8859-15 charset has be
|
||||
|
||||
You can concatenate two string literals using '+', which can be useful to
|
||||
split long strings over separate lines. But remember that the length
|
||||
of the total string still cannot exceed 255 characaters.
|
||||
of the total string still cannot exceed 255 characters.
|
||||
A string literal can also be repeated a given number of times using '*', where the repeat number must be a constant value.
|
||||
And a new string value can be assigned to another string, but no bounds check is done
|
||||
so be sure the destination string is large enough to contain the new value (it is overwritten in memory)::
|
||||
@ -370,7 +370,7 @@ as newlines, quote characters themselves, and so on. The ones used most often ar
|
||||
``\\``, ``\"``, ``\n``, ``\r``. For a detailed description of all of them and what they mean,
|
||||
read the syntax reference on strings.
|
||||
|
||||
Using the ``in`` operator you can easily check if a characater is present in a string,
|
||||
Using the ``in`` operator you can easily check if a character is present in a string,
|
||||
example: ``if '@' in email_address {....}`` (however this gives no clue about the location
|
||||
in the string where the character is present, if you need that, use the ``string.find()``
|
||||
library function instead)
|
||||
@ -412,10 +412,10 @@ for the constant itself). This is only valid for the simple numeric types (byte,
|
||||
When using ``&`` (the address-of operator but now applied to a datatype), the variable will point to specific location in memory,
|
||||
rather than being newly allocated. The initial value (mandatory) must be a valid
|
||||
memory address. Reading the variable will read the given data type from the
|
||||
address you specified, and setting the varible will directly modify that memory location(s)::
|
||||
address you specified, and setting the variable will directly modify that memory location(s)::
|
||||
|
||||
const byte max_age = 2000 - 1974 ; max_age will be the constant value 26
|
||||
&word SCREENCOLORS = $d020 ; a 16-bit word at the addres $d020-$d021
|
||||
&word SCREENCOLORS = $d020 ; a 16-bit word at the address $d020-$d021
|
||||
|
||||
.. _pointervars_programming:
|
||||
|
||||
@ -511,7 +511,7 @@ Conditional Execution
|
||||
if statements
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
Conditional execution means that the flow of execution changes based on certiain conditions,
|
||||
Conditional execution means that the flow of execution changes based on certain conditions,
|
||||
rather than having fixed gotos or subroutine calls::
|
||||
|
||||
if xx==5 {
|
||||
@ -567,7 +567,7 @@ So ``if_cc goto target`` will directly translate into the single CPU instruction
|
||||
.. caution::
|
||||
These special ``if_XX`` branching statements are only useful in certain specific situations where you are *certain*
|
||||
that the status register (still) contains the correct status bits.
|
||||
This is not always the case after a fuction call or other operations!
|
||||
This is not always the case after a function call or other operations!
|
||||
If in doubt, check the generated assembly code!
|
||||
|
||||
.. note::
|
||||
@ -643,7 +643,7 @@ If possible, the expression is parsed and evaluated by the compiler itself at co
|
||||
Expressions that cannot be compile-time evaluated will result in code that calculates them at runtime.
|
||||
Expressions can contain procedure and function calls.
|
||||
There are various built-in functions such as sin(), cos() that can be used in expressions (see :ref:`builtinfunctions`).
|
||||
You can also reference idendifiers defined elsewhere in your code.
|
||||
You can also reference identifiers defined elsewhere in your code.
|
||||
|
||||
Read the :ref:`syntaxreference` chapter for all details on the available operators and kinds of expressions you can write.
|
||||
|
||||
@ -680,7 +680,7 @@ Logical expressions are expressions that calculate a boolean result: true or fal
|
||||
logical expressions will compile more efficiently than when you're using regular integer type operands
|
||||
(because these have to be converted to 0 or 1 every time)
|
||||
|
||||
You can use parentheses to group parts of an expresion to change the precedence.
|
||||
You can use parentheses to group parts of an expression to change the precedence.
|
||||
Usually the normal precedence rules apply (``*`` goes before ``+`` etc.) but subexpressions
|
||||
within parentheses will be evaluated first. So ``(4 + 8) * 2`` is 24 and not 20,
|
||||
and ``(true or false) and false`` is false instead of true.
|
||||
|
@ -8,7 +8,7 @@ Module file
|
||||
-----------
|
||||
|
||||
This is a file with the ``.p8`` suffix, containing *directives* and *code blocks*, described below.
|
||||
The file is a text file wich can also contain:
|
||||
The file is a text file which can also contain:
|
||||
|
||||
Lines, whitespace, indentation
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -48,7 +48,7 @@ Directives
|
||||
Global setting, selects the program launcher stub to use.
|
||||
Only relevant when using the ``prg`` output type. Defaults to ``basic``.
|
||||
|
||||
- type ``basic`` : add a tiny C64 BASIC program, whith a SYS statement calling into the machine code
|
||||
- type ``basic`` : add a tiny C64 BASIC program, with a SYS statement calling into the machine code
|
||||
- type ``none`` : no launcher logic is added at all
|
||||
|
||||
.. data:: %zeropage <style>
|
||||
@ -225,7 +225,7 @@ and after that, a combination of letters, numbers, or underscores. Examples of v
|
||||
Code blocks
|
||||
-----------
|
||||
|
||||
A named block of actual program code. Itefines a *scope* (also known as 'namespace') and
|
||||
A named block of actual program code. It defines a *scope* (also known as 'namespace') and
|
||||
can only contain *directives*, *variable declarations*, *subroutines* or *inline assembly*::
|
||||
|
||||
<blockname> [<address>] {
|
||||
@ -270,7 +270,7 @@ Variable declarations
|
||||
|
||||
Variables should be declared with their exact type and size so the compiler can allocate storage
|
||||
for them. You can give them an initial value as well. That value can be a simple literal value,
|
||||
or an expression. If you don't provide an intial value yourself, zero will be used.
|
||||
or an expression. If you don't provide an initial value yourself, zero will be used.
|
||||
You can add a ``@zp`` zeropage-tag, to tell the compiler to prioritize it
|
||||
when selecting variables to be put into zeropage (but no guarantees). If the ZP is full,
|
||||
the variable will be allocated in normal memory elsewhere.
|
||||
@ -505,7 +505,7 @@ logical: ``not`` ``and`` ``or`` ``xor``
|
||||
the ``bool`` variable type instead, where this conversion doesn't need to occur.
|
||||
|
||||
.. note::
|
||||
Unlike most other programming languages, there is no short-cirquit or McCarthy-evaluation
|
||||
Unlike most other programming languages, there is no short-circuit or McCarthy evaluation
|
||||
for the logical ``and`` and ``or`` operators. This means that prog8 currently always evaluates
|
||||
all operands from these logical expressions, even when one of them already determines the outcome!
|
||||
|
||||
@ -765,7 +765,7 @@ Conditional Execution and Jumps
|
||||
Unconditional jump: goto
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To jump to another part of the program, you use a ``goto`` statement with an addres or the name
|
||||
To jump to another part of the program, you use a ``goto`` statement with an address or the name
|
||||
of a label or subroutine::
|
||||
|
||||
goto $c000 ; address
|
||||
@ -806,7 +806,7 @@ However if <statements> is a block of multiple statements, you'll have to enclos
|
||||
**Special status register branch form:**
|
||||
|
||||
There is a special form of the if-statement that immediately translates into one of the 6502's branching instructions.
|
||||
It is almost the same as the regular if-statement but it lacks a contional expression part, because the if-statement
|
||||
It is almost the same as the regular if-statement but it lacks a conditional expression part, because the if-statement
|
||||
itself defines on what status register bit it should branch on::
|
||||
|
||||
if_XX <statements> [else <statements> ]
|
||||
@ -826,7 +826,7 @@ It can also be one of the four aliases that are easier to read: ``if_z``, ``if_n
|
||||
.. caution::
|
||||
These special ``if_XX`` branching statements are only useful in certain specific situations where you are *certain*
|
||||
that the status register (still) contains the correct status bits.
|
||||
This is not always the case after a fuction call or other operations!
|
||||
This is not always the case after a function call or other operations!
|
||||
If in doubt, check the generated assembly code!
|
||||
|
||||
|
||||
|
@ -80,7 +80,7 @@ ZeroPage ("ZP")
|
||||
|
||||
The ZeroPage memory block ``$02``--``$ff`` can be regarded as 254 CPU 'registers', because
|
||||
they take less clock cycles to access and need fewer instruction bytes than accessing other memory locations outside of the ZP.
|
||||
Theoretically they can all be used in a program, with the follwoing limitations:
|
||||
Theoretically they can all be used in a program, with the following limitations:
|
||||
|
||||
- several addresses (``$02``, ``$03``, ``$fb - $fc``, ``$fd - $fe``) are reserved for internal use
|
||||
- most other addresses will already be in use by the machine's operating system or kernal,
|
||||
@ -100,7 +100,7 @@ There's a global program directive to specify the way the compiler
|
||||
treats the ZP for the program. The default is to be reasonably restrictive to use the
|
||||
part of the ZP that is not used by the C64's kernal routines.
|
||||
It's possible to claim the whole ZP as well (by disabling the operating system or kernal).
|
||||
If you want, it's also possible to be more restricive and stay clear of the addresses used by BASIC routines too.
|
||||
If you want, it's also possible to be more restrictive and stay clear of the addresses used by BASIC routines too.
|
||||
This allows the program to exit cleanly back to a BASIC ready prompt - something that is not possible in the other modes.
|
||||
|
||||
|
||||
@ -163,5 +163,5 @@ The Commander X16 provides two additional routines that should be used *in your
|
||||
|
||||
cx16.push_vera_context()
|
||||
; ... do your work that uses vera here...
|
||||
cx15.pop_vera_context()
|
||||
cx16.pop_vera_context()
|
||||
|
||||
|
@ -42,7 +42,7 @@ Calling a subroutine requires three steps:
|
||||
|
||||
#. preparing the arguments (if any) and passing them to the routine
|
||||
#. calling the routine
|
||||
#. preparig the return value (if any) and returning that from the call.
|
||||
#. preparing the return value (if any) and returning that from the call.
|
||||
|
||||
|
||||
Calling the routine is just a simple JSR instruction, but the other two work like this:
|
||||
@ -83,7 +83,7 @@ Some builtin functions have a fully custom implementation.
|
||||
|
||||
|
||||
The compiler will warn about routines that are called and that return a value, if you're not
|
||||
doing something with that returnvalue. This can be on purpuse if you're simply not interested in it.
|
||||
doing something with that returnvalue. This can be on purpose if you're simply not interested in it.
|
||||
Use the ``void`` keyword in front of the subroutine call to get rid of the warning in that case.
|
||||
|
||||
|
||||
@ -138,7 +138,7 @@ Some notes and references into the compiler's source code modules:
|
||||
Most notably, node type information is now baked in. (``codeCore`` module)
|
||||
#. An *Intermediate Representation* has been defined that is generated from the intermediate AST. This IR
|
||||
is more or less a machine code language for a virtual machine - and indeed this is what the built-in
|
||||
prog8 VM will execute if you use the 'virtual' compilaton target and use ``-emu`` to launch the VM.
|
||||
prog8 VM will execute if you use the 'virtual' compilation target and use ``-emu`` to launch the VM.
|
||||
(``intermediate`` and ``codeGenIntermediate`` modules, and ``virtualmachine`` module for the VM related stuff)
|
||||
#. Currently the 6502 ASM code generator still works directly on the *Compiler AST*. A future version
|
||||
should replace this by working on the IR code, and should be much smaller and simpler.
|
||||
|
Loading…
Reference in New Issue
Block a user