Post Reply 
Stack Overflow Sensing
10-07-2014, 07:56 PM
Post: #3
RE: Stack Overflow Sensing
(10-06-2014 12:27 AM)Garth Wilson Wrote:  You don't need any extra hardware. My initial exposure to a stack was my HP-41, so it was natural to think of things getting copied from one register to the next like the manuals show. This is very inefficient though. What is routinely done in programming at levels that give the user tighter control of the machine, primarily meaning (but not limited to) assembly language, does not involve so much (or necessarily any) copying, but rather just incrementing or decrementing a pointer which acts as an offset to the stack area of memory. The pointer rolls over wherever the number of bits hits a limit; so if you have 8 registers, you use 3 bits for the pointer. When it goes from binary 111 to 000, or vice-versa, you have stack underflow or overflow, depending on the direction you make the stack grow. The depth of the stack could be displayed all the time if desired, or checked only when desired. Stack initialization can be as simple as zeroing the pointer.

I suppose you're right that an extra Stack Overflow sensing register above the T register would not be necessary. The firmware would only have to watch for a state where a stack lift is done while the T register is "non-empty". But stack initialization with Stack Overflow Sensing ON would need more than zeroing a pointer, it would need to set at least Y, Z and T to the "empty" state. X could be left unchanged (maybe that is even more useful than setting it to zero for historical reasons).

The only "hardware" needed would be a CLS key function (that could even be named "SOS") and a NO ("No Overflow") annuntiator that appears on pressing the CLS/SOS key and disappears on Stack Overflow.

Very unintrusive when you don't need it, very useful when you would like to watch for stack overflow in a complicated long calculation on an RPN calculator with a limited stack height.

Hans
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Stack Overflow Sensing - hansklav - 10-05-2014, 11:39 PM
RE: Stack Overflow Sensing - Garth Wilson - 10-06-2014, 12:27 AM
RE: Stack Overflow Sensing - hansklav - 10-07-2014 07:56 PM
RE: Stack Overflow Sensing - walter b - 10-07-2014, 08:15 PM
RE: Stack Overflow Sensing - hansklav - 10-07-2014, 09:10 PM
RE: Stack Overflow Sensing - Paul Dale - 10-07-2014, 10:18 PM
RE: Stack Overflow Sensing - hansklav - 10-09-2014, 09:12 PM
RE: Stack Overflow Sensing - Garth Wilson - 10-07-2014, 10:10 PM



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