Stack Overflow Sensing
|
10-06-2014, 12:27 AM
Post: #2
|
|||
|
|||
RE: Stack Overflow Sensing
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.
http://WilsonMinesCo.com (Lots of HP-41 links at the bottom of the links page, at http://wilsonminesco.com/links.html#hp41 ) |
|||
« Next Oldest | Next Newest »
|
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: 1 Guest(s)