Post Reply 
Simple Programming Language or Set of Programming Commands
10-07-2019, 08:46 AM (This post was last modified: 10-07-2019 08:48 AM by deetee.)
Post: #1
Simple Programming Language or Set of Programming Commands
Hi all!

The next calculator I'm going to build should cover some programming features but unfortunately the resources (i.e. code size) are limited.

So far I can edit and run sequences containing all operations of the calculator. But a "complete" programming language has to contain some decision and repetition capabilities. Also some simple input and output sequences would be very convenient.

Are there any examples for small, easy and simple complete programming languages or sets of commands?

For instance my HP15c seems to have easy and complete programming features - but it could be more convenient.

Thanks in advance and regards
deetee
Find all posts by this user
Quote this message in a reply
10-07-2019, 11:56 AM
Post: #2
RE: Simple Programming Language or Set of Programming Commands
(10-07-2019 08:46 AM)deetee Wrote:  Hi all!

The next calculator I'm going to build should cover some programming features but unfortunately the resources (i.e. code size) are limited.

So far I can edit and run sequences containing all operations of the calculator. But a "complete" programming language has to contain some decision and repetition capabilities. Also some simple input and output sequences would be very convenient.

Are there any examples for small, easy and simple complete programming languages or sets of commands?

For instance my HP15c seems to have easy and complete programming features - but it could be more convenient.

Thanks in advance and regards
deetee

Although people may call for my head for suggesting this, have you looked at BASIC? It was designed to be easy for beginners to use (in fact the name means Beginners All-purpose Symbolic Instruction Code) It's complete with branching, subroutines and in many implementations, formatted output. It doesn't enforce odd rules like semi-colons at the end of lines like C or forced indenting like Python. BASIC allows structured programming but it doesn't force it on you. It can be quite small (the first commercially successful microcomputer BASIC fit in 4K) and even a complete implementation can fit in 32K with all the bells and whistles. These days, that's nothing! Also, there's a large base of pre-written programs available. I was a professional BASIC programmer until I retired a couple years ago. The salary was quite good and the job was easy.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
10-07-2019, 12:25 PM
Post: #3
RE: Simple Programming Language or Set of Programming Commands
Hello!

(10-07-2019 11:56 AM)toml_12953 Wrote:  ... have you looked at BASIC?

I would also suggest something like BASIC. A full implementation is not really required for a small calculator, but it can provide the most often used control structures (IF...THEN...ELSE, FOR..NEXT, WHILE, ...) in readable and easily comprehensible format. Ideally they would be used in "tokenised" form without the need to type "W H I L E" on the keyboard.

The way these structures are implemented on legacy calcultors (like the HP-15 you mention or the Ti59 that I used back then) are not really appleaing any more. At least not to me...

Regards
Max

NB: As an example there are BASIC interpreters for the Arduino which require very little memory like this one here for example: https://github.com/robinhedwards/ArduinoBASIC
Find all posts by this user
Quote this message in a reply
10-07-2019, 03:57 PM
Post: #4
RE: Simple Programming Language or Set of Programming Commands
You might also consider Forth for its extensibility and stack model of computation. Operation resembles RPN but programs look more like RPL. A barebones interpreter can also fit in a small amount of memory. I've never seen an implementation that used a calculator Run/Program model of entering and editing programs, but that would be a lot easier to use on a limited size display that the HP48 model of program editing.

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
Quote this message in a reply
10-07-2019, 07:56 PM (This post was last modified: 10-07-2019 07:56 PM by Craig Bladow.)
Post: #5
RE: Simple Programming Language or Set of Programming Commands
(10-07-2019 08:46 AM)deetee Wrote:  Hi all!

The next calculator I'm going to build should cover some programming features but unfortunately the resources (i.e. code size) are limited.

So far I can edit and run sequences containing all operations of the calculator. But a "complete" programming language has to contain some decision and repetition capabilities. Also some simple input and output sequences would be very convenient.

Are there any examples for small, easy and simple complete programming languages or sets of commands?

For instance my HP15c seems to have easy and complete programming features - but it could be more convenient.

Thanks in advance and regards
deetee

I think you are starting in the right place, looking to other calculators for examples of where to start. The HP-25 is a fairly minimal example and if you replace the key codes for each function with the text name, you have something that is friendlier to program.

Try CC41!
Find all posts by this user
Quote this message in a reply
10-09-2019, 05:49 AM
Post: #6
RE: Simple Programming Language or Set of Programming Commands
Thanks for your very inspiring hints so far.

I also like the simplicity of BASIC, but in my case the resources are to limited (Arduino, 32k). I don't want to spend more than 1 or 2 kilobytes of code for looping and conditions.

The HP-25 seems to be really minimal (but complete) in programming. There is no (ISG/DSE)looping, labelling or jumping to subroutines. Even if there are 8 conditions - the HP-15c works with 2 only (x<=y and x=0).

Finally I like FORTH because it "fits" to the stack philosophy of RPN calculators. There is no GOTO (which seems to be strange for HP programmers) but a lot of attention for subroutines.


Maybe my minimalistic solution could be to implement 2 possible conditions and jumping to (a limited size of labelled) subroutines (needs some address stack to return) - and no GOTO? I hope this is still "complete".

Regards
deetee
Find all posts by this user
Quote this message in a reply
10-09-2019, 06:42 AM
Post: #7
RE: Simple Programming Language or Set of Programming Commands
Would this be appropriate?

It's Python slimmed down for the limited resources of microcontrollers.

I know BASIC too but Python really is more future-proof.

https://micropython.org
Find all posts by this user
Quote this message in a reply
10-09-2019, 12:15 PM
Post: #8
RE: Simple Programming Language or Set of Programming Commands
(10-09-2019 05:49 AM)deetee Wrote:  ...Even if there are 8 conditions - the HP-15c works with 2 only (x<=y and x=0).

Actually, the 15C supports 12 comparison tests; 2 are assigned to keys, the other 10 are accessed via [g][TEST][N], and the 10 "N" tests are listed on the back of the case. See p. 91 in the manual. This may be the most complete set of comparisons available on a calculator, more than on he 41C.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
10-09-2019, 07:57 PM
Post: #9
RE: Simple Programming Language or Set of Programming Commands
For 1k to 2k of code, you are probably looking at some Forth-type language, where there's no interpreter or execution loop. For Basic, some tokenized implementations used to fit in 16 kbytes of ROM (like the original ZX Spectrum 48k) but I don't know of any open source code out there that can be that small.
Try uBASIC? I don't know if it's small enough.
Find all posts by this user
Quote this message in a reply
10-10-2019, 07:24 AM
Post: #10
RE: Simple Programming Language or Set of Programming Commands
Maybe https://sourceforge.net/projects/terminal-basic/?

I would try to avoid inventing Yet Another Pocket Calculator Language because only few people will try to learn it.
Find all posts by this user
Quote this message in a reply
10-15-2019, 07:11 AM
Post: #11
RE: Simple Programming Language or Set of Programming Commands
Thanks for your further hints and advices - that helps me a lot.

I like uBasic and TerminalBasic, which are worth to examine in another project. But that seems to be far beyond my resources for my calculator project.

And it's a shame that I'm not familiar with my HP-15c - and it's 12 conditions.

So far I implemented jumping to subroutines (XEQ) and 4 conditions similar to the HP-25 (X=Y, X!=Y, X<Y and X>=Y) which seems to be sufficient. By the way comparing double values costs more code space than I expected - that's why I don't compare with 0 additionally.

What I'm not sure about is whether doing without GOTO is acceptable (regarding "completeness" and comfort). GOTO (even if GOTO LABEL or GOTO LINENUMBER) costs much code space (because it's the only 2 byte command so far).

Regards
deetee
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)