Monday 3 September 2018

To Swap or not to Swap that is the question.....

On changing a language which already has code written for it

Having written a few bits of code in M8, I'm beginning to wonder if I've made a mistake.  I've written a Console I/O module, a Text-loading module for debugging to easily load in Color text* and most of a colourising screen editor.

I originally changed the language design so that the "stack pushing" so to speak was manual ; so to calculate 2 + 3 you would do 2 , 3 +

I think perhaps for readability the old system worked better. This was based around the concept of a loader ; constants, load variables and load addresses (and nothing else) all did a A<->B swap prior to loading their value into A.

So 4, rather than being simply ld hl,4 , was ex de,hl ; ld hl,4.  This had a slight problem in that there was a tendency to produce too many ex de,hl instructions, but it did actually make the code look clearer. Current code seems to be full of commas and you can't really read it.

M8 , especially with this, really does look like FORTH. The only time it matters is when you get loops where you are manhandling two values, and you need to track what is in A and what is in B.

But even then, this is much simpler than remembering what is where on the stack.

Colouring

One thing I didn't mention ; this system has two compilers. The first is a cross compiler in Python, which already exists, which generates code from ASCII text that looks like FORTH : increment 1 + ; ; the other is an interactive one that will run on the actual target uses the color format increment 1 + ;

The interactive one is extensible in the way FORTH is, in that you can add new loops and so on ; to do this in the Python one you have to write them in Python

Platform

I can finally switch back to Linux :) Zesarux has now reached a stage where it is useable as a development target viz you can run Spectrum SNA files from the command line without going through 27 button presses each time.

The windows only CSpect emulator (these are the only two working Spectrum Next emulators) sort of works under Wine (the cursor keys don't seem to work ....) but it is the only one with a decent debugger.

No comments:

Post a Comment