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 »

Fruitcake wrote: Mon Mar 21, 2022 11:53 pm The other option is to poke the $76 with $00, which is a NOP instruction and so does nothing apart from delay for 4 clock cycles. But your solution is preferable to make the code run as efficiently as possible.
But a NOP would cause possible errors when trying to list the REM statements from what I gleaned above...and the HALT doesn't seem to impact the game since running in FAST doesn't work when that issue is fixed. But the little BASIC program to find the address worked pretty well in any case.
Fruitcake
Posts: 346
Joined: Wed Sep 01, 2010 10:53 pm

Re: Using MCoder2 in EightyOne

Post by Fruitcake »

bwinkel67 wrote: Tue Mar 22, 2022 2:43 am But a NOP would cause possible errors when trying to list the REM statements from what I gleaned above...
If NOPs replace the two $76 bytes at the start of a REM then they won't necessarily cause problems. The code for a NOP instruction is 0. The character displayed for a code of 0 is a space. So you'll simply end up with two spaces. But it will mean all the machine code after them will become visible and that could cause a lock up if the line is listed.

The approach you are taking of finding and correcting the call address is the best solution.
christoph
Posts: 14
Joined: Sun Mar 27, 2022 1:32 pm
Location: Oschersleben

Re: Using MCoder2 in EightyOne

Post by christoph »

Fruitcake wrote: Mon Mar 21, 2022 11:04 pm Aside from the original MCODER I, I'm also aware of another compiler for the ZX81. It was made by Silversoft but I don't have any direct experience of it so don't know how it compares. It's available online but sadly no instructions sheet for it:
http://www.zx81stuff.org.uk/zx81/tape/ZXCompiler

I suspect MCODER II is superior, but perhaps someone else has used it and can comment on how it compares.
I tried to start this compiler once and the impressive thing maybe is, that it runs in BASIC (!)
But sadly i never got to compile a program with it. Even a simple PRINT "HELLO WORLD" did not really work .. :( Maybe we should start a new thread trying to get it to run or finding someone, who actually has the Manual (?) also there is the Z99-Compiler, which i would like to try but there are literally no resources...

Back to MCODER II, i wrote my game especially in mind to run under MCODER II and after you understand the internals it works flawlessly (except this one crazy bug with printing chars rather than numbers fixed by Siggi). A simple tip of mine: If you want an Intro for your game, just compile the game itself and then deleting the basic code, to then append your intro in BASIC. Also some really neat idea is to simulate DATA READ and RESTORE by either using a complicated String method or to use REM Statements (but you need to know where this statement would lie in BASIC and even worse, you can't delete the BASIC Code).
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Using MCoder2 in EightyOne

Post by bwinkel67 »

I had videoed myself back in spring when I did a multi-step compile of my Elite game...it's live now on my channel. I tried to do it the way I would have back in the mid 80's when I only had a cassette recorder, a ZX81 printer, and a 16K RAM pack. The only difference is that instead of saving to a cassette, I captured the intermediate files on my PC, which is a bit more robust (i.e. no bad tape loads) and then later I go back to the PC and demonstrate what was actually going on.

https://www.youtube.com/watch?v=rRtalbnJP5w

So it was very possible back then to use MCODER II to create compiled code bigger than a few K and it actually was pretty straightforward. I was even more impressed with how it handled itself in multi-step compiles. A really well thought out program. Maybe one of the best on that platform IMHO.

I also briefly outline how to do it if you have 48K of memory (just highlighting what Fruitkake had shared with me). That mechanism is a whole lot simpler, obviously, but my goal was to see how it would have gone had I owned MCODER II myself as a kid and wanted to compile some of my own BASIC code. It definitely is very capable to do it in multiple steps.

One of the things I tried was compiling like half a dozen small modules in sequence (not in this video), and integrating them into one program (that was one attempt at a compiled Elite) and that also worked really well. So I could really see someone creating small routines in BASIC, compiling them, and then using them in other parts of the main program. All you had to do is organize yourself a bit at the start so you planned which module you'd compile first. I think that's what I really liked about the 1980's, you had to think about what you were doing when programming, even in BASIC. Today you can just try and see if it works and throw it out with little invested time. Obviously with emulators you can just max out the RAM and do it in a single compile, but not many folks likely had more than 16K of RAM back in the day.
Post Reply