Post Reply 
Emulators / Simulators available as a library?
07-01-2019, 10:27 PM
Post: #5
RE: Emulators / Simulators available as a library?
(06-06-2019 03:08 AM)obrash Wrote:  Are any of the HP calculator emulators/simulators available in C or C++ library form - so that the core functionality (minus UI) could be easily invoked from another application?

I am experimenting with a general purpose system for program synthesis from examples and was thinking it would be fun to experiment with automatically generating programs for classic HP calculators (since I'm a fan). To minimize the work on my part (because I am lazy and have a real job) the easiest path to such an experiment would be to find an HP calculator "vm" in library form that I could adapt to provide the set of available operators to the program synthesis system.

Thanks in advance for any useful pointers.

newRPL is not exactly available as a library you can link to, but the code can be included directly in your application (it's plain C, and compiles fine with either gcc or clang), and yes, the GUI can be completely disregarded (though much of the code needs to be included due to some commands interacting with it, like WAIT, COPYCLIP, etc.). But other than taking space it doesn't affect functionality, just provide some memory for the GUI and forget it's even there.
As a matter of fact, newRPL uses the exact same codebase for the standalone newRPL-comp compiler that is a command line tool using the RPL compiler from C, no GUI there. If you start from that example you'll get to run RPL code in no time.
Once you get it to compile, using newRPL is quite easy:
  1. Call rplInit() to setup the newRPL execution environment (only once at the beginning).
  2. Compile some text with rplCompile() to get a pointer to an RPL object.
  3. Pass the object you received to rplSetEntryPoint(), and then call rplRun().
  4. Once rplRun returns, you have either the results on the data stack or an error condition.
  5. Repeat 2, 3 and 4 until you get tired.
  6. Extract results from the stack using rplPeekData() or rplPopData()/rplPushData() to take objects from the data stack. Once you have an object, call rplDecompile() to get its text representation.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Emulators / Simulators available as a library? - Claudio L. - 07-01-2019 10:27 PM



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