Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
6502.py , 6809.py, 68000.py, etc.
#1
Since z80.py is the essential part of zxbasic-compiler that is used for reference when compiling the resulting .asm into binary, would be a good idea if we start to create similar code for 6502, 6809, 68000, etc., for expanding zxbasic-compiler to other 8bit/16bit platforms? would be this a good start?
Reply
#2
The approach for this is to use only one main executable, which loads the corresponding libraries. This is the way ZX Basic is designed. So you should use something like:
Code:
zxb.py --arch=<architecture name>
This way, you can produce an output for different architectures from a single compiler.
The compiler then loads the "backend" (the part of the compiler which translates from "Intermediate representation" to machine code of the target architecture), which should be, in these case, python modules like yours. This is not an easy task, though:
  • Target architecure might have a different CPU (e.g. other than Z80, like 68k)
  • Even if the target platform happens to have the same CPU the hardware and memory organization might be different. You will need to rewrite input/output (keyboard, cassete, screen, joystick) asm library routines (you can save time using the one provides by the BIOS/ROM or a prebooted OS, but this might introduce other problems, like Floating Point in ZX Basic being slower and requiring some fixed RAM positions, etc...)
  • To run in a target emulator/real machine, the output file format must be generated accordingly (thousands of them, completely different and VERY BAD documented).
So this is a titanic task. Even worse, as I started ZX BASIC as a toy compiler, some of these layers are not completely well designed. This is why I've thinking in rewriting some of them from scratch or even the compiler entirely. At the moment, only the zxbasm (the assembler) and zxbpp (the preprocessor) are completely independant and designed "correctly enough".

Other layers has too much interdependences with each others or with the target architecture (Speccy), which means that changing them is very hard without affecting the whole compiler. This is what I've been working out these days...
Reply
#3
Meanwhile, i were starting this 6502.py (far unacurated - i'm not that proficient on 6502) based on z80.py - <!-- m --><a class="postlink" href="http://pastebin.com/G2RJRF9N">http://pastebin.com/G2RJRF9N</a><!-- m -->

Ss i can imagine, the rewriting process of zxbasic-compiler is to making it a kind of compiler to z80 only, and then to machines based on that like zx-spectrum, sms, mc1000, msx (still unsuccesfully), amstrad-cpc, pacman-namco (started this as mentioned on another thread, maybe i'm struggling on stack point, interrupts, and so on... - btw, i'm really curious about how simply we can make stuff for arcade machines using zxbasic-compiler! Smile ) - and then start it to other processors (like 6502) only, and then the machines based on these processors?

Thanks to Haroldo O.P (sms port of zxbasic-compiler), he let me know about wla-dx, which made a good effort on targetting a good ammount of different hardware, so i'm also dreaming on see this happening on zxbasic-compiler as well! Smile

And thanks a lot for all your efforts! Smile
Reply
#4
i started this:
- <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:68000.py">http://www.boriel.com/wiki/en/index.php ... C:68000.py</a><!-- m -->
- <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:6502.py">http://www.boriel.com/wiki/en/index.php ... IC:6502.py</a><!-- m -->
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)