Open sijanec opened 4 years ago
Hi Šijanec, Sorry for the late reply.
The core hack of HPGCC happens in ARM Toolbox, aka Lib275, which provides a single ROM pointer xPrRUN
that could escape from the emulator, and execute the arbitrary string on the stack as a piece of ARM native code.
If you only have a HP 39 series calculator, it might be difficult to figure out where is the stack, what is an aplet, how to program with System RPL and so on -- since these are deliberately obscured and hidden by HP from the 39 series. So even if you were only interested in programming HP 39, it would be definitely helpful to have a HP 49 (either use a x49gp emulator, or flash a 39gs into a 48gII, or just buy one) along with its user guide, which would allow you to have direct access to the stack, the file hierarchy, UserRPL, SysRPL, etc -- and help you understand all the underlying concepts.
The .hp
file is intended for use with the HP 49 series, and the .apt
or .000
folder (yes, aplets are SysRPL folders with particular structure) is intended for HP 39. If you use a 49 series, you do not necessarily need elf2hp
or hp2aplet
, since these are no more than RPL boilerplate generators that help you create a script to put the ARM code as a string on the stack and then execute the xPrRUN
hack. However, HP 39 series do not include UserRPL support (read "access to the stack"), so you must compile a wrapper SysRPL program for that, either into an aplet or into a library.
To make things easier for those not familiar with SysRPL and just want to program with C, the HPGCC team shipped their toolchain with hp2aplet
and a compiled SysRPL binary -- HPGCC000.000
. The original SysRPL source code is here (I've highlighted the core part that push ARM native code to the stack and xPrRun
:-). The hp2aplet
program reads the SysRPL HPGCC000.000
as the template and patch the placeholder ARM CODE HERE!!!
with the actual binary code, so that users do not need a working SysRPL compiler installation to work with HPGCC. However if you developed an interest in SysRPL, the HPGCC boilerplate could be a nice start to understand how to create a aplet with SysRPL. Since the original hp2aplet
does not fit all my needs -- it forces me to create a splash screen (well, a 49-ish one -- press Enter to execute and ON to exit) in the aplet -- I've forked it to remove the splash screen and named the fork minstub39.
So back to your questions. If you do not wrap your code in an aplet, you still need to pack it into a library or something else, since there's no way to push it onto the stack of HP 39 series manually. In case that helps, I've attached both my HPGCC000.000
aplet template and the original HPGCC hp2aplet
, but do not mix them together, since the offsets in my fork does not match the original; i.e. either use my hp2aplet
fork with my HPGCC000.000
, or use both hp2aplet
and SysRPL binaries from the zip archive. My SysRPL aplet binary was compiled with HP Tools and make hpgccaplet.apt
.
Sorry for my late reply again. I've been really busy with my life stuff these days, since the coronavirus outbreak in Wuhan last year delayed my research work for months, and now it's payback time :-) Here is the datasheet of the S3C2410X SOC, which is useful for native ARM programming on the calculator. Glad to hear from you if you have more questions.
Hello!
Thank you very much for your very detailed reply.
I now understand things much clearer now. Thanks for attaching your assembled HPGCC000.000, I can see the difference. I will try to include the produced ARM code with your hp2aplet.c.k into the placeholder and I am going to try it on an emulator of a 49 series when I will be back from vacation. I will get more familiar with the SysRPL and the 49 series, since I only ever used the HP48G calculator before and only wrote code for it with it's builtin RPN scripting language.
I am glad to hear you are managing the corona-situation over there.
Regards, Anton.
(Sent from a mobile device)
On Sat, 10 Oct 2020, 01:15 Arnie97, notifications@github.com wrote:
Hi Šijanec, Sorry for the late reply.
The core hack of HPGCC happens in ARM Toolbox, aka Lib275, which provides a single ROM pointer xPrRUN that could escape from the emulator, and execute the arbitrary string on the stack as a piece of ARM native code.
If you only have a HP 39 series calculator, it might be difficult to figure out where is the stack, what is an aplet, how to program with System RPL and so on -- since these are deliberately obscured and hidden by HP from the 39 series. So even if you were only interested in programming HP 39, it would be definitely helpful to have a HP 49 (either use a x49gp emulator, or flash a 39gs into a 48gII, or just buy one) along with its user guide, which would allow you to have direct access to the stack, the file hierarchy, UserRPL, SysRPL, etc -- and help you understand all the underlying concepts.
The .hp file is intended for use with the HP 49 series, and the .apt or .000 folder (yes, aplets are SysRPL folders with particular structure) is intended for HP 39. If you use a 49 series, you do not necessarily need elf2hp or hp2aplet, since these are no more than RPL boilerplate generators that help you create a script to put the ARM code as a string on the stack and then execute the xPrRUN hack. However, HP 39 series do not include UserRPL support (read "access to the stack"), so you must compile a wrapper SysRPL program for that, either into an aplet or into a library.
To make things easier for those not familiar with SysRPL and just want to program with C, the HPGCC team shipped their toolchain with hp2aplet and a compiled SysRPL binary -- HPGCC000.000. The original SysRPL source code is here https://github.com/Arnie97/minstub39/blob/a0f46c97f77a168ee352a0c8d84fe4255364dd4e/hpgccaplet.s#L200-L210 (I've highlighted the core part that push ARM native code to the stack and xPrRun :-). The hp2aplet program reads the SysRPL HPGCC000.000 as the template and patch the placeholder ARM CODE HERE!!! https://github.com/Arnie97/minstub39/blob/a0f46c97f77a168ee352a0c8d84fe4255364dd4e/hpgccaplet.s#L252 with the actual binary code, so that users do not need a working SysRPL compiler installation to work with HPGCC. However if you developed an interest in SysRPL, the HPGCC boilerplate could be a nice start to understand how to create a aplet with SysRPL. Since the original hp2aplet does not fit all my needs -- it forces me to create a splash screen (well, a 49-ish one -- press Enter to execute and ON to exit) in the aplet -- I've forked it to remove the splash screen and named the fork minstub39.
So back to your questions. If you do not wrap your code in an aplet, you still need to pack it into a library or something else, since there's no way to push it onto the stack of HP 39 series manually. In case that helps, I've attached both my HPGCC000.000 aplet template https://github.com/Arnie97/clock-tuner/files/5356919/Minstub39.Aplet.Boilerplate.zip and the original HPGCC hp2aplet https://github.com/Arnie97/clock-tuner/files/5356922/HPGCC.Original.Aplet.Boilerplate.zip, but do not mix them together, since the offsets in my fork does not match the original; i.e. either use my hp2aplet fork with my HPGCC000.000, or use both hp2aplet and SysRPL binaries from the zip archive. My SysRPL aplet binary was compiled with HP Tools https://www.hpcalc.org/details/3788 and make hpgccaplet.apt https://github.com/Arnie97/minstub39/blob/master/Makefile.
Sorry for my late reply again. I've been really busy with my life stuff these days, since the coronavirus outbreak in Wuhan last year delayed my research work for months, and now it's payback time :-) Here is the datasheet of the S3C2410X SOC https://github.com/Arnie97/clock-tuner/files/5357959/S3C2410X.pdf, which is useful for native ARM programming on the calculator. Glad to hear from you if you have more questions.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Arnie97/clock-tuner/issues/2#issuecomment-706439841, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKFM2ETUYFTLF2QCADRX6ZTSJ6KRXANCNFSM4RYOU6YA .
Hello!
I run
Linux kondenzator 5.3.0-59-generic #53~18.04.1-Ubuntu SMP Thu Jun 4 14:58:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
. The aplet won't compile claiming it can't open HPGCC000.000. Isn't this file supposed to be the file where the aplet will be contained?I compiled your hp2aplet software and it seems to me that this is where the error happens.
Do you know of any way to run clock_tuner.hp on HP 39gs directly without converting it into an aplet?
This is the
clock_tuner.hp
file:And this is the
clock_tuner.apt
file (incomplete, of course).I had to modify lines 24 and 25 of Makefile to use forward-slashes instead of backwards-slashes.