Code generator for MSX

By franklin.jr

Supporter (6)

franklin.jr's picture

20-04-2021, 01:00

I'd like to show you an idea that originated in a WhatsApp group.

Supposing we can create a text editor - with the purpose of being a code generator for MSX - that will get MSX BASIC code as parameters, these instructions can be translated straight into other languages such as ASM, C and Pascal.

If - as an example to illustrate it - we want to draw a line, this editor could take the following parameters:

- machine (MSX 1, MSX 2, MSX 2+, MSX Turbo-R)
- screen (0, 1, 2...)
- from X1/Y1 to X2/Y2
- color C

... this code generator will take these parameters and automatically generate ASM code to draw this line, and this code can be either invoked from BASIC or as an ASM text file; other languages can be added as well. For example, a CLS instruction runs faster when it's translated into ASM and runs straight into memory. There are many possibilities, such as generate sprites, create functions, and so on.

For each line in this editor/generator we can have a drop-down list with all MSX BASIC instructions.

As people are already used to develop for MSX BASIC, this code generator will generate code for languages that are faster to run, circumventing speed limits imposed by MSX BASIC and its slow interpretation of the code. In case this idea raises interest from other communities of developers, code can be generated for other 8-bit machines such as Commodore, VIC, Apple, Amiga and so on, but at this moment our focus is on MSX.

Team is already organizing steps that will be followed, such as Github account, language to develop the interface (possibly Python or Ruby, but other languages can be discussed), first instructions that can be converted as they are simple and have no parameters such as CLS. Anyone who wants to join and contribute is welcome, so please have your say.

Regards, Franklin

Login or register to post comments

By AxelStone

Prophet (2932)

AxelStone's picture

20-04-2021, 08:40

Hello @franklin.jr, welcome to the forum. I think that your project is quite similar to Turbo BASIC, which automatically converts BASIC blocks into ASM blocks so it's much faster. Did you know about it? We also have Nestor Basic which's a very good extension for Turbo Basic, adding very interesting features.

Take a look at both of them.

By jltursan

Prophet (2480)

jltursan's picture

20-04-2021, 08:46

Not being MSX-BASIC based; but mostly C++, you can also find ccZ80++

BASIC compilers are always welcomed!

By wolf_

Ambassador_ (9858)

wolf_'s picture

20-04-2021, 10:25

I wonder how intelligent/efficient this could be for asm.

If your script would have:

PRINT "blah"
PRINT "blah"

(or any other high-level print command that covers the same load)

What, apart from a printing routine, would you get in asm?
txt001: db "blah",0
txt002: db "blah",0

Also, for-loops: would they be done by altering/lowering variables in memory locations, or with a quick DJNZ loop?

By Amaury Carvalho

Supporter (6)

Amaury Carvalho's picture

20-04-2021, 15:27

A project with similar idea is MSXBAS2ASM (but discontinued).

There's also MSXBAS2ROM, an experimental opensource cross plataform MSX BASIC compiler.

By franklin.jr

Supporter (6)

franklin.jr's picture

20-04-2021, 16:11

Thanks, I never heard about them before and will surely take a look.