Shop OBEX P1 Docs P2 Docs Learn Events
was the PocketCalculator HP48 programmed in forth? — Parallax Forums

was the PocketCalculator HP48 programmed in forth?

StefanL38StefanL38 Posts: 2,292
edited 2012-10-23 05:54 in General Discussion
You may find my question funny or astonishing. However when I was a student for mechanical engineering I used a Hewlett Packard HP48 pocket-calculator
and made some quite sophisticated programs for it.

Right now as in the prop-forum the thread Forth X.Y downloadable keeps on top of the thread-listing I was interested to take a first look into forth.
So I looked up forth at wikipedia and saw some of the basic commands like DUP, SWAP, DROP etc. which I all know well vom coding with the HP48.

So I came to the conclusion that I coded at least in a forth-style without knowing it. Cool!
Does somebody have experience with forth in general and the HP48 espescially and can explain how similar the HP48-language and forth are?

EDIT: Oops! sorry I wanted this post in the general discussion forum but accidently I posted in the prop-forum.
@webmaster if you have time you can move it into the general forum.

best regards
Stefan

Comments

  • LeonLeon Posts: 7,620
    edited 2012-10-23 01:45
    It used Reverse Polish, but it wasn't programmed in Forth.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-10-23 02:01
    According to the Wikipedia article which seems to have a lot of inside information concerning this beast:
    "The HP-48 series of calculators support a stack-based programming language named Reverse Polish Lisp (RPL), a combination of Reverse Polish Notation (RPN) and Lisp. RPL adds the concepts of lists and functions to stack-based programming, allowing the programmer to pass unevaluated code as arguments to functions, or return unevaluated code from a function by leaving it on the stack. In spite of the name, RPL resembles Forth more closely than Lisp"

    When I read an RPL program it looks very much like Forth and the bits that don't are suspiciously just like Forth dressed-up doing some preprocessing.
    «
       IF DUP "A" == 
       THEN 
          "Alpha"
       ELSE 
          IF DUP "B" == THEN
             "Beta"
          ELSE 
             IF DUP "G" == THEN
                "Gamma"
             ELSE
                "Unknown letter"
             END
          END 
       END
       SWAP DROP  @ Get rid of the original letter
    »
    

    So the THEN is really an IF and END is really a THEN so that IF is more of a dummy function. I say this because I can redefine a couple of words in Forth to make it work the same.

    Through the decades Forth has been Forth but you just didn't say it's name unless you wanted to invite a tirade of abuse and criticism which I can tell you I also know from experience. But Forth has always worked and it was very easy for a lone Forth programmer "for instance" :) to show up a whole team of conventional programmers, both in terms of code size, speed, and even more strikingly, the rapidity of the development cycle. In fact, there were many many instances (more than that in fact) where within a couple of hours a working and capable proof-of-concept could be demonstrated from scratch on new hardware. I kid you not.
  • BeanBean Posts: 8,129
    edited 2012-10-23 04:08
    StefanL38 wrote: »
    Oops! sorry I wanted this post in the general discussion forum but accidently I posted in the prop-forum.
    @webmaster if you have time you can move it into the general forum.
    Stefan

    It is so...

    Bean
  • Martin_HMartin_H Posts: 4,051
    edited 2012-10-23 04:49
    It's stack based, RPN syntax, with dup, swap, and drop, so it sure looks like Forth to me. I find Forth quite interesting, although I flail around compared to C family languages.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-23 05:54
    I am sure that HP felt some ties to Forth, but the HP48 didn't allow you to use colon and semi-colon to create more words, did it.

    I don't think my HP50g will actually do that in that manner - though I suspect I can form words. Simply put, the HP calculators generally did not have a very good alphabetical interface for using a word based language. It was a number cruncher.

    If I am using Forth, I'd much rather have a full Querty keyboard than have to peck letters from a grid of buttons, especially when I have to enter something equivalent to a ALT or CNTL each time I want to input a letter.

    I used an HP calculator extensively for years when estimating construction costs to bid major projects. I wore out a couple of rather expensive ones, but never got into adding words.

    Forth is very like-able on the Propeller, not because you have a calculator: but because it provide an interpreted language that you can get and see immediate responses. If fact, you can even use Forth on the Propeller in some instance to learn more about programming PASM. The Forth word 'see' will show you what makes up a word and in many cases the words are in PASM. It also is a great way to sort out what is happening in the Cog versus what is happening in the Hub with ram or i/o.

    It is a great Propeller study tool and I am a bit surprised that it took me so long to realize that. Of late, I've been spending a few hours each day reading about Forth, reviewing dictionary definitions, and so on. All of this is rewarding.
Sign In or Register to comment.