equi

A self-descriptive stack-based PC platform
git clone git://git.luxferre.top/equi.git
Log | Files | Refs | README | LICENSE

commit 62b84f735b96b97207d213a29bcce6678031a86e
parent 152744e84aec2ea77b46e5da967f893d276933ce
Author: Luxferre <lux@ferre>
Date:   Sat,  6 Aug 2022 12:14:23 +0300

Described how we would build Equi for Apple II and started to debug the process

Diffstat:
Mequi.c | 11++++++++---
Mequi.md | 22+++++++++++++++++-----
Aplatform-build-tools/apple2/ac.jar | 0
Aplatform-build-tools/apple2/tpl.dsk | 0
4 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/equi.c b/equi.c @@ -27,6 +27,8 @@ #include <conio.h> #else +#define cgetc() (fgetc(stdin)) + #endif /* Definitions section */ @@ -56,12 +58,12 @@ /* Command buffer start address */ #ifndef CMD_BUF_START -#define CMD_BUF_START 0x5000 +#define CMD_BUF_START 0x3b80 #endif /* Command buffer size in bytes */ #ifndef CMD_BUF_SIZE -#define CMD_BUF_SIZE 0x5700 +#define CMD_BUF_SIZE 15600 #endif /* Some necessary constants and offsets derived from the above values */ @@ -129,7 +131,10 @@ int main(int argc, char* argv[]) { ram.cmd_start = CMD_BUF_START; ram.cmd_size = CMD_BUF_SIZE; - printf("0x%X", ram.cmd_size); + printf("Equi command buffer: 0x%X\n", ram.cmd_size); + + cgetc(); + return 0; } diff --git a/equi.md b/equi.md @@ -43,10 +43,10 @@ Address range|Size (bytes)|Purpose 0x0230-0x0231|2 |Command buffer size (set to 0x5700 by default) 0x0232-0x02ff|206 |Reserved for internal usage by the interpreter and future extensions 0x0300-0x22ff|8192 |Compilation lookup table (CLT) - up to 1024 compiled words (6 bytes for literal + 2 bytes for CBP address each) by default -0x2300-0x4fff|11520 |General purpose data (GPD) area -0x5000-0xa6ff|22272 |Command buffer area +0x2300-0x3b7f|6272 |General purpose data (GPD) area +0x3b80-0x7dff|17024 |Command buffer area -This layout has been carefully chosen to achieve maximum portability: so that full a Equi system could fit inside the user area of Apple II's space between (physical) 0x0800 and 0xbf00 addresses, while still leaving 4096 bytes for the interpreter itself with all necessary peripheral drivers if required so. As such, Apple II equipped with full 48K RAM is supposedly the lowest spec possible target system Equi could run on with the default virtual RAM configuration. +This layout has been carefully chosen to achieve maximum portability: so that full a Equi system could fit inside the user area of Apple II's space between (physical) 0x0800 and 0x9600 addresses, while still leaving 4096 bytes for the interpreter itself with all necessary peripheral drivers if required so. As such, Apple II equipped with full 48K RAM is supposedly the lowest spec possible target system Equi could run on with the default virtual RAM configuration. To preserve runtime integrity, Equi implementations are allowed to (but not required to) restrict all writes to the addresses below the GPD area start (0x2300 by default). On systems with less/more RAM where CLT and/or GPD and/or command buffer areas are smaller/larger, the values at 0x0227, 0x0229 and 0x022b must be populated accordingly. You don't need to fill in the sizes of CLT and GPD areas since they are calculated automatically from the specified offsets, you only need to specify how big your command buffer is to avoid any writes outside the user area. @@ -148,6 +148,7 @@ Build with default parameters (you can override any of the above constants with ``` cc -std=c89 -Os -o equi equi.c [-DSTACK_SIZE=... ...] +strip equi ``` ### Building with TCC (TinyCC, Tiny C Compiler) @@ -160,8 +161,19 @@ tcc -std=c89 -o equi equi.c [-DSTACK_SIZE=... ...] ### Building with CC65 (for 6502-based targets) -This is where things start to get interesting, as we need to specify the exact target machine for CC65. For now, Equi reference implementation is only being tested for Apple II, so the commands to build it would be: +This is where things start to get interesting, as we need to specify the exact target machine for CC65 and perform certain target-dependent post-build manipulation. For now, Equi reference implementation is only being tested for Apple II, so the command to build it would be: ``` - cc65 --standard c89 -O -Os -t apple2 -o equi.s equi.c +cl65 --standard c89 -O -Os -t apple2 -o equi.apple2 equi.c ``` + +Then, if there are no compiler/linker errors, we can proceed with building the image (assuming we're using Java and AppleCommander with an empty 140K ProDOS 8 image bundled in the repo for image assembly): + +``` +cp platform-build-tools/apple2/tpl.dsk equi.dsk +java -jar platform-build-tools/apple2/ac.jar -p equi.dsk equi.system sys < $(cl65 --print-target-path)/apple2/util/loader.system +java -jar platform-build-tools/apple2/ac.jar -as equi.dsk equi bin < equi.apple2 +``` + +This will build a bootable disk image with Equi for Apple II that can be tested on emulators or real hardware. + diff --git a/platform-build-tools/apple2/ac.jar b/platform-build-tools/apple2/ac.jar Binary files differ. diff --git a/platform-build-tools/apple2/tpl.dsk b/platform-build-tools/apple2/tpl.dsk Binary files differ.