NewOPL
Posted: Sun Sep 29, 2024 7:07 am
I thought I'd start a topic to put progress on the NewOPL into.
The latest version:
https://github.com/blackjetrock/newopl
has just run example 4 in the 'Language' section of the technical manual.
This doesn't mean it's nearly finished, as the code implements only what is needed to run this example. It does, however:
Load procedure XXX onto a stack
Execute procedure XXX which itself:
Loads procedure EX4 onto the stack as well
Executes procedure EX4 which
Writes a value to global J$ (which is defined in XXX, so the stack frames have to be traversed to find J$)
Exits and the stack is unwinds
XXX continues and also exits
The OPL:
This involves quite a lot of stack manipulation and also procedure loading. This is all quite complicated and I now know more about it than I ever thought I would.
The code also runs the original QCodes. I translated the OPL for the example in Jape and the executables on Linux run those files unchanged. The stack also matches the example almost exactly (there are some differences which I think are either typos or changes in code from when the example was made to the translator I used). So it's pretty much byte compatible.
If you want to run it (it dumps a lot of debug at the moment), then clone the newopl repo then:
this will build the executables and then run example 4. XXX.OB3 is the example procedure. It loads from the file system at the moment and will load the next procedure as required. The output is debug messages and machine states at various stages of execution. The code is fairly tidy.
the result is fairly uninteresting, but correct:
That's an empty stack with a floating point zero on it. At least I'm pretty sure that's correct.
I have arranged the code so it works on 'machines'. A machine is an OPL runtime, I did this so you could run multiple machines at once in the future without too much work...
There's lots to do, but the core of the runtime (loading procedures and executing qcodes) is largely there. Lots more qcodes to implement...
The latest version:
https://github.com/blackjetrock/newopl
has just run example 4 in the 'Language' section of the technical manual.
This doesn't mean it's nearly finished, as the code implements only what is needed to run this example. It does, however:
Load procedure XXX onto a stack
Execute procedure XXX which itself:
Loads procedure EX4 onto the stack as well
Executes procedure EX4 which
Writes a value to global J$ (which is defined in XXX, so the stack frames have to be traversed to find J$)
Exits and the stack is unwinds
XXX continues and also exits
The OPL:
Code: Select all
XXX:
GLOBAL J$(3)
EX4:("RST")
Code: Select all
EX4:(PPP$)
LOCAL A$(5)
GLOBAL B,C%(3),D$(5)
J$=PPP$
The code also runs the original QCodes. I translated the OPL for the example in Jape and the executables on Linux run those files unchanged. The stack also matches the example almost exactly (there are some differences which I think are either typos or changes in code from when the example was made to the translator I used). So it's pretty much byte compatible.
If you want to run it (it dumps a lot of debug at the moment), then clone the newopl repo then:
Code: Select all
cd newopl/pc
./m
./newopl_exec ../examples/XXX.OB3
the result is fairly uninteresting, but correct:
Code: Select all
Stack reset
push_machine_8:pushing 00 to 3EFF
push_machine_8:pushing 00 to 3EFE
push_machine_8:pushing 00 to 3EFD
push_machine_8:pushing 00 to 3EFC
push_machine_8:pushing 00 to 3EFB
push_machine_8:pushing 00 to 3EFA
push_machine_8:pushing 00 to 3EF9
push_machine_8:pushing 00 to 3EF8
=== Exit ====
3EFF: 00 .
3EFE: 00 .
3EFD: 00 .
3EFC: 00 .
3EFB: 00 .
3EFA: 00 .
3EF9: 00 .
3EF8: 00 .
I have arranged the code so it works on 'machines'. A machine is an OPL runtime, I did this so you could run multiple machines at once in the future without too much work...
There's lots to do, but the core of the runtime (loading procedures and executing qcodes) is largely there. Lots more qcodes to implement...