|More: NSSBWS HP-33s SLC # 01 |
Message #3 Posted by Paul Brogger on 9 Dec 2005, 12:43 p.m.,
in response to message #2 by Gene Wright
Right -- sorry for being incomplete. I'd edit the original post, but that feature has been disabled (for, I think, good reason), so here's more:
I use label "D" (for "Double Memory") for mine.
To store a value, I put the value itself in stack y, and the storage location (1 <= x <= 54) in stack x, and "XEQ D". The routine stores the value, and returns the value as stored (normalized to 5 digits) in stack x.
To recover a value, I put the negated storage location in stack x (-1 >= x >= -54) and "XEQ D". The routine returns the specified value in stack x.
After a "store" call, stack z is returned in y; for recall, stack y & z are maintained in place. As written, the routine uses flags 3 & 4, but it could probably use other, more obscure flags & leave 3 & 4 to the calling programs.
My solution starts mapping pseudo-registers to actual storage way up in the 6 statistics regs (half-register locations 1-12), and proceeds down to register A (half-registers 53 & 54). So if the calling routine needs a few regs, it can keep its storage low in the alphabet, and limit the range of pseudo-index values employed.
My solution utilizes registers V-Z, and restores the original contents of i before returning.
Potentially, similar techniques could be used to store reals of greater precision but reduced range (6 digits & 10^-9 -- 10^+9), 7-digit integers, or even more, smaller integers (perhaps as many as 81 4-digit values?)
Breaking it apart to utilize several labels would make it shorter overall, faster, and easier to understand & maintain. But I was going for the extremes.
And, I won't feel quite so pathologically geek-ish if someone finds it useful!
Edited: 9 Dec 2005, 2:34 p.m.