2022-02-01 20:34:17 +00:00
.. _portingguide:
2021-12-30 22:57:54 +00:00
=============
Porting Guide
=============
Here is a guide for porting Prog8 to other compilation targets.
Answers to the questions below are used to configure the new target and supporting libraries.
2023-08-01 20:49:55 +00:00
.. note ::
The assembly code that prog8 generates is not suitable to be put into ROM. (It contains
embedded variables, and self-modifying code).
If the target system is designed to run programs from ROM, and has just a little bit of RAM
intended for variables, prog8 is likely not a feasible language for such a system right now.
2021-12-30 22:57:54 +00:00
CPU
---
2021-12-31 10:34:53 +00:00
#. 6502 or 65C02? (or strictly compatible with one of these)
#. can the **64tass** cross assembler create programs for the system? (if not, bad luck atm)
2021-12-30 22:57:54 +00:00
Memory Map
----------
2023-08-01 20:49:55 +00:00
Zeropage
========
2022-10-29 12:12:10 +00:00
#. *Absolute requirement:* Provide three times 2 consecutive bytes (i.e. three 16-bit pointers) in the zeropage that are free to use at all times.
#. Provide list of any additional free zeropage locations for a normal running system (BASIC + Kernal enabled)
#. Provide list of any additional free zeropage locations when BASIC is off, but floating point routines should still work
#. Provide list of any additional free zeropage locations when only the Kernal remains enabled
2021-12-30 22:57:54 +00:00
Only the three 16-bit pointers are absolutely required to be able to use prog8 on the system.
2022-10-29 12:12:10 +00:00
But more known available zeropage locations mean smaller and faster programs.
2021-12-30 22:57:54 +00:00
RAM, ROM, I/O
=============
#. what part(s) of the address space is RAM? What parts of the RAM can be used by user programs?
2022-02-22 21:43:14 +00:00
#. what is the usual starting memory address of programs?
2021-12-30 22:57:54 +00:00
#. what part(s) of the address space is ROM?
#. what part(s) of the address space is memory mapped I/O registers?
2023-02-22 21:48:45 +00:00
#. is there a block of "high ram" available (ram that is not the main ram used to load programs in) that could be used for variables?
2021-12-30 22:57:54 +00:00
#. is there a banking system? How does it work (how do you select Ram/Rom banks)? How is the default bank configuration set?
2023-08-01 20:49:55 +00:00
Note that prog8 itself has no notion of banking, but this knowledge may be required for proper system initialization.
2021-12-30 22:57:54 +00:00
2022-01-19 19:45:24 +00:00
Character encodings
-------------------
2022-10-29 12:07:04 +00:00
#. if not PETSCII or CBM screencodes: provide the primary character encoding table that the system uses (i.e. how is text represented in memory)
2022-01-19 19:45:24 +00:00
#. provide alternate character encodings (if any)
2022-02-01 20:34:17 +00:00
#. what are the system's standard character screen dimensions?
#. is there a screen character matrix directly accessible in Ram? What's it address? Same for color attributes if any.
2021-12-30 22:57:54 +00:00
ROM routines
------------
#. provide a list of the core ROM routines on the system, with names, addresses, and call signatures.
2022-10-28 23:25:54 +00:00
Ideally there are at least some routines to manipulate the screen and get some user input (clear, print text, print numbers, input strings from the keyboard)
2021-12-30 22:57:54 +00:00
Routines to initialize the system to a sane state and to do a warm reset are useful too.
The more the merrier.
Floating point
==============
2023-08-01 20:49:55 +00:00
Prog8 can support floating point math *if* the target system has floating point math routines in ROM. If that is the case:
2021-12-30 22:57:54 +00:00
#. what is the binary representation format of the floating point numbers? (how many bytes, how the bits are set up)
#. what are the valid minimum negative and maximum positive floating point values?
#. provide a list of the floating point math routines in ROM: name, address, call signature.
Support libraries
-----------------
The most important libraries are `` syslib `` and `` textio `` .
`` syslib `` *has* to provide several system level functions such as how to initialize the machine to a sane state,
and how to warm reset it, etc.
`` textio `` contains the text output and input routines, it's very welcome if they are implemented also for
2023-08-01 20:49:55 +00:00
the new target system. But not required.
2021-12-30 22:57:54 +00:00
There are several other support libraries that you may want to port (`` diskio `` , `` graphics `` to name a few).
2022-10-28 21:39:54 +00:00
Also of course if there are unique things available on the new target system, don't hesitate to provide
2021-12-30 22:57:54 +00:00
extensions to the `` syslib `` or perhaps a new special custom library altogether.