by denton-scratch · 7y ago · 0 comments
I never tried to write a Pascal compiler, but I think it is pretty easy - I wrote a source-code debugger for one implementation of the language, which I think involved reverse-engineering the targeted compiler (can't really remember - too long ago). I had never before encountered a source-code debugger for any language at all (other than 8086 Assembler, which only just counts).
I just thought it was a cool idea, and one that would help me in my work. It was a "hobby" task, and I had a full-time job, a young wife, and kids. It can't have taken more than a handful of weekends.
It looks like this one has a lot of constraints for easy 6502 code generation, like only allowing 8-bit variables in a FOR loop.
The problem is you really wouldn't write code for these machines the same way you write code for a bigger machine. Not least because most of them had so little memory that keeping track of an assembly program that size was not really a big deal. A lot of C64 demos were written in machine code monitors with no labels, no macros, no variable declarations, that just assembled/disassembled line by line, and saved by just saving the memory regions to disk - no separate source-code. It was a revelation to get a proper assembler...
But that meant self-modifying code (often seen used for 16 bit loops...) and effectively global variables all over the place (= data in fixed memory locations...) was extremely common as well. Trying to shoehorn that into a language like Pascal means basically writing everything in the main block and not call any functions, and even then you're unable to use most of the dirtier tricks..
Pascal was an approachable language and was exactly what I needed at the time to push forward, revisiting C in my highschool years. I built dumb Dragon Warrior clones, homework helpers, etc. It was super readable for me too.
Of course I look back with rose tinted glasses on but Pascal was a huge part of my programming growth - I will always remember it fondly!!
Timex 2068 Basic, Z80, GW-Basic, Turbo Basic, 80x86 and then came to learn Turbo Pascal (started with 4.0 and did all of them up to Delphi 2).
Thanks to this path I got to learn systems programming in high level mostly safe languages, modules, OOP and my very first framework experiences, Turbo Vision (OWL, VCL as well).
For me this was a very lucky path, because I never got tainted that C and C++ were the only God sent programming languages for systems programming.
And best of all, I never had any issues to deal with pointers in C and C++.
I remember being annoyed initially because i had to declare my variables before using them, but it was worth it since unlike GW-BASIC, Turbo Pascal was able to create EXE files (which was the only reason i decided to use it :-P).
How do you know that?
Most of the people I've worked with in the last decade have favoured weakly-typed languages, and Pascal in particular has been a target for ridicule (among the small proportion of my colleagues who have ever looked at the language).
The version of Pascal on which I was raised was an Intel Pascal; I can't find a link just now. It was definitely not Turbo Pascal, which I think was Borland. But both versions had this restriction on the size of a compiled module, complete with stack and data - 64K, the size of a 8086 memory "segment". These 8086 vices have genes that survive in Intel architectures to the present day.
I also did some work with PL/M ("Programming Language for Microprocessors", I think), a much nicer language than Pascal, targeted at those same 1980s 8-bit chips. Pascal was invented as a teaching language; PL/M was an IBM product designed for production work - a cut-down version of PL/1, which was a heavy-duty mainframe language. Pascal and PL/M are similar, and they're all children of ALGOL.
I taught college classes using Turbo Pascal; I had barely any experience with that compiler, and the students were a nightmare (it was not by any measure a "top school"). I faked it, and I got away with it.