Post Reply 
Little explorations with HP calculators (no Prime)
03-22-2018, 02:16 AM (This post was last modified: 03-22-2018 02:17 AM by brickviking.)
Post: #288
RE: Little explorations with Casio 9750/9860 calculators
(03-21-2018 10:45 AM)3298 Wrote:  The 9860 series also adds a list label (basically a string) as List n[0], but I can't remember if that existed before OS 2.0 or only after.

It's on my gII but not on my g+. I'm pretty sure it's mentioned in the manual for all gII versions, including the 9750.

(03-21-2018 10:45 AM)3298 Wrote:  
(03-20-2018 11:59 PM)brickviking Wrote:  ... I generally use the last List on the calculator in the last File so it's less likely to get in the way of already-created Lists....

Plenty of people do that, but it breaks down when the program you're calling does the same on exactly that list (and the last list in file 6 is quite commonly used for that purpose), because the list cannot really be operated as a stack, so the called program will overwrite the caller's saved variables.

You could do it this way, store the Last-Used count in the first position of List6, and start counting from *LastUsed. It's sort of a stack, with the warning that you'd better reset the pointer when you've finished with it and presumably flush the variables too. That functionality could go into the "Clean-up" phase, though as you rightly point out, this won't work as well for calling subroutines. Consider it a bit like malloc/free pairs. Even if you use the full stride of 28 each time, you'd still end up with over 35 calls before you ran out of space in your stack.

If you get fiddly, you can sacrifice a slot each "segment" and use that to specify the size of the next segment, i.e. first one's 28, second one's ten, Listn[1] is how far to skip down for the first unused slot (LastUsed), Listn[2] is how large the first segment is before hitting another sement count.

Code:
All code refers to whichever Listn (List1..26) you're using for your stack.

Listn[1]=79,4i (LastUsed,Seg[ment]Cnt)
[2]=28 (Seg1Cnt)
[3]..[30] (Seg1)
[31]=10 (Seg2Cnt)
[32]..[41] (Seg2)
[42]=16 (Seg3Cnt)
[43]..[58] (Seg3)
[59]=20 (Seg4Cnt)
[60]..[79] (Seg4)
Pseudocode flows a bit like this:
  • Read First value.
  • peel off complex var portion (n), this tells me how many "segments" I stored.
  • from 1 to n
  • * Read value
  • * step forward that many to get next segment counter,
  • * increment n,
  • loop
  • Read final value

I can then restore that many variables. Yes, there are weaknesses in this, I haven't fully got my head around the aspects of shutting down programs in mid-stream without cleaning up the stack list.

(03-21-2018 10:45 AM)3298 Wrote:  But let's get back on track, shall we? Smile

This is fun, though I suspect this post could have gone into another forum.

(Post 193)

Regards, BrickViking
HP-50g |Casio fx-9750G+ |Casio fx-9750GII (SH4a)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Little explorations with Casio 9750/9860 calculators - brickviking - 03-22-2018 02:16 AM



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