Slashdot Mirror


A C Compiler For The HP49g+

Cheese Source writes "As previously mentioned on Slashdot, HP's latest and greatest calculator is the HP49g+. While it sports a very powerful (for a calculator) ARM9 cpu, it is only 3 times the speed of the 49g, running at 4MHz. This is because it has to emulate an older processor. Of course, some calculator geeks are now writing adapting a free, open-source C compiler for it. Based on GCC, you can now make programs that run natively on the CPU between 12 and 203MHz. 1000 factorial is calculated and displayed in the blink of an eye (the built in command takes 30 seconds). It will also allow for some great games."

17 of 194 comments (clear)

  1. Options? by dmayle · · Score: 3, Interesting

    running at 4MHz. This is because it has to emulate an older processor

    So what they're saying is, rather than porting their calculator software to a new platform, they found it easier to write an emulator that pretends to be the old processor? Sounds like a pretty crappy design decision to me.

    Also, if customers are writing their own programs with a C compiler to get speed, why not just use something like the Zaurus running Linux, and one of the many, full featured, science/math software suites for Linux?

    1. Re:Options? by metalpet · · Score: 4, Interesting

      > So what they're saying is, rather than porting their calculator software to a new platform, they found it easier to write an emulator that pretends to be the old processor? Sounds like a pretty crappy design decision to me.

      HP has a bit of an history of using great hardware for their calculators then botching them with inferior software.
      The HP48g/gx had 512KB of ROM, a good chunk of it was used to store standard applications programmed in "external" (odd name given to a dialect of RPL that used internal entry-points liberally. Those would render as "<external>" when you'd try to see the source within the calculator, hence the name.) Applications written in "external" would commonly be about 15% faster than user-RPL programs. However in both case, you still use the RPL framework, which means your program is essentially interpreted, token after token.
      That may be acceptable for user-written programs, but it's a bit sloppy for processor intensive applications that are in charge of plotting graphs and resolving symbolic equations.

      A group of hackers once rewrote a good chunk of the built-in applications entirely in assembly, with the goal of making it fit on a 128K memory card. Unsurprisingly, the resulting environment was many times faster and more responsive than the original version.

      That said, a whole lot of software has been written for the HP48 in many areas (although I seem to only remember seeing great games and textbook browsers for some strange reason..)
      I can understand the value of an emulator to keep this software library available to the newer models.

    2. Re:Options? by RevAaron · · Score: 2, Interesting

      C'mon- how long does your HP49g+ last on a set of batteries/a charge? Wouldn't you prefer it to last 2 hours, like a Zaurus? Or 4-5 if you buy a C760 or C860. Or, you could be like most Z users and have a pocketful of batteries, at the ready!

      Although, with an external keyboard (or a PDA with a *real* keyboard, like a Jornada 720 or Sigmarion 3) it is pretty fun to use GNU Maxima or GNU Octave. Somehow though, it strikes me as lame that you can get a full GUI'd version of GNU Maxima on Windows CE [1], and on the Zaurus you only have text-mode Maxima and Octave. Some pretty bitchen ASCII graphs, though.

      Although, on those two CE devices batter life is a fair bit better- on the Jornada 720 you're looking at 12 hours or so (with a 640x480 color screen, 206 MHz StrongARM) and the Sigmarion 3 around 6 hours, though with a fancier 400 MHz PXA255. Not sure why they can't make my C760 Zaurus last a usable length of time.

      What I use on Palm OS is an HP48g emulator, pretty slick, since Palm OS itself doesn't have many good math apps. There's LyME, but nothing like an HP or Octave or Maxima.

      BLEH!

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
  2. 30 seconds? by BarryNorton · · Score: 2, Interesting

    What kind of moronic algorithm is being used there?

    http://www.luschny.de/math/factorial/FastFactorial Functions.htm
    1. Re:30 seconds? by Nyall · · Score: 2, Interesting

      Displaying the results is a larger problem than doing the factorial.

      --
      http://en.wikipedia.org/wiki/Jury_nullification
  3. GCC on TI by eldacan · · Score: 4, Interesting

    GCC has been available for a long time for the 68000 based TI calculators with TIGCC. Is this about a port of GCC that runs on the calculator?

  4. GCC Mods by devphil · · Score: 2, Interesting


    I wonder what they had to change in GCC for this project. ARM chips are fairly well supported already.

    I poked around briefly in their CVS repo, but didn't see anything obvious that looked like a set of patches to gcc backend source.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  5. Good thing ! by Lionel+Debroux · · Score: 3, Interesting

    Good to see that some programmers are interested in hacking a powerful calculator. They should be able to port great games, despite the rather low screen resolution.
    I was already aware of that project, as an user of the TIGCC board (an environment development including heavily patched GCC for TI-68k calculators), which someone else already told about in those comments.

  6. Games huh? by Flower · · Score: 4, Interesting

    So how long until a NetHack port is complete? Come on, we all know what's important.

    --
    I don't want knowledge. I want certainty. - Law, David Bowie
  7. Contiki port? by Anonymous Coward · · Score: 4, Interesting

    Now with a C compiler available, how about building an Ethernet interface and porting the Contiki OS to iy? A Contiki port would bring TCP/IP networking, multitasking and a bunch of other cool stuff to the HP. Contiki has already been ported to a lot of weird stuff, like the GBA and the C64, so it would probably work well on the HP.

  8. HP calculator are no more, really. by Yodalf · · Score: 5, Interesting

    A long time ago i bought an HP41C (not "V"!) and it was (still is...) a very good, small & rugged machine. No nonsense. Back then HP were making the very best calculators in the world.

    Nowadays, a certain Miss has decided to decimate the "Calculators" division of HP and it shows. THe present calculators at HP have the same look and (cheesy) feel as the TI calculators. They are bulky and large, they sport cheesy buttons and it is actually hard to find a model that supports the sooo efficient & fast RPN notation. In short: they suck. I feel like we will never ever again see really well built & designed calculators now. Too bad.

    Interestingly enough, the only calculator left in their product line that still has the feeling & quality of true HP calculators is the "Financial" HP12C... It seems Economists have it all... !

    Maybe we should petition for Agilent to start designing calculators? One can always dream...

  9. Re:Convergence - USE GSM(GPRS) for calculating ;) by radionacht · · Score: 2, Interesting

    Salve,
    I would call convergence when I use my mobile and a SSH connection via GPRS to use my Maple version of my home PC on the road. OK, your right the HP calculators do have a better keyboard and the display shows better plots, but why not use a HP calculator with SSH conection via mobile to the home PC? I would call it "mobile shell" that offeres much more than using maple *g*. There is a free J2ME SSH1 Client:
    http://phoenix.inf.upol.cz/~polakr/

    BTW: Any chance to get a HP48GX programming manual, today? I borrowed it one guy - but he never brought it back ;(

  10. "That's not a calculator..." by po8 · · Score: 4, Interesting

    Note that Nickle will quite happily compute 10,000! (exactly) in a fraction of a second on a similar machine, through the miracle of Karatsuba multiplies. It also supports arbitrary-precision rationals and definable-precision floats (default 256b mantissa) with arbitrary exponent, and features a calculator-like interactive mode. I don't use much of anything else for numeric calculations anymore. (Of course, I co-wrote it.)

  11. Re:What is the point by Anonymous Coward · · Score: 5, Interesting

    Hi,

    I'm one of the people working on this. Maybe I can answer a few questions:

    Whats the point? Why Bother?

    Well, this is just an obscure hobby; no-one is spending 6 hours a day coding for this project. For me its just a way to learn a little about compilers. The main aim is to make it possible to create decent programs (mainly games) for this system. Coding for devices such as calculators has some interesting challenges to it, esp when you have to reverse engineer the hardware like we did.

    Is this a real port of GCC? I thought ARM already has a port.

    Yes it does, and its very good. We have tried to avoid modifying GCC itself to avoid extra work in the future. What we have done is write HP specific libraries and linking programs to executable may run. It works, so why not?

    1000! in half a second is slow, 10,000! takes about a second to calculate on [some platform]

    Indeed. Calculating factorials quickly is easy. Displaying the result (a massive, massive integer) is not. The factorial program trades off some calculation speed to markedly improve display speed. The "half a second" measurement comes from when the CPU is executing at 75MHz. I'm guessing running at 203MHz would speed that up a little.

    Is the calculator really running a saturn emulator?

    Yes, it is. SysRPL is an obscure language used only in these calculators. The complete Saturn CPU is being emulated, not just the SysRPL envrioment.

    Yes, it makes things very slow - but there is a decade of debugged code written in sysRPL and Saturn asm. Throwing all that away would be very expensive for HP. With calculators, having the correct answer is critical. Emulating old code means the ROM should be fairly bug-free.

    Of course an OS completely rewritten for the ARM would have been great - but its not economically feasible.

  12. battery usage? by teridon · · Score: 3, Interesting


    What happens to the battery life when you run the ARM at higher clock?

    --
    I hold it, that a little rebellion, now and then, is a good thing. -- Thomas Jefferson
  13. I just got the 49g+ yesterday by Vlion · · Score: 2, Interesting

    because I knew hp-gcc existed.
    I'm liking this calculator.
    I've owned a TI-86 for a few years, so I know a bit about higher-end calcs.
    The keyts are nice and firm, with a "pop" type feeling when I push them.
    I can switch between RPN and normal entering mode.
    The menus are a bit unintuitive.

    I even have the IR port on it, plus what looks to be a memory slot.

    I like it. My TI is nice, mind you.
    But this is much slicker.
    And, I can now do some good old C programming with it. ^_^

    --
    /b
    |f(x)dx = F(b) - F(a)
    /a
  14. The doom of the calculator by stonecypher · · Score: 3, Interesting

    ... is nigh.

    See, the only thing that's been preventing the gameboy from being a kickass calculator is the relatively awful control system. However, the upcoming DS has two screens, one of them a touchscreen; you can't get a better small-platform simulation setup than that, IMO, since you can change the key layout per task, and if nessecary trade the keys temporarily for a whole second screen.

    It's like a palm pilot calculator, except that it still has a screen while the keys are up, eliminating the most sucking thing about palm pilot calculators.

    Seperately, you never need to bother with a connection cable, because it does 802.11, and the screen is quite nice - backlit 256x192 fullcolor with hardware-assisted 3D with antialiasing. The graphing potential of such hardware is massive. You can use sprites for things like cursors and flow analysis.

    Oh, right: and the underlying CPU blows the doors off of a 4mHz ARM9. It's got a 66mHz ARM9 *and* a 33mHz arm7. 8 meg of ram for large matrix calculations. The ability to network.

    Oh, and games on a gameboy are better than games on any TI.

    The end is nigh. HEED MY WARNING. Calculator advocates, repent - unification is at hand, commodity hardware defeats characteristic purpose hardware, generalization is cheaper than specific hardware, the ASIC falls at the sword of the CPU.

    Linux boxes for VCRs, Linux boxes for game systems, Linux boxes for kitchen appliances, but when it matters, turn to Nintendo for your calculator.

    And in case you were wondering, yes, I'm the gameboy stonecypher, and yes, my calculator, based largely on gnuplot and yacas, is about three quarters done. I may not know shit about math, but my Nintendo sure does.

    +1, Insightful to anyone who compares YACAS and whatever other computer algebra systems there are to HP's bujillion calculators I can't be bothered to research.

    --
    StoneCypher is Full of BS