Dual Stack Design Question



#7

Hello All,

I am thinking about updating and old HP41-based design of a Windows application for a programmable RPN calculator. My question is this regarding the stack. How do you feel about having a secondary stack to push and pop intermediate results. HP designed the older calculator with a fixed 4-register autmatic stack. We often used it to store intermediate results when calculations allowed this. Otherwise, we store results in memory registers and recall them when we need to. How about a SECONDARY stack (say with 10 registers) to which we push intermediate results and pop them back (to the main stack) when we need them???


Namir


#8

How about a single stack of arbitrary depth?


#9

The nice thing about two stacks is that you can seperate them logically. So the main stack is my normal RPN/RPL parameter passing, intermediate result thing, and this other guy is what I say it is. Say that now it's a place to accumulate a list of values (you can do this with a real list in RPL.) and later it's a place to store successive results of an iterative process. I then don't have to juggle parameters as much because they stay undisturbed on the "main" stack. Forth gives you multiple stacks in many implementations.

How about a stack data type? You then allocate or abandon them as needed. Good (perhaps psychic 8) GC would be needed.

Regards,

Howard

Edited: 6 Feb 2006, 3:10 p.m.

#10

A somewhat longer stack (or virtually infinite, only limited by the total memory-space allocated to it) would do fine. For normal calculations 4 stack positions is fairly enough though, also for temporarely storing results to be used later.

#11

Sounds like Forth, it has an arbitrarily deep regular stack and a return stack. The return stack normally deals with program flow control but you can use for anything that you'd like. http://www.forth.org/svfig/Len/softstak.htm I used to do a bunch of programming in a forth-like language of my own design but rarely found the need to use the return stack for intermediate calculation results.

#12

I think we have been through this discussion before.

If you want compatibility with existing programs you cannot change the stack size (will break assumptions of how the stack will look like after RDN, R^ and stack drop).

So how about a pointer into a "large" register bank that tells
you where your 4+1 stack is located. You can have a command (say STACK nnn) that sets the stack pointer.

Default is STACK 000. If you want to create a new stack use STACK 005.


OR

You may even have a PUSHST and POPST that "push" and "pop" your entire stack into a stack-of-stacks. But why stop at that? Why not save additional processor state (e.g. flags), program file, etc so that you can push you entire HP41 CPU state into the stack, carry out your task and then pop it. Note that you will need some way of accessing data from that stack so that you can retrieve arguments and return results. In this way you can implement a "native" HP-41 command that retains stack contents, LASTx, ALPHA, flags etc, that is not part of the spec of the command.


**vp

BTW the first technique is used in RISC processors like the MIPS.


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP-80 History, Design and Interesting Facts BShoring 1 1,392 11-30-2013, 08:50 AM
Last Post: Xavier A. (Brazil)
  HP 50g - select characters on the stack, copy/paste Sean Freeman 7 2,799 11-20-2013, 07:11 AM
Last Post: Sean Freeman
  Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 2,331 11-19-2013, 08:59 AM
Last Post: Miguel Toro
  emu48 - copy stack doesn't work (as expected) Thomas Radtke 2 2,018 11-11-2013, 02:19 PM
Last Post: Thomas Radtke
  HP Prime Stack operations from within a program John Colvin 1 1,433 11-08-2013, 09:45 PM
Last Post: Helge Gabert
  Prime: Anyway to refresh stack? kris223 5 2,211 10-16-2013, 05:09 PM
Last Post: kris223
  hp prime - sending program results to the stack giancarlo 6 2,182 10-15-2013, 02:00 AM
Last Post: Giancarlo
  HP Prime - RPN stack access from programs? Mike Mander (Canada) 10 3,514 09-30-2013, 11:20 AM
Last Post: steindid
  WP-34S: Stack after divide by 0 Marcel Samek 4 1,448 08-24-2013, 11:57 PM
Last Post: Paul Dale
  Little curiosity: why the fourth stack register is called "T"? Antlab 34 8,892 07-03-2013, 04:49 PM
Last Post: Walter B

Forum Jump: