FAQ  •  Register  •  Login

6502.py , 6809.py, 68000.py, etc.

<<

nitrofurano

Posts: 349

Joined: Thu Sep 29, 2011 12:44 pm

Location: Porto, Portugal

Post Wed Sep 19, 2012 11:47 am

6502.py , 6809.py, 68000.py, etc.

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?
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Wed Sep 19, 2012 12:03 pm

Re: 6502.py , 6809.py, 68000.py, etc.

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...
<<

nitrofurano

Posts: 349

Joined: Thu Sep 29, 2011 12:44 pm

Location: Porto, Portugal

Post Wed Sep 19, 2012 2:34 pm

Re: 6502.py , 6809.py, 68000.py, etc.

Meanwhile, i were starting this 6502.py (far unacurated - i'm not that proficient on 6502) based on z80.py - http://pastebin.com/G2RJRF9N

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! :) ) - 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! :)

And thanks a lot for all your efforts! :)
<<

nitrofurano

Posts: 349

Joined: Thu Sep 29, 2011 12:44 pm

Location: Porto, Portugal

Post Sun Sep 23, 2012 5:08 pm

Re: 6502.py , 6809.py, 68000.py, etc.


Return to Wishlist

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO