Code generator for MSX

Por franklin.jr

Supporter (6)

Imagen del franklin.jr

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 sesión o register para postear comentarios

Por AxelStone

Prophet (3176)

Imagen del AxelStone

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.

Por jltursan

Prophet (2619)

Imagen del jltursan

20-04-2021, 08:46

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

BASIC compilers are always welcomed!

Por wolf_

Ambassador_ (10035)

Imagen del wolf_

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?

Por Amaury Carvalho

Resident (36)

Imagen del Amaury Carvalho

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.

Por franklin.jr

Supporter (6)

Imagen del franklin.jr

20-04-2021, 16:11

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

Por DanySoft

Champion (452)

Imagen del DanySoft

02-06-2022, 21:48

Hi, after running this program with ASCII file, it threw a lot of errors! Evil

It has been released since 2019 and never updated! Therefore I noticed that in the program there were already many functions such as CLEAR, CLOAD, SPRITE, etc ....
But if you write this command and an error appears!

file: prova.BAS
10 SCREEN 1,2:CLS
msxbas2asm -d prova.bas [RETURN]

MSXBAS2ASM - MSX BASIC TO Z80 ASSEMBLY CONVERTER
Created by Amaury Carvalho (2019)
Version: 0.2.1

Converting prova.bas to prova.asm ...
(1) Doing lexical analysis...
Displaying lexical analysis:
10 SCREEN 1,2:cls
--> Literal Numeric: 10
--> Keyword : SCREEN
--> Literal Numeric: 1
--> Separator : ,
--> Literal Numeric: 2
--> Separator : :
--> Keyword : CLS


(2) Doing syntactic analysis...
10 SCREEN 1,2:cls
--> Literal Numeric: 10
--> Keyword : SCREEN
--> Literal Numeric: 1
--> Separator : ,
--> Literal Numeric: 2
--> Separator : :
--> Keyword : CLS
Invalid number of parameters
ERROR: Syntax error at line 1

So what does this name "MSXBAS2ASM" mean ????
One thing is certain: {MOD: be kind! no bullying or insulting others!} It never compiles all functions but only one or two:
if you write SCREEN 1: NO ERROR!
if you write SCREEN 1,2: ERROR !!!!!!!!!!!!
So what do these error messages mean? I'm sorry, but I don't like this program or future updates.

But in my opinion, {MOD: be kind!}
DanySoft