Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
HP Programming Technology

A C Compiler For The HP49g+ 194

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."
This discussion has been archived. No new comments can be posted.

A C Compiler For The HP49g+

Comments Filter:
  • Options? (Score:4, Interesting)

    by dmayle ( 200765 ) * on Sunday August 22, 2004 @05:20AM (#10036872) Homepage Journal

    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?

    • Re:Options? (Score:5, Insightful)

      by Anonymous Coward on Sunday August 22, 2004 @05:24AM (#10036881)
      Because the input interface (buttons vs touchpad) and output interface (greyscale vs energy-guzzling colour screen) of a calculator are more suitable for.. calculating. Pity about the crappy 49g+ keys [repaste 100000000 posts from c.s.hp48 here].
      • Re:Options? (Score:4, Insightful)

        by W2k ( 540424 ) <wilhelm.svenseli ... m minus caffeine> on Sunday August 22, 2004 @07:20AM (#10037098) Homepage Journal
        What is it that people have against the 49g+ keys? I've got just such a calculator, and the only complaint I've had is that the calculator was DOA - getting a replacement from HP was fairly painless though, even though I'd bought it on eBay.

        Regarding the keys, I find them to be just the right size, easy to read, have a distinct press, and not overly plasticy, despite being made of .. plastic. Yes, if they'd made the keys from brushed aluminium or ebony, carefully hand-crafted by pure-minded tibetan nuns, that would have been nice, but who cares? Compared to my old Casio or my friend's TI, the HP kicks ass, every department. And now a C compiler? Wow. Can't wait to try it.
        • Re:Options? (Score:5, Insightful)

          by Cereal Box ( 4286 ) on Sunday August 22, 2004 @07:35AM (#10037127)
          What is it that people have against the 49g+ keys?

          These sound like the words of someone who has never used HP's 48 series. The keys were made out of a very solid plastic, never wobbled, gave you tactile feedback, etc. I think the other big complaint people have is the placement of the enter key, which was perfect on the 48 (big wide button, center left). Now I believe it's been shrunk and moved to the bottom right.

          Now you may not care about all that, but the undeniable truth was that HP had a winning formula on the 48 and they threw it all away with the 49 series.
          • Correct, I haven't tried the 48 series. I can, however, recognize a great calculator when I have one in my palm (and I have tried several others, the popular Ti-89 for instance). Maybe the 48 was better, but the criticism against the 49 is clearly overstated.

            The keys on my 49g+ are neither wobbly nor is there a lack of tactile feedback. Are the problems you suggest something that I can expect as it gets older (only had it for about 6 months) or do you suggest that my experience using the 49g+ is signific
            • There is an unending stream of complaints about the 49 series keys on news://comp.sys.hp48/ Google it for some examples. I've no experience with the 49 series.

              I purchased a 48gx two years ago so that I'd have one of the last good ones. Crazily enough, I bought it brand-new at Fry's for $95 and now many are going for $250 on ebay. Never would I have considered a calculator an investment.
              • I just Googled it. Look what I found regarding the 49g+ keys:

                People have been complaining that hp49g+ keyboards dont work right. i emailed hp to hear the other side of the story; they replied the next day. Here's their reply on 7/19/2004:

                "Thank you for contacting HP Total Care.
                The some of the early ones did have an actual issue with the keyboard. The new ones still 'click' and we have had a couple complaints that they were "loud" but they do work. ALL the time. If anyone still has one of the old ones,

                • Re:Options? (Score:2, Insightful)

                  by Anonymous Coward

                  How many of the people in comp.sys.hp48 bothered to ask HP about the keyboard issues, I wonder?

                  The first batches of 49G+s were even worse than the current - so bad, in fact, that HP admitted the problem and tweaked a little. Everyone in the group that I'm aware of with such a unit has asked HP for a replacement, and almost everyone got one. (If they're new to the group, and haven't bothered reading any threads before replying, they're quickly pointed to the thousand other which state this.)

                  If you'd bo

                  • I'm an engineering student. Working on a master's in information technology, specifically. Yes, this means a software developer. I wanted a fast and reliable calculator that had functions for most (all) the university-level maths I need to go through. IT has lots of maths in it, at least where I study [www.kth.se].

                    I have read the posts but I can't seem to find the same problems in my 49g+. Will they develop over time? Maybe, but most of the complaints I read suggested that the problems existed from day 1. Guess my pa
      • Re:Options? (Score:3, Interesting)

        by RevAaron ( 125240 )
        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
    • Re:Options? (Score:3, Funny)

      by ColaMan ( 37550 )
      Perhaps they deliberately slowed it down for all the tons of user-written programs out there.

      But a "turbo" key would have been handy.
    • by xtal ( 49134 ) on Sunday August 22, 2004 @05:45AM (#10036930)
      I suspect it was one of the two:

      - Simple economics, if it's cheaper to use the faster processor and emulate the other one, it doesn't matter. Recoding for native operation may not have been possible. This is related to my second point:

      - All glitches and problems with the existing design are well documented and hammered out. It may not have been feasible as I suspect there is a lot of verification that happens on these guys before they ship. If the calculator has been painstakenly debugged on one processor, it may very well be easier to insure 100% emulation than re-test all the functions.
    • Re:Options? (Score:5, Insightful)

      by torpor ( 458 ) <ibisum@@@gmail...com> on Sunday August 22, 2004 @06:07AM (#10036970) Homepage Journal
      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?

      Ah yes, rampant Consumericanism at its finest.

      Maybe the reason 'they' 'don't just use something like a Zaurus running Linux' is because they've already got a fine working H49g+ in 'their' posession.

      Don't you get it? You're only 'countering the view' on automatic. The solution to every cool hack is not automatically "you can buy something else instead and it'll be cooler".

      (Not a Flame, not a Troll. Truly, this is Consumerican 'logic' at its finest...)
    • Re:Options? (Score:5, Interesting)

      by metalpet ( 557056 ) on Sunday August 22, 2004 @06:08AM (#10036973) Journal
      > 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.
      • "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."

        More info please?

        (proud HP48gx owner here)
    • Re:Options? (Score:3, Informative)

      by ricotest ( 807136 )
      From the site:

      The most commonly used language for advanced programming is 'System RPL', or 'SysRPL'. On modern calculators, SysRPL is mostly executed by an emulated 'Saturn' processor. C on the other hand is executed directly by the ARM chip. The same program written in C will be many (up to 100) times faster then the equivalent SysRPL program.

      So possibly the article miswords that the 'emulation' is simply of an older programming language. If it's a common one, I see why they'd keep using it instead of
    • Re:Options? (Score:5, Insightful)

      by mqx ( 792882 ) on Sunday August 22, 2004 @06:22AM (#10037007)
      "Sounds like a pretty crappy design decision to me."

      You don't understand Engineering do you?

      The design solution to a problem is about getting the best time, cost, risk and other constraints satisfied in the most optimal way possible. It may be lower risk to emulate an old processor than to port and regression test legacy code.

      The best technical solution can often be the worst engineering solution, taking into account other cost and risk factors.

  • 30 seconds? (Score:2, Interesting)

    by BarryNorton ( 778694 )

    What kind of moronic algorithm is being used there?

    http://www.luschny.de/math/factorial/FastFactorial Functions.htm [luschny.de]
    • Re:30 seconds? (Score:4, Informative)

      by imsabbel ( 611519 ) on Sunday August 22, 2004 @05:42AM (#10036924)
      Perhaps the same that make TI calculators need 5 seconds to calculate 50!....
      No, really. the 4Mhz cpu it emulates does imho only do 4bit arithmetic, so you need an awfull lot of cycles to handle longer arbitrary precission numbers...
      • Re:30 seconds? (Score:5, Informative)

        by BarryNorton ( 778694 ) on Sunday August 22, 2004 @06:27AM (#10037014)
        No, the Saturn has an external word size of 4 bits, but 64 bit registers and instructions.

        At three to seven (the actual comparison) times the 4MHz 48g speed, there is far less than a gap of >>30 between the speed of the emulated processor and the physical one so I stand by (for now) my speculation that there is surely an algorithmic difference between the built-in (example?) one and the new 'native' one...

        (But what do I know, I'm just flamebait... apparently...)
      • Re:30 seconds? (Score:2, Informative)

        by khuber ( 5664 )
        No, really. the 4Mhz cpu it emulates does imho only do 4bit arithmetic

        Um, no. Saturns have 64 bit registers. They do address on 4-bit nibble boundaries though.

      • "Perhaps the same that make TI calculators need 5 seconds to calculate 50!"

        No. The TI-89 can bust through 50! without any noticeable delay.

        The TI's biggest slowness when working with large integers is the display time - the "pretty print" routine is slow when working with them. If you put "(100!)^2->X" in a program and execute it, it only takes a fraction of a second.

        Note that the TI does not display integers greater than 10^1000.
      • I don't have a TI or a HP-49g+. Are you saying that these calculators are actually displaying 65-digit numbers like 50! ? Or, that they are internally representing the calculations using multi-precision arithmetic?
    • Re:30 seconds? (Score:2, Interesting)

      by Nyall ( 646782 )
      Displaying the results is a larger problem than doing the factorial.
      • How so? It should not be a greater problem than multiplying two 6 digit numbers together --- after all, these calculators don't display full precision on numbers like 50!, do they?
  • Calculators that feature games and compile C programs, sounds to me like another example of bundling lots of unrelated features into the same hardware [slashdot.org].
    • Then I have to wonder why you are using a calculator that features games, compiles C programs and even allows you to waste your time communicating with other nerds using a worldwide network of such calculators...
      • Re:Convergence (Score:2, Insightful)

        by DaveGerbik ( 742915 )
        The difference of course, pocket calculators have always had a very different, far less specific set of features to home PCs/PDAs and have traditionally been built for niche science/maths tasks.

        Why start shifting calculators away from their original uses when PDAs are already available for the less specific functions such as nice graphics, sound, GPS and offer the same portability?
    • by smittyoneeach ( 243267 ) * on Sunday August 22, 2004 @05:46AM (#10036934) Homepage Journal
      See, now, your cart and your horse are transposed.
      Specifically, the horse in this example is the chip, and the cart is, of course, emacs.
      The C compiler is foundational. Now, we need to figure out an interface using the cable kit for a keyboard, and the relentless march of the One True Editor shall take yet another step.
      Mwahahahahah...
    • 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/ [inf.upol.cz]

      BTW: Any chance to get a HP48GX programming manual, toda
  • Wonder what kind of key'age you can get on one of these "top of the line" calculators...
    • Many years ago, a friend of mine implemented RSA on his HP48gx.

      His intention? Try to get arrested taking it across the border as a way of protesting ITAR. (This was before encryption export restrictions were eased.)
  • GCC on TI (Score:4, Interesting)

    by eldacan ( 726222 ) on Sunday August 22, 2004 @05:32AM (#10036896)
    GCC has been available for a long time for the 68000 based TI calculators with TIGCC [ticalc.org]. Is this about a port of GCC that runs on the calculator?
    • Re:GCC on TI (Score:2, Informative)

      > Is this about a port of GCC that runs on the calculator?
      No.
    • Re:GCC on TI (Score:5, Informative)

      by khuber ( 5664 ) on Sunday August 22, 2004 @06:16AM (#10036991)
      GCC has been available for calculators with HP's Saturn processors since 1994 (hp48xgcc). This is about using gcc as a cross-compiler for HP's new ARM-based calculator. The summary makes it sound as though someone is writing a compiler which is of course not the case. They are just writing the glue code and linker portions specific to the HP49G+.
    • 68000 based TI calculators
      The Motorola 68k-based calculators, the 89, the 92, and the Voyage 200, are unfortunately prohibited most everywhere (ACTs, etc.) due to the onboard computer algebra system. Great calculator on technical merits, though.

      Anyone know of a good GCC/other C compiler for the Zilog Z80 TI series (73 and 80 through 86)? I've seen Z80 compilers on the Internet that can output object code linkable into TI programs (using DEVPAC83), but these aren't explicitly designed for TIs: they use the
  • GCC Mods (Score:3, Interesting)

    by devphil ( 51341 ) on Sunday August 22, 2004 @05:32AM (#10036897) Homepage


    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.

    • Most of the work is writing the linker and the C library. Though if they're anything like TIGCC, they'll start accumulating patches to the compiler itself after awhile. Not because the compiler itself needs to be changed, but to work around mismanagement of the gcc main branch.
  • by xtal ( 49134 )
    Can anyone confirm that this calculator has the trademark keys - the 49 didn't - and I noticed they switched back to plastic. My 48 is dying and I have pretty much decided to get a tungsten T3 running power48 to replace it, but this would be far superior.
    • Re:Keys? (Score:3, Informative)

      by khuber ( 5664 )
      No. Actually there have been tons of user complaints about how crappy the keys are on the 49g+. Check out comp.sys.hp48 on Usenet or Google groups. Supposedly they have been improved on recent calculators, but there are still complaints.
    • A quick check of comp.sys.hp48 will show hundreds of posts complaining about key bounce and other issues.

      I'm fairly disappointed with my 49G+, I'm looking forward to this machine [hydrix.com], which was designed by some of the old HP48 engineers, I believe.
      • I'm interested in that, but before I'm going to buy it that picture on the top-right damn well better feature a crappile of calculator keys.
        • The older version of the site showed that it's a clamshell case - the bottom half flips down to reveal a large calculator style keyboard.

          They used to have pics of their prototype spread out over the bench, with all the chips in view and the keys on the keyboard all hand-labelled.

          I guess they've gotten funding since then. :-P
  • by Anonymous Coward on Sunday August 22, 2004 @05:38AM (#10036914)
    Should only be about 3 years before Gentoo finishes compiling. Woohoo!
  • HP49g+ details (Score:5, Informative)

    by goon ( 2774 ) <<moc.lacigolmodles> <ta> <wahsnerretep>> on Sunday August 22, 2004 @05:43AM (#10036927) Homepage Journal
    for those interested in the the 49g+ in all it's gory technical details [hpcalc.org].
  • ...some real news for nerds!
  • Good thing ! (Score:3, Interesting)

    by Lionel Debroux ( 807362 ) <lionel_debroux@yah[ ]fr ['oo.' in gap]> on Sunday August 22, 2004 @05:47AM (#10036936) Homepage
    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.
  • as calculators get more and more powerful and capable, the fun things one can do to them increased. I made something for the ti-83+ that replaces every token (eg. "sin(", "1" and "Q") with "codysux," and I'm currently finishing up a self-propagating virus. I'm sure this just opens up many new possibilities for people to mess with the hardware.
  • Games huh? (Score:4, Interesting)

    by Flower ( 31351 ) on Sunday August 22, 2004 @06:05AM (#10036964) Homepage
    So how long until a NetHack port is complete? Come on, we all know what's important.
  • Contiki port? (Score:4, Interesting)

    by Anonymous Coward on Sunday August 22, 2004 @06:07AM (#10036969)
    Now with a C compiler available, how about building an Ethernet interface and porting the Contiki OS [www.sics.se] 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.
    • 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.

      Why go with ethernet when you could have a SD 802.11b / 256M card [sandisk.com]? The question is can SDIO cards work on the 49+?

  • by Yodalf ( 83088 ) on Sunday August 22, 2004 @06:10AM (#10036978) Homepage
    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...

  • Someone port Libtomcrypt [libtomcrypt.org] to it!
    It compiles in ARM CPU's already, I believe.
    Crypto on your calculator!
  • by po8 ( 187055 ) on Sunday August 22, 2004 @06:39AM (#10037034)

    Note that Nickle [nickle.org] 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.)

    • Could someone please enlighten my poor brain and suggest some practical use for the exact value of 10000!, and why I might require its computation in a fraction of a second? I'm afraid I don't think too good.
      • It's simply an easy metric to test a calculator by. Takes virtually no effort to enter or explain it.
      • It's mostly a metric of multiplication speed. There are lots of times you need to do a lot of large multiplications in a fraction of a second.

        That said, my students were recently working on an ICPC problem in which they needed to find the last non-zero digit of large factorials. "How will we check our solutions?" they asked. Heh...

  • by bombshelter13 ( 786671 ) on Sunday August 22, 2004 @06:46AM (#10037043)
    ... think this calculator would, if nothing else be an amazing way to earn geek street cred? I mean, if programming (1 geek point) computer games (2 points) on an overclocked (3 points) calculator (4 points) using an open source (5 points) compiler isn't the pinnacle of all that is geek I don't know what is.
  • while the post can first be read by the editors with grammatical corrections the flow of the story could hopefully be found.

    Seriously, Michael give me your snail mail address and I will send you the MLA guide. We will have you making sentences in NO time.
    • Pot, meet kettle. I presume your subject line should be interpreted as "Hello, grammar"?
      • Pot, meet kettle. I presume your subject line should be interpreted as "Hello, grammar"?

        Yes, I should definitely spell a subject like Grammar correctly if I am chastising someones lack of familiarity with it, I could not have done that intentionally.

        Yes, we are both black :-)
  • battery usage? (Score:4, Interesting)

    by teridon ( 139550 ) on Sunday August 22, 2004 @08:29AM (#10037304) Homepage

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

  • by rossdee ( 243626 ) on Sunday August 22, 2004 @09:07AM (#10037432)
    "1000 factorial is calculated and displayed in the blink of an eye (the built in command takes 30 seconds)."

    So how big a display has this thing got if it can display 1000! Not sure how big it would be, my guess is somewhere between a googol and a googolplex.
  • ... but does the fact that talking about a calculator and feeling the need to link to a definition of the concept of a factorial shed a not-so-positive light on the average intelligence of the person reading this article?
  • ... 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.
    • The end is nigh.

      No it's not. Calculators are bought by two kinds of people.

      1) Students. Students can't use calculators with softkeys.

      2) Professionals. Most professionals want calculators that actually work, not some Gameboy hack designed by Joe Shmoe that comes up with 2.99998 when asked to calculate the square root of nine. (They also want calculators with tactile feedback, long battery life, and the ability to work after being dropped a couple of times.)

      [G]eneralization is cheaper than specific

To do two things at once is to do neither. -- Publilius Syrus

Working...