Post Reply 
Emu48 - Load, Save As, Save Programmatically
10-15-2021, 09:17 PM
Post: #1
Emu48 - Load, Save As, Save Programmatically
Is it possible to programmatically load a file into the Emu48? What about save as or save?
Find all posts by this user
Quote this message in a reply
11-20-2021, 04:29 PM
Post: #2
RE: Emu48 - Load, Save As, Save Programmatically
(10-15-2021 09:17 PM)MNH Wrote:  Is it possible to programmatically load a file into the Emu48? What about save as or save?

To my knowledge this is currently not possible. Emu48 halts the (HP48) system when it does file operations because it has to read/change RAM pointers in order to prevent program execution from possibly changing the content of what is (or is going to be) on the user's stack. File loading/saving are operations on the computer side and Emu48 would have to implement new ways for the emulated system (the HP48 operating system) to interact with the computer operating system. Since the source code is available, I suppose it could be possible. One possible method would be to create a "new" opcode at the assembly language level. The emulator would trap this opcode, pause emulation and do the appropriate operations on the operating system side: use the data stack pointer to copy the appropriate bits and save it as a new file. The file names will probably have to be generically named (maybe the file name could also be timestamped and the root of the name is something set in the Emu48 settings) to keep things simple. As far as the "new" opcode is concerned, using a NOP opcode inside an "empty" code object.

Code:
CODE
        GOSBVL  =SAVPTR
        NOP
        GOTO    +
        NIBHEX  12345
+       GOSBVL  =GETPTRLOOP
ENDCODE

The "12345" would be a 5-bit code designating what sort of operation this is (e.g. 00001 might mean save, 00002 could be load, etc.) and could be any width; I just picked 5 arbitrarily. So Emu48 would check to see if NOP is followed by a GOTO statement that skips only 5 bits and immediately ends in a jump back to RPL. Emu48 would then execute the proper operating system functions (save, load, etc) based on the 5-bit code. These different operations would be implemented as library commands. Anyone accidentally executing these commands on a real calculator would see no harm done since all the commands would be basically no-operation commands that only Emu48 would be aware of.

If you wanted to get fancy, you could even have a string on the stack be used as the file name. For example, the 5-bit value 00003 might be used for a load command using the string on the user data stack as the file name.

You would have to implement this yourself, or perhaps you could contact Christoph Giesselink who currently maintains Emu48 to see if he could add this as a feature.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
11-20-2021, 05:06 PM
Post: #3
RE: Emu48 - Load, Save As, Save Programmatically
(11-20-2021 04:29 PM)Han Wrote:  You would have to implement this yourself, or perhaps you could contact Christoph Giesselink who currently maintains Emu48 to see if he could add this as a feature.

Thank you very much for answering my post! I have high hopes that Christoph will continue to add features to the Emu48. I enjoy the convenience of using it on my smartphone. Also, the fact that I could one day figure out how to use it to communicate with a survey instrument or a survey GPS unit is very exciting to me. I do this only as a hobby, but it gives me great pleasure to figure out how to make things work.
Find all posts by this user
Quote this message in a reply
Post Reply 




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