From Basic to ROM

Página 2/2
1 |

Por PingPong

Prophet (3793)

Imagen del PingPong

09-02-2009, 21:38

cesco: in either situation, 'C' or asm you can get a rom file

Por NYYRIKKI

Enlighted (5889)

Imagen del NYYRIKKI

09-02-2009, 22:32

@cesco
Just use X-BASIC (or Nestor Basic, if you need extra features) It generates quite a well optimized ML from MSX-BASIC.

NestorPreTer also does pretty much same as your "toy".

*click*

Por cesco

Champion (453)

Imagen del cesco

09-02-2009, 22:48

Yes, but NestorBasic AFAIK works only on MSX2

Por NYYRIKKI

Enlighted (5889)

Imagen del NYYRIKKI

09-02-2009, 23:15

X-BASIC "works" also on MSX1... at least somehow... If you try to do some MSX2 specific stuff, you'll propably cause crash.

Por Metalion

Paragon (1451)

Imagen del Metalion

10-02-2009, 09:12

This is not exactly a compiler, it's something simpler. A true Basic compiler would involve the conversion of every single line of code in its assembly equivalent.

What I'm proposing here is just to "beautify" the code, introducing some classic constructors from the Basic Language that weren't allowed in the original MSX Basic, and then "speed up" some time-critical portions of the code with the injection of assembly routines. Something that is thousand times simpler than a real compiler.
Sorry but I just don't get it ...

If you want to work within a ROM file, you have to have a full machine code program, because the 2nd page of the main ROM (which is needed to interpret the BASIC tokens) is switched off. Now there is a solution to that : you just need to jump from the ROM start to a higher address and from there switch on again the 2nd page of the main ROM. But you still would need a big portion of code which would manage your semi-compiled source, in order to either interpret the BASIC tokens or execute the machine code routines.

It means two things :

1 - The ROM structure is useless, you do not gain any memory space from it
2 - You lose some RAM to your semi-compiled source interpreter

So in the end, I do not see a big advantage of your solution over a simple BASIC compiler.

Por monant

Resident (48)

Imagen del monant

15-02-2009, 23:17

on a magazine for commodore 64 once I saw a game written using a powerful basic compiler which allowed to easily mix basic and assembly .

for example on the msx it would work like this <

10 for i=0 to 10 : call &hf000 : xor a
20 print "hallo" : ld a,255 : ld b,a
30 next i
>

i know that x-basic allows the inline function ( you have to write hex code directly)

i dont know if such a thing exists for msxQuestionSmile

Por RetroTechie

Paragon (1563)

Imagen del RetroTechie

16-02-2009, 03:48

If you want to work within a ROM file, you have to have a full machine code program, because the 2nd page of the main ROM (which is needed to interpret the BASIC tokens) is switched off.

Sorry, but that isn't true. BASIC programs in ROM work just fine. Just read the MSX Technical Databook about what you can put in a cartridge, and how the MSX finds it. BASIC programs in a cartridge is provided for in the spec...

Now: basically that means nothing Eek! But I tried it once, and it works fine! Procedure is something like this:

  • Change some system variables to make BASIC program start at, say, 8010h, and variables / free area all in page 3 (C000h and above)
  • Load BASIC program
  • Optional: run BASIC program and exercise as many code paths as possible. This will make the BASIC interpreter turn line numbers into memory addresses, and speed up execution when the program is run from ROM
  • Save BASIC program as a .BIN file
  • Use disk editor to change some bytes at the start of that file
  • Blow binary data into an EPROM or something
  • Reset MSX with that inserted as a cartridge

I can tell you: no problem, it actually works! Pages 0 & 1 (0-7FFFh) are taken by BIOS and BASIC interpreter, BASIC program in ROM takes up page 2, and variables / RAM fills page 3 (so less space for arrays and such). You can't edit the BASIC program then, and a system variable gets set that makes CTRL-STOP not work. On the plus side: mixing BASIC and machine code should be easy this way.

You want a simple recipe to try? Sorry, too much work Tongue Hint: an external RAM cartridge with write-protect switch is very helpful. Also emulators may make experimentation with this easy. One way or the other: BASIC programs in ROM definitely work!

Por Metalion

Paragon (1451)

Imagen del Metalion

16-02-2009, 10:55

Sorry, but that isn't true. BASIC programs in ROM work just fine
Yes, of course you're right, and I hinted at that in my post, altough I didn't know exactly how it worked.
What I meant is that you can't have a ROM in $4000 - $BFFF unless you use machine code.

Página 2/2
1 |