Page 2 of 2

Re: [POLL] Compiler for DM15L ?

Posted: Thu Apr 18, 2019 4:39 pm
by toml_12953
michaelzinn wrote:
Fri Apr 12, 2019 12:16 pm
toml_12953 wrote:
Fri Apr 12, 2019 12:04 am
e12g wrote:
Wed Apr 10, 2019 5:33 pm
Python makes sense. The language has a large user base and is growing in popularity.
I'd want a FULL Python, though. Not one of these "MicroPython" implementations.
How would a full Python with Strings and all be usable on the DM15L? I'd probably not do an exact implementation of a language anyway, e.g. I'd use the native decimal numbers of the calculator instead of integers or IEEE floats.

It's interesting that Python is so popular. The syntax is not that easy to parse...
It's fine to do another language but please don't call it Python unless it really is. One of the main reasons for higher level languages is portability and programmers should be confident that a program written in Python will be able to run on any system that supports Python with minimal changes. Internal differences such as numerical format don't matter too much to a high level programmer as long as the answers are consistent.

Re: [POLL] Compiler for DM15L ?

Posted: Tue Apr 23, 2019 1:44 pm
by pauli
If possible, I'd go for Lua -- small and lean VM, JIT compilation is available for ARM CPUs and it is fast (even without that).
It's also a very simple but expressive language.


Pauli

Re: [POLL] Compiler for DM15L ?

Posted: Wed Apr 24, 2019 12:45 pm
by michaelzinn
pauli wrote:
Tue Apr 23, 2019 1:44 pm
[...] JIT compilation is available for ARM CPUs [...]
Interesting, thank you for pointing that out! But that's not the goal here: I'd like to compile to the language of the calculator (is it called RPN?), not create an alternative firmware where you can run Lua on the exposed ARM CPU. If you want serious programming on a handheld device I think programming a smartphone app is a much more sensible approach.

My goal is to get a basic understanding of programming languages and compilers, and given that I already wrote some complex programs in RPN (interpreter, binary converter with lookup tables...) I think that I have a good enough understanding of the language to use it as a compiler target. In addition, it would be nice if it were also useful for other people (unlike the BF interpreted), hence this thread.

Also, the current status is that I now understand parser combinators and implemented them in Idris. I should be able to parse any language now, but I think old style BASIC with line numbers and gotos should be the choice with the best usefulness to difficulty quotient, given that I wouldn't need to think about complicated things like variable scopes and stack frames.

Re: [POLL] Compiler for DM15L ?

Posted: Tue May 14, 2019 10:57 am
by michaelzinn
I decided to go with CommodoreBASIC (C64), for these reasons:
- It is easier to compile than most other languages (only global variables, no stack frames etc.)
- It is something that people who use HP calculators might know, because it is from the same time
- You can compile old number based BASIC games and play them on your calculator, e.g. Hammurabi

I'll start with a useful subset, i.e. I want to be able to compile the Hammurabi game and run it on my calculator: http://vintage-basic.net/bcg/hammurabi.bas

The Hammurabi game uses 15 variables and 26 jump targets, so as a first version I'll compile variables to directly accessible registers (0-19) but jumps to line numbers instead of labels. More sophisticated features like functions or lists will come later when/if I need them or somebody asks for them.

Current state of the project is that it parses the whole program and compiles some expressions (ENTER insertion was tricky):

Code: Select all

((Z-1)*P1+D*100/P)/Z

RCL 0
1
-
RCL 1
*
RCL 2
1
0
0
*
RCL 3
/
+
RCL 0
/
Do you have an idea for a name for this compiler? Maybe VoyagerBASIC or voyagerc?

Re: [POLL] Compiler for DM15L ?

Posted: Mon May 20, 2019 2:21 pm
by michaelzinn
Compiling works now, but only for programs smaller than 448 lines because of viewtopic.php?f=11&t=2186.

I'll see if I can clean up the code and release it in the next days/weeks/when I have time.