I've put this off long enough!
Here is version 1.0 of Pascal-iSh, a p-code Pascal compiler hosted on the Commander X16 and written in Prog8.
Previous versions were posted in the WIP section and while in some sense, it is still a work in progress and probably
will be for the foreseeable future, everything is working now, at least to some degree.
The name, Pascal-iSh, is a pun. This compiler is a conversion/adaptation of Pascal-S, written by Nicklaus Wirth, back in
the 1970's for use in the classroom, by students...hence the -S. This programming system is non-standard Pascal,
hence the -iSh. That it works at all, is something that I'm happy with, that it doesn't quite work the way it's supposed
to, is something that is frustrating and attributable to my shortcomings as a programmer, but I look at this as
idiosyncrasies, these are, to my view, minor issues. Another aspect is how I have added other features/capabilities,
which do not really adhere to any ISO standards....something that matters to me, not at all. It is a single pass
compiler that relies heavily on recursion, I have seen one subroutine get to 8 levels deep. I have yet to completely
tame this in Prog8, which does not support recursion natively.
This is basically a 'can I do it?' project. If anyone finds it useful....great. I don't expect that many....any, will adopt it
as a their method of programming the X16, but some might find it interesting to 'putz' around with. It does provide
access to the X16 Kernal and thus most of the X16's capabilities. It also provides the means to insert user created m/l
routines in a manner similar to BASIC's read/data/sys methodology. Only signed integers, characters and Boolean types
are natively supported and all occupy 2 bytes in memory, this was the original design and as much as I'd like to change
it, it's beyond my capability. Real numbers are possible, but, while I have included a demo program, further
development is needed for it to be of any real use. Other user TYPES are also possible.
There is a document included in the zip file that is part 'about' and part manual. The Pascal Language is better
documented elsewhere, but I go over some of the specifics to this rendition.
The original Pascal source code is here:
http://pascal.hansotten.com/uploads/pas ... Pascal.pas
with the exception of the code for 'for loops', which was omitted, but included in a text book written by the translator
(to Turbo Pascal), as an answer to questions in the chapter on the compiler, which I managed to obtain. This version
does compile with minimal fuss, with Free Pascal, which was the only way that I was able to get any of this working, by
comparing output from it, to my version!
Pascal-iSh V1.0
Re: Pascal-iSh V1.0
This is great! Im a language fan, so Ill definitely be messing with it and checking out the code.
thanks!
thanks!
Re: Pascal-iSh V1.0
Here is another piece for using floats, should anyone actually want/need to use floats; ASCII to float conversion. The ROM routine to do this can't be used, since the compiler and or interpreter, stomps all over the zero page locations that the BASIC routine depends on. Demonstration program attached. It works, except when it doesn't , which results in being kicked into the monitor. Mostly it works, perhaps I'll find the bug.
Bug found (more may lurk ), updated attachment. It appears that floats and their pointers need to be global. I'll see if I can figure that out.
Third time is a charm! New version of atoftest.pas attached.
Bug found (more may lurk ), updated attachment. It appears that floats and their pointers need to be global. I'll see if I can figure that out.
Third time is a charm! New version of atoftest.pas attached.
- Attachments
-
- ATOFTEST4.zip
- (2.41 KiB) Downloaded 65 times
Re: Pascal-iSh V1.0
In working on the test program in the previous post, I discovered....re-discovered that 'OR' was generating a syntax error. That is now fixed. Please download the new version of the compiler: V1.0.1.
Re: Pascal-iSh V1.0
A few days ago I noticed Tony (AHENRY3068) talking about a program of his that he was converting from BASIC to XC=BASIC, which is a compiled BASIC. After runnning the program, which is called Mystify, I remembered that this was...an old Windows screen saver...I think. What version of Windows I don't remember, but I thought this would make a nice project for Pascal-ish. So, I took his original BASIC version and converted it to Pascal-iSh. I thought this would be straightforward, it was and it wasn't. It took several days to get it to run and then another few to get it to work. I still don't understand a difference in behaviour from Tony's program, namely a delay when the number of elements to draw, exceeds a certain number, which may be related to the fact that my arrays need to be twice as big as I calculated that are needed. I'll probably figure out my miscalcualtion at some point....whatever it turns out to be. Another oddity is that this program doesn't seem to run correctly when loaded with 'p-run'. Another bug to figure out! Anyway, here is my interpretation of Mystify....I call it Mesmerize. Needless to say, the more line segments you ask for, the slower it runs. Make sure you are using version 1.0.1 of the compiler, since I'm using OR statements here.
Here is an update, version 3 of Mesmerize, with some further refinements and is p-run safe. Probably the final version.
Here is an update, version 3 of Mesmerize, with some further refinements and is p-run safe. Probably the final version.
- Attachments
-
- mesmerize.jpg (132.71 KiB) Viewed 1554 times
Last edited by yock1960 on Thu Jun 13, 2024 4:25 pm, edited 2 times in total.
Re: Pascal-iSh V1.0
For anyone with a 65816 CPU installed or anyone wanting to try this out in the emulator (V47 and higher) with the -c816 option, here is the version of the interpreter for you. This will give a bit of a boost, not a tremendous amount...maybe 15%...I forget, but every little bit helps! I haven't messed with this since April, so, while it should work with most of everything I've written...I may have forgotten some change I've made...