Using MCoder2 in EightyOne

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Using MCoder2 in EightyOne

Post by bwinkel67 »

mrtinb wrote: Sat Feb 19, 2022 4:15 am The documentation says there is no compilation past STOP, so STOP has a different meaning than in Basic.

Maybe instead of
500 STOP
should be
500 GOTO 9999
9999 STOP
Ah, thank you...that may be the issue.
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Using MCoder2 in EightyOne

Post by bwinkel67 »

mrtinb wrote: Sat Feb 19, 2022 4:15 am The documentation says there is no compilation past STOP, so STOP has a different meaning than in Basic.

Maybe instead of
500 STOP
should be
500 GOTO 9999
9999 STOP
Just tried it and yup, that did the trick. They ought to have left that feature out, very confusing :-/
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Using MCoder2 in EightyOne

Post by bwinkel67 »

A few more questions on MCODER2. So I've been working with it and getting a bit more familiar with how it works. One oddity, I cannot get OR operations to work within an IF. Everything works fine with AND but not with OR. Any idea why?

Also, in the EightyOne emulator I'm trying to compile an 8K program, and it's just too big for MCODER2 to work in 16K of memory. I think the sweet spot is half that (at 4K) as I've played with pruning it and having some success. When I set up EightyOne in 32K of memory, MCODER2 doesn't seem to like that. Can it only run in 16K? How can I get an 8K program to compile? Is this an EightyOne issue?

I've managed to tease out all the faults in the BASIC: changed all OR if's to AND and reversed logic, got rid of boolean operators in assignments (LET), that sort of thing. So I'm close but can't get past the memory limit. So any help would be appreciated. Note that I have played around with the option that lets you compile two parts separately and that works, but those two parts don't share any information. So you can just write stand-alone chunks that way (i.e. maybe have one piece that just creates the screen display and the second piece lives within it but doesn't interact) but no easy way to piece them together.

I've also played with the RAND USER 17287 feature that lets you put code anywhere you want. Maybe you could create your own REM statement and put it there. What's frustrating is that with a 5K program, with MCODER2 being 4K, and the compiled version of the BASIC taking less than 4K, it still stops because of lack of memory.
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Using MCoder2 in EightyOne

Post by mrtinb »

You need to take out subroutines of the program, and get them to work. And in your main program call the routines with USR.

Since you’ll need tools in the background to merge the code at last, the program needs to be in smaller pieces and fused together finally.

The manual also describes how.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Using MCoder2 in EightyOne

Post by bwinkel67 »

I've played around with multiple pieces and got it to work...but it cannot share information between them via variables. I suppose you could poke data into some memory and peek it back, but that's a pain. Also, wasn't sure if you could have more than 2 pieces since you poke the REM and change it form 2 to 1 (so MCODER uses 2 as it's default). What happens with the 3rd piece of code?

I did see one person (Steven Reid) claim that he poked RAMTOP and got MCODER2 to work in 32K of memory but when I tried it, still a no.
https://www.reids4fun.com/385/et-redux
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Using MCoder2 in EightyOne

Post by mrtinb »

I guest PEEK and POKE is the solution. I haven't tried it, but the manual state it is possible.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
XavSnap
Posts: 1941
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Using MCoder2 in EightyOne

Post by XavSnap »

Better to call André*** to speedup the code...
;)

Mcoder is running under 16k, never 32k.

The RAMTOP limit hang the basic code to 10k... and the Mcoder2 compiler don't understand extended Zx81 Basic.

Open a topic to try to speedup the original "ET" code.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Using MCoder2 in EightyOne

Post by mrtinb »

Even André***’s Basic tricks won’t make games fast. It will only make them playable.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Using MCoder2 in EightyOne

Post by bwinkel67 »

I think I have gotten the main loop down to a size it will compile (4087). So now I have about a half dozen routines of various size I will try and compile separately and then merge the whole thing. One trick in the main is to add fake calls (RAND USR 11111, etc), then after compiling it and then compiling the next part and finding it's address, you go back and recompile everything and change the 11111 to the correct address. That seems to be the way to do it though I'm not sure if I'll run into difficulties with size when I try to compile the smaller chunks.
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Using MCoder2 in EightyOne

Post by mrtinb »

It seem like you are getting a hang of it. Good luck.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
Post Reply