How to rewrite a project from Pascal to C, or a macro-assembler for Intel 8080

Let’s look at the code:

BEGIN
   if (Hi(Code) == 0)
    BEGIN
     BAsmCode[0] = Lo(Code); CodeLen = 1;
     return True;
    END
   else if (MomCPU <= CPU1802)
    BEGIN
     WrError(1500);
     return False;
    END
   else
    BEGIN
     BAsmCode[0] = Hi(Code); BAsmCode[1] = Lo(Code); CodeLen = 2;
     return True;
    END
END

(grabbed from code1802.c).

Frankly, it is not easy to recognize the language. Of course, this is C but initially it was Pascal, and then the author had converted in to C trying to minimize the amount of changes.

The project is called “Macro-assembler AS”, by Alfred Arnold. I use it as an Intel 8080 macro-assembler available on Mac, Linux and Windows. Frankly I haven’t seen anything better so far.

As the author explains, the project was started in Turbo Pascal, but after Borland had abandoned the DOS version but free implementation of the modern Pascal didn’t exist yet, he decided to convert the sources into C and continue development in C. Despite of overall doubtfulness of such approach, to me, the author had managed it very well. The project hadn’t die as it usually happens with big projects after rewrite. But though I have cloned it for myself and started using successfully, I doubt that I want to contribute because it requires coding in this weird “Pascal on C steroids” dialect. Alas, this is inevitable due to that conversion, otherwise the project may turn into mess. If to surf amongst the sources of AS it is easy to find a lot of tricks like “how to make C to be Pascal”.

Nevertheless, all the best to Alfred with his great project. Again, the project moves forward and becomes better.

By the way, Alfred has a very cool collection of old hardware which makes me feel envy.


Disclaimer

Comments