mirror of
https://github.com/irmen/prog8.git
synced 2024-11-18 04:08:58 +00:00
Kernal spelling
This commit is contained in:
parent
0e297731a3
commit
db8912a735
@ -74,7 +74,7 @@ Language features
|
|||||||
- Many built-in functions, such as ``sin``, ``cos``, ``abs``, ``sqrt``, ``msb``, ``rol``, ``ror``, ``sort`` and ``reverse``
|
- Many built-in functions, such as ``sin``, ``cos``, ``abs``, ``sqrt``, ``msb``, ``rol``, ``ror``, ``sort`` and ``reverse``
|
||||||
- Programs can be run multiple times without reloading because of automatic variable (re)initializations.
|
- Programs can be run multiple times without reloading because of automatic variable (re)initializations.
|
||||||
- Supports the sixteen 'virtual' 16-bit registers R0 .. R15 from the Commander X16, also on the other machines.
|
- Supports the sixteen 'virtual' 16-bit registers R0 .. R15 from the Commander X16, also on the other machines.
|
||||||
- If you only use standard kernal and core prog8 library routines, it is possible to compile the *exact same program* for different machines (just change the compilation target flag)!
|
- If you only use standard Kernal and core prog8 library routines, it is possible to compile the *exact same program* for different machines (just change the compilation target flag)!
|
||||||
|
|
||||||
|
|
||||||
Code example
|
Code example
|
||||||
|
@ -29,7 +29,7 @@ of these library modules automatically as required.
|
|||||||
syslib
|
syslib
|
||||||
------
|
------
|
||||||
The "system library" for your target machine. It contains many system-specific definitions such
|
The "system library" for your target machine. It contains many system-specific definitions such
|
||||||
as ROM/kernal subroutine definitions, memory location constants, and utility subroutines.
|
as ROM/Kernal subroutine definitions, memory location constants, and utility subroutines.
|
||||||
|
|
||||||
Depending on the compilation target, other routines may also be available in here specific to that target.
|
Depending on the compilation target, other routines may also be available in here specific to that target.
|
||||||
Best is to check the source code of the correct syslib module.
|
Best is to check the source code of the correct syslib module.
|
||||||
@ -140,7 +140,7 @@ Provides several routines that deal with disk drive I/O, such as:
|
|||||||
- delete and rename files on the disk
|
- delete and rename files on the disk
|
||||||
- send arbitrary CbmDos command to disk drive
|
- send arbitrary CbmDos command to disk drive
|
||||||
|
|
||||||
On the Commander X16 it tries to use that machine's fast kernal loading routines if possible.
|
On the Commander X16 it tries to use that machine's fast Kernal loading routines if possible.
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
@ -210,7 +210,7 @@ Provides string manipulation routines.
|
|||||||
|
|
||||||
floats
|
floats
|
||||||
------
|
------
|
||||||
Provides definitions for the ROM/kernal subroutines and utility routines dealing with floating
|
Provides definitions for the ROM/Kernal subroutines and utility routines dealing with floating
|
||||||
point variables. This includes ``print_f``, the routine used to print floating point numbers,
|
point variables. This includes ``print_f``, the routine used to print floating point numbers,
|
||||||
``fabs`` to get the absolute value of a floating point number, and a dozen or so floating point
|
``fabs`` to get the absolute value of a floating point number, and a dozen or so floating point
|
||||||
math routines.
|
math routines.
|
||||||
|
@ -20,9 +20,9 @@ Memory Map
|
|||||||
Zero page
|
Zero page
|
||||||
=========
|
=========
|
||||||
#. *Absolute requirement:* Provide three times 2 consecutive bytes (i.e. three 16-bit pointers) in the Zero page that are free to use at all times.
|
#. *Absolute requirement:* Provide three times 2 consecutive bytes (i.e. three 16-bit pointers) in the Zero page that are free to use at all times.
|
||||||
#. Provide list of any additional free Zero page locations for a normal running system (basic + kernal enabled)
|
#. Provide list of any additional free Zero page locations for a normal running system (basic + Kernal enabled)
|
||||||
#. Provide list of any additional free Zero page locations when basic is off, but floating point routines should still work
|
#. Provide list of any additional free Zero page locations when basic is off, but floating point routines should still work
|
||||||
#. Provide list of any additional free Zero page locations when only the kernal remains enabled
|
#. Provide list of any additional free Zero page locations when only the Kernal remains enabled
|
||||||
|
|
||||||
Only the three 16-bit pointers are absolutely required to be able to use prog8 on the system.
|
Only the three 16-bit pointers are absolutely required to be able to use prog8 on the system.
|
||||||
But more known available Zero page locations mean smaller and faster programs.
|
But more known available Zero page locations mean smaller and faster programs.
|
||||||
|
@ -261,8 +261,8 @@ Floating point numbers
|
|||||||
|
|
||||||
Floats are stored in the 5-byte 'MFLPT' format that is used on CBM machines,
|
Floats are stored in the 5-byte 'MFLPT' format that is used on CBM machines,
|
||||||
and currently all floating point operations are specific to the Commodore 64.
|
and currently all floating point operations are specific to the Commodore 64.
|
||||||
This is because routines in the C-64 BASIC and KERNAL ROMs are used for that.
|
This is because routines in the C-64 BASIC and Kernal ROMs are used for that.
|
||||||
So floating point operations will only work if the C-64 BASIC ROM (and KERNAL ROM)
|
So floating point operations will only work if the C-64 BASIC ROM (and Kernal ROM)
|
||||||
are banked in.
|
are banked in.
|
||||||
|
|
||||||
Also your code needs to import the ``floats`` library to enable floating point support
|
Also your code needs to import the ``floats`` library to enable floating point support
|
||||||
@ -935,7 +935,7 @@ callrom(bank, address, argumentaddress) ; NOTE: specific to cx16 target for
|
|||||||
syscall(callnr), syscall1(callnr, arg), syscall2(callnr, arg1, arg2), syscall3(callnr, arg1, arg2, arg3)
|
syscall(callnr), syscall1(callnr, arg), syscall2(callnr, arg1, arg2), syscall3(callnr, arg1, arg2, arg3)
|
||||||
Functions for doing a system call on targets that support this. Currently no actual target
|
Functions for doing a system call on targets that support this. Currently no actual target
|
||||||
uses this though except, possibly, the experimental code generation target!
|
uses this though except, possibly, the experimental code generation target!
|
||||||
The regular 6502 based compiler targets just use a subroutine call to asmsub kernal routines at
|
The regular 6502 based compiler targets just use a subroutine call to asmsub Kernal routines at
|
||||||
specific memory locations. So these builtin function calls are not useful yet except for
|
specific memory locations. So these builtin function calls are not useful yet except for
|
||||||
experimentation in new code generation targets.
|
experimentation in new code generation targets.
|
||||||
|
|
||||||
|
@ -57,19 +57,19 @@ Directives
|
|||||||
Global setting, select ZeroPage handling style. Defaults to ``kernalsafe``.
|
Global setting, select ZeroPage handling style. Defaults to ``kernalsafe``.
|
||||||
|
|
||||||
- style ``kernalsafe`` -- use the part of the ZP that is 'free' or only used by BASIC routines,
|
- style ``kernalsafe`` -- use the part of the ZP that is 'free' or only used by BASIC routines,
|
||||||
and don't change anything else. This allows full use of KERNAL ROM routines (but not BASIC routines),
|
and don't change anything else. This allows full use of Kernal ROM routines (but not BASIC routines),
|
||||||
including default IRQs during normal system operation.
|
including default IRQs during normal system operation.
|
||||||
It's not possible to return cleanly to BASIC when the program exits. The only choice is
|
It's not possible to return cleanly to BASIC when the program exits. The only choice is
|
||||||
to perform a system reset. (A ``system_reset`` subroutine is available in the syslib to help you do this)
|
to perform a system reset. (A ``system_reset`` subroutine is available in the syslib to help you do this)
|
||||||
- style ``floatsafe`` -- like the previous one but also reserves the addresses that
|
- style ``floatsafe`` -- like the previous one but also reserves the addresses that
|
||||||
are required to perform floating point operations (from the BASIC kernal). No clean exit is possible.
|
are required to perform floating point operations (from the BASIC Kernal). No clean exit is possible.
|
||||||
- style ``basicsafe`` -- the most restricted mode; only use the handful 'free' addresses in the ZP, and don't
|
- style ``basicsafe`` -- the most restricted mode; only use the handful 'free' addresses in the ZP, and don't
|
||||||
touch change anything else. This allows full use of BASIC and KERNAL ROM routines including default IRQs
|
touch change anything else. This allows full use of BASIC and Kernal ROM routines including default IRQs
|
||||||
during normal system operation.
|
during normal system operation.
|
||||||
When the program exits, it simply returns to the BASIC ready prompt.
|
When the program exits, it simply returns to the BASIC ready prompt.
|
||||||
- style ``full`` -- claim the whole ZP for variables for the program, overwriting everything,
|
- style ``full`` -- claim the whole ZP for variables for the program, overwriting everything,
|
||||||
except the few addresses mentioned above that are used by the system's IRQ routine.
|
except the few addresses mentioned above that are used by the system's IRQ routine.
|
||||||
Even though the default IRQ routine is still active, it is impossible to use most BASIC and KERNAL ROM routines.
|
Even though the default IRQ routine is still active, it is impossible to use most BASIC and Kernal ROM routines.
|
||||||
This includes many floating point operations and several utility routines that do I/O, such as ``print``.
|
This includes many floating point operations and several utility routines that do I/O, such as ``print``.
|
||||||
This option makes programs smaller and faster because even more variables can
|
This option makes programs smaller and faster because even more variables can
|
||||||
be stored in the ZP (which allows for more efficient assembly code).
|
be stored in the ZP (which allows for more efficient assembly code).
|
||||||
@ -119,7 +119,7 @@ Directives
|
|||||||
Sets special compiler options.
|
Sets special compiler options.
|
||||||
|
|
||||||
- ``enable_floats`` (module level) tells the compiler
|
- ``enable_floats`` (module level) tells the compiler
|
||||||
to deal with floating point numbers (by using various subroutines from the Commodore 64 kernal).
|
to deal with floating point numbers (by using various subroutines from the Commodore 64 Kernal).
|
||||||
Otherwise, floating point support is not enabled. Normally you don't have to use this yourself as
|
Otherwise, floating point support is not enabled. Normally you don't have to use this yourself as
|
||||||
importing the ``floats`` library is required anyway and that will enable it for you automatically.
|
importing the ``floats`` library is required anyway and that will enable it for you automatically.
|
||||||
- ``no_sysinit`` (module level) which cause the resulting program to *not* include
|
- ``no_sysinit`` (module level) which cause the resulting program to *not* include
|
||||||
@ -580,7 +580,7 @@ Multiple return values
|
|||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
Normal subroutines can only return zero or one return values.
|
Normal subroutines can only return zero or one return values.
|
||||||
However, the special ``asmsub`` routines (implemented in assembly code) or ``romsub`` routines
|
However, the special ``asmsub`` routines (implemented in assembly code) or ``romsub`` routines
|
||||||
(referencing a routine in kernal ROM) can return more than one return value.
|
(referencing a routine in Kernal ROM) can return more than one return value.
|
||||||
For example a status in the carry bit and a number in A, or a 16-bit value in A/Y registers.
|
For example a status in the carry bit and a number in A, or a 16-bit value in A/Y registers.
|
||||||
It is not possible to process the results of a call to these kind of routines
|
It is not possible to process the results of a call to these kind of routines
|
||||||
directly from the language, because only single value assignments are possible.
|
directly from the language, because only single value assignments are possible.
|
||||||
|
@ -20,7 +20,7 @@ Currently these machines can be selected as a compilation target (via the ``-tar
|
|||||||
This chapter explains some relevant system details of the c64 and cx16 machines.
|
This chapter explains some relevant system details of the c64 and cx16 machines.
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
If you only use standard kernal and prog8 library routines,
|
If you only use standard Kernal and prog8 library routines,
|
||||||
it is often possible to compile the *exact same program* for
|
it is often possible to compile the *exact same program* for
|
||||||
different machines (just change the compilation target flag)!
|
different machines (just change the compilation target flag)!
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ reserved address in use for
|
|||||||
The actual machine will often have many other special addresses as well,
|
The actual machine will often have many other special addresses as well,
|
||||||
For example, the Commodore 64 has:
|
For example, the Commodore 64 has:
|
||||||
|
|
||||||
- ROMs installed in the machine: BASIC, kernal and character roms. Occupying ``$a000``--``$bfff`` and ``$e000``--``$ffff``.
|
- ROMs installed in the machine: BASIC, Kernal and character roms. Occupying ``$a000``--``$bfff`` and ``$e000``--``$ffff``.
|
||||||
- memory-mapped I/O registers, for the video and sound chips, and the CIA's. Occupying ``$d000``--``$dfff``.
|
- memory-mapped I/O registers, for the video and sound chips, and the CIA's. Occupying ``$d000``--``$dfff``.
|
||||||
- RAM areas that are used for screen graphics and sprite data: usually at ``$0400``--``$07ff``.
|
- RAM areas that are used for screen graphics and sprite data: usually at ``$0400``--``$07ff``.
|
||||||
|
|
||||||
@ -83,10 +83,10 @@ they take less clock cycles to access and need fewer instruction bytes than acce
|
|||||||
Theoretically they can all be used in a program, with the following 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
|
- 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,
|
- most other addresses will already be in use by the machine's operating system or Kernal,
|
||||||
and overwriting them will probably crash the machine. It is possible to use all of these
|
and overwriting them will probably crash the machine. It is possible to use all of these
|
||||||
yourself, but only if the program takes over the entire system (and seizes control from the regular kernal).
|
yourself, but only if the program takes over the entire system (and seizes control from the regular Kernal).
|
||||||
This means it can no longer use (most) BASIC and kernal routines from ROM.
|
This means it can no longer use (most) BASIC and Kernal routines from ROM.
|
||||||
- it's more convenient and safe to let the compiler allocate these addresses for you and just
|
- it's more convenient and safe to let the compiler allocate these addresses for you and just
|
||||||
use symbolic names in the program code.
|
use symbolic names in the program code.
|
||||||
|
|
||||||
@ -98,8 +98,8 @@ machine, (almost) all of the ZP addresses are suddenly available and will be use
|
|||||||
**ZeroPage handling is configurable:**
|
**ZeroPage handling is configurable:**
|
||||||
There's a global program directive to specify the way the compiler
|
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
|
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.
|
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).
|
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 restrictive 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.
|
This allows the program to exit cleanly back to a BASIC ready prompt - something that is not possible in the other modes.
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ This allows the program to exit cleanly back to a BASIC ready prompt - something
|
|||||||
IRQs and the ZeroPage
|
IRQs and the ZeroPage
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
The normal IRQ routine in the C-64's kernal will read and write several addresses in the ZP
|
The normal IRQ routine in the C-64's Kernal will read and write several addresses in the ZP
|
||||||
(such as the system's software jiffy clock which sits in ``$a0 - $a2``):
|
(such as the system's software jiffy clock which sits in ``$a0 - $a2``):
|
||||||
|
|
||||||
``$a0 - $a2``; ``$91``; ``$c0``; ``$c5``; ``$cb``; ``$f5 - $f6``
|
``$a0 - $a2``; ``$91``; ``$c0``; ``$c5``; ``$cb``; ``$f5 - $f6``
|
||||||
@ -155,7 +155,7 @@ For the C64 these routines are::
|
|||||||
And for the Commander X16::
|
And for the Commander X16::
|
||||||
|
|
||||||
cx16.set_irq(uword handler_address, boolean useKernal) ; vsync irq
|
cx16.set_irq(uword handler_address, boolean useKernal) ; vsync irq
|
||||||
cx16.set_rasterirq(uword handler_address, uword rasterline) ; note: disables kernal irq handler! sys.wait() won't work anymore
|
cx16.set_rasterirq(uword handler_address, uword rasterline) ; note: disables Kernal irq handler! sys.wait() won't work anymore
|
||||||
cx16.restore_irq() ; set everything back to the systems default irq handler
|
cx16.restore_irq() ; set everything back to the systems default irq handler
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ Calling the routine is just a simple JSR instruction, but the other two work lik
|
|||||||
``asmsub`` routines
|
``asmsub`` routines
|
||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
These are usually declarations of kernal (ROM) routines or low-level assembly only routines,
|
These are usually declarations of Kernal (ROM) routines or low-level assembly only routines,
|
||||||
that have their arguments solely passed into specific registers.
|
that have their arguments solely passed into specific registers.
|
||||||
Sometimes even via a processor status flag such as the Carry flag.
|
Sometimes even via a processor status flag such as the Carry flag.
|
||||||
Return values also via designated registers.
|
Return values also via designated registers.
|
||||||
@ -92,7 +92,7 @@ The 6502 CPU's X-register: off-limits
|
|||||||
|
|
||||||
Prog8 uses the cpu's X-register as a pointer in its internal expression evaluation stack.
|
Prog8 uses the cpu's X-register as a pointer in its internal expression evaluation stack.
|
||||||
When only writing code in Prog8, this is taken care of behind the scenes for you by the compiler.
|
When only writing code in Prog8, this is taken care of behind the scenes for you by the compiler.
|
||||||
However when you are including or linking with assembly routines or kernal/ROM calls that *do*
|
However when you are including or linking with assembly routines or Kernal/ROM calls that *do*
|
||||||
use the X register (either clobbering it internally, or using it as a parameter, or return value register),
|
use the X register (either clobbering it internally, or using it as a parameter, or return value register),
|
||||||
those calls will destroy Prog8's stack pointer and this will result in invalid calculations.
|
those calls will destroy Prog8's stack pointer and this will result in invalid calculations.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user