3 ms·
The programmer took great care about register allocation. On this topic, the Saturn CPU of the HP-48 handheld calculator of the 90's had quite a lot of registe
by s_gourichon 7y ago
The programmer took great care about register allocation.
On this topic, the Saturn CPU of the HP-48 handheld calculator of the 90's had quite a lot of registers (9 of them 64-bit, plus a number of others and a hardware return stack) yet a 4-bit wide bus.
The whole CPU was optimized for BCD (binary coded decimal) computation and registers were structured into "fields" varying length. Thus you could program relatively advanced algorithms without having to swap registers with memory or stack all the time like on e.g. the Z80.
This allowed to write quite advanced things. For example I wrote ASM code that compiles to a 18kb binary where you can walk into a complex dungeon rendered in perspective with shading, with writings on walls, monsters, you can find objects, pick them, throw them, climb stairs, fall in pits.
See http://amphi-gouri.org/hp48/dm48/ http://amphi-gouri.org/hp48/dm48/ for details.
- mruts 7y agoI’ve played it! Still have my HP48 though I only use the 50g anymore (the Prime is terrible). Unfortunately they didn’t feel like porting RPL to ARM and instead went the Saturn emulation route. When I was younger I tried programming a simple interpreted stack language using the hpgcc tools to compile the interpreter to an ARM binary. Testing with simple loops, a naive interpreter was 80x faster than sysRPL! It’s too bad HP hss stopped caring about craftsmenship anymore.
- s_gourichon 7y ago> I've played it! Thanks for telling! I still have my HP48-S and HP48-GX where I coded the thing. (Yes, all DM48 was written on a HP48G with 128kb storage and compiles on it.) > Unfortunately they didn’t feel like porting RPL to ARM and instead went the Saturn emulation route. I understand that. The HP48 operating system is special. There is no actual RPL interpreter. The way objects are coded incorporates not arbitrary data but ROM address of code handling it. Executing RPL is like handling a linked list from ASM and jumping to the next node after processing each, but the ASM code to jump is not in some well-located place, it's at the end of each routine, where you would expect a "return". It's only a few bytes longs. No wonder it was muuuch simpler to emulate Saturn than reimplement the whole thing in ARM. > Testing with simple loops, a naive interpreter was 80x faster than sysRPL! Which sysRPL? Below user RPL, there sysRPL features comes at many depths. The lower ones are quite fast, the higher ones pile feature other feature and are much slower. Regular RPL is on top on HP48-S. On GX they piled even further, adding visible menus and lots of shenanigans below due to memory bank switching. > It’s too bad HP hss stopped caring about craftsmenship anymore. Like the Amstrad CPC, the HP-48 was very well thought out at the beginning. The design was a bonus at the beginning, but it was difficult to evolve it and maintain compatibility. After hardware evolves a lot (speed, memory), and emulation is an easy option, it's not economically feasible to justify the attention to details that matters to people like us.
- acqq 7y agoSadly, the source code is unreadable without the emulator.
- s_gourichon 7y agoNot yet fully complete, but all the source code for run-time is there: https://github.com/fidergo-stephane-gourichon/dm48 https://github.com/fidergo-stephane-gourichon/dm48
- deleted 7y ago[deleted]
- s_gourichon 7y agoNow updated the repository and tested compilation. I generated a new binary with updated web site and e-mail address. https://github.com/fidergo-stephane-gourichon/dm48 https://github.com/fidergo-stephane-gourichon/dm48