![]() | ||
| Home | SwiftX Archive | SwiftForth Archive | |

In this case (the Atmel AVR family), the overhead would be even worse than that.
DUP is only two instructions and the compiler substitutes them in place of a
call to DUP in definitions. In order to do stack bounds checking (both overflow
and underflow), DUP would require TWELVE MORE INSTRUCTIONS! Imagine
instrumenting the entire kernel with this baggage!!
About the value returned by DUP (OVER, 2DUP, 2OVER, etc) on an empty stack. The
stack is just memory. The base of any task's stack is not necessarily the edge
of the world. So the DUP operator makes a copy of whatever happens to be in
memory following (or prior to, depending on which way your stacks grow) the base
of the task's stack.
> -----Original Message-----
> From: swiftx-bounce_at_forth.com [mailto:swiftx-bounce_at_forth.com]On Behalf
> Of Elizabeth D. Rather
> Sent: Thursday, April 11, 2002 17:31
> To: Swiftx Listserve
> Subject: [swiftx] Re: DUP, AVR SwiftX
>
>
>
> Stack checking is performed at the user interface, not internally (unless
> you build it in yourself).
> In other words, if you type commands during testing, the stack will be
> checked for underflow between the commands you type, but not internally
> within those commands. The reason is simple: overhead. To check the
> stack in DUP, for example, would roughly double its cost, 100% overhead.
>
> Detecting stack problems is pretty easy if you follow the recommended
> debugging procedure of testing your application words individually,
> bottom-up (lowest-level words first). Always make sure the stack effect
> corresponds to the stack comment in the source file! Never write a great
> long application and start by testing its highest-level command, that's a
> recipe for hours of frustration.
>
> The occurrance of that particular number is probably a consequence of
> whatever's happening in your program prior to the underflow (in otherwords,
> it could have happened a while before the DUP).
>
> Cheers,
> Elizabeth
>
> At 05:04 PM 4/11/02 -0700, Gene Silvernail wrote:
> >Something as simple as DUP bit me. I've always assumed that DUP checks the
> >stack and would error if the stack was empty, not so.
> >
> >Don't have the exact number but....
> >
> >When DUP is run on an empty stack I get the number 658, I believe, in
> >return. Not 2 numbers, ie the original and a copy but just the one
> >658. No indication that that the stack was empty.
> >
> >Late one night I actually provided 2 errors in a word that countered each
> >other. The 1st was the use of DUP with an empty stack and the 2nd placed
> >a number on the stack that made up for the empty DUP stack.
> >
> >How or where does one look or find which words perform a test on the stack??
> >
> >Gene SIlvernail
> >
> >
> >----------------------------------------------------------------------
> >swiftx_at_forth.com The SwiftX programming discussion email list
> >To unsubscribe, send subject "unsubscribe swiftx" to listar_at_forth.com
> >For help with listar commands, send subject "help" to listar_at_forth.com
> >Archives are located at http://www.forth.com/swiftx -- check them out!
> >----------------------------------------------------------------------
> >THIS LIST IS NOT FOR BUG REPORTS! Send bug reports to support_at_forth.com.
>
> ==================================================
> Elizabeth D. Rather (US & Canada) 800-55-FORTH
> FORTH Inc. +1 310-491-3356
> 5155 W. Rosecrans Ave. #1018 Fax: +1 310-978-9454
> Hawthorne, CA 90250
> http://www.forth.com
>
> "Forth-based products and Services for real-time
> applications since 1973."
> ==================================================
>
> ----------------------------------------------------------------------
> swiftx_at_forth.com The SwiftX programming discussion email list
> To unsubscribe, send subject "unsubscribe swiftx" to listar_at_forth.com
> For help with listar commands, send subject "help" to listar_at_forth.com
> Archives are located at http://www.forth.com/swiftx -- check them out!
> ----------------------------------------------------------------------
> THIS LIST IS NOT FOR BUG REPORTS! Send bug reports to support_at_forth.com.
>
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe swiftx" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/swiftx -- check them out!
----------------------------------------------------------------------
THIS LIST IS NOT FOR BUG REPORTS! Send bug reports to support_at_forth.com.
Received on Fri Apr 12 2002 - 08:26:50 PDT
This archive was generated by hypermail 2.2.0 : Wed Jan 07 2009 - 03:04:23 PST