Convert a Basic program to Rom file easly

Page 2/2
1 |

By TomXP411

Supporter (8)

TomXP411's picture

25-02-2020, 20:07

Is there a BASIC compiler for MSX? It might make more sense to compile the programs to COM files, then port that over to a ROM.

Never mind. It looks like BASCOM didn't make it to MSX. It's an excellent CP/M BASIC compiler, and it probably formed the core of QuickBASIC on PC... but unless you are using text-only programs, that's not the best option.

Now I'm thinking of modifying my BASIC editor to transcode BASIC to c code... where it can then be compiled (and eventually assembled.)

By spacemoai1973

Ambassador (0)

spacemoai1973's picture

25-02-2020, 20:07

There are various compilers for MSX-BASIC, but none of them are 100% compatible with regular MSX-BASIC.
For ROM cartridges, nothing needs to be "ported" over. As long as the program is small enough to run on 16K RAM MSX computers, the MSX BIOS has native support for running BASIC programs from ROM.

By TomXP411

Supporter (8)

TomXP411's picture

25-02-2020, 20:09

Thanks. I'm new to MSX, so I'm totally unfamiliar with the system, aside from its similarity to DOS and CP/M. (It even runs CP/M software, which is super handy.)

By tfh

Prophet (3255)

tfh's picture

02-03-2020, 12:18

Well, that worked quite nicely Smile
It would be nice if I could also hide the listing. I tried ending the BASIC program with NEW, but as a result the whole program kept on looping.

By gdx

Enlighted (5812)

gdx's picture

03-03-2021, 01:37

The link I gave above is no longer valid and I did not indicate the method to make a Rom with a program in Basic larger than 16Kb. The method is the same but we must add the page 4000h~7FFFh to the rom in which there is the part of the program which exceeds and a small machine language program to copy the missing part to RAM at C000h.
For this, the page 4000h~7FFFh must also have a header.

Here is what it gives in hexadecimal (header + the machine language copy program):

00000h: 42 42 30 40 00 00 00 00 00 00 00 00 00 00 00 00 00
00010h: E5 D5 C5 21 40 40 11 00 C0 01 XX XX ED B0 C1 D1 E1
00020h: C9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

XX XX is the length of the part of the BASIC program to be added. (eg. 00 04 for 1024 bytes)
Then add your BASIC program part at 00030h and fill the rest with 00 or FF up to 3FFFh to make a 32kB file altogether.

By MagicBox

Master (208)

MagicBox's picture

28-08-2022, 00:27

Another useful tip and I am not sure if this goes for all basic implementations or just the Philips basic implementation but...

The start of a basic program stored in &HF676 points towards well, the start of the basic program area. But there is a catch: At the given address -1 (minus 1) the value must be zero, otherwise attempting to run or attempting to 'new' will fail with a syntax error. When BASIC starts on a machine with 32KB, and the first RAM location is &H8000, the pointer in &HF676 will contain &H8001, where location &H8000 contains a 0. When you want to relocate the Basic program area to the 3rd page, you'll have to set &HF676 to &HC001 and set &HC000 to 0. Setting it to &HC000 works as well most of the time, but that's because &HBFFF contains a 0. When it does not, you'll get the syntax error upon a run or new.

Page 2/2
1 |