Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: I found a F...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 25 of 53 Topic 3681 of 4325
Post > Topic >>

Re: I found a FORTH stack optimzer, but could use a better version.

by "Rod Pemberton" <do_not_have@[EMAIL PROTECTED] > Jan 8, 2008 at 05:07 AM

"Albert van der Horst" <albert@[EMAIL PROTECTED]
> wrote in message
news:jubg5r.hy7@[EMAIL PROTECTED]
> In article <flus86$366$1@[EMAIL PROTECTED]
>,
> Rod Pemberton <do_not_have@[EMAIL PROTECTED]
> wrote:
> >
> >"Stephen Pelc" <stephenXXX@[EMAIL PROTECTED]
> wrote in message
> >news:478201e9.1788292609@[EMAIL PROTECTED]
> >> For Forth to Forth translation look at Timbre by Rob Chapman. Others
> >> have used it for host and embedded compilation.
> >>
> >
> >Actually, you may have referred me to the works of the correct person.
It
> >appears that Rob Chapman's "Stack Quarks" Sept. 15, 1995 are the
solution
to
> >optimizing FORTH stack words for x86 assembly.  He defines six words:
> >
> >  DIP DRIP NUP NIP TUCK TAKE
> >
> >Each of these corresponds 1:1 to x86 assembly instructions, as the C
> >versions in "Script.3" shows, i.e., they correspond to mov, push, or
pop.
>
> Interesting idea!
>
> >NIP and TUCK appear to be the standard definitions.  DROP, DUP, SWAP,
OVER,
> >are defined in terms of the six.  I don't see definitions for ROT,
or -ROT.
> >From the article, it seems he has/had a Timbre script for converting
FORTH
> >stack instructions similar to the java app.  The results using that app
> >showed that DUP,DROP,OVER correspond 1:1 to x86 assembly, but that
SWAP,
or
> >another stack ****ft instruction (ROT,-ROT,ROLL) was im****tant.
> > Relocating
> >the physical stack from location 0 to 2 of the virtual stack does
wonders...
>
> Isn't that dangerous in the situation of the x86 where the stack is
> used by interrupts too?
>

Dangerous in what way?  I'm not completely clear on which type of danger
you're asking about...

The stack state and stack pointer prior to the interrupt should be
restored
upon returning from the x86 interrupt.  Interrupts either a) use their own
stack or b) must reset the stack pointer if changed.  They shouldn't be
corrupting stack data that isn't theirs, but if they do, they must restore
it prior to returning from the interrupt or risk a crash...  (Was this
what
you were asking about?)  I don't see how this would be any different from
assembled C code, OS code, BIOS code.  In a typical x86 compiled C
application, there is only one stack.  The flow control information (stack
frame, program counter, instruction pointer, cpu flags, etc.) and local
variables are interleaved on the same stack.  This can lead to the well
known underflow/overflow buffer exploits.  (Or, was this what you were
asking about?)

FORTH, as I understand it, typically separates the data and tem****ary flow
control information by using two stacks: data, return.  As I understand
it,
the primary purpose of the return stack is to store the tem****ary flow
control information (return addresses).  This is much safer than a single
stack.  By using two stacks and not interleaving data and control flow
information, FORTH also eliminates the need for a stackframe required by
other languages.  I.e., no need for a compiler to copy data from where
it's
at on the stack to where it's needed on the stack - in FORTH it's already
there or can be moved quickly with stack operators.  I've recommended
separate stacks to some (insignificant) C people to eliminate buffer
exploits.  But, using two stacks does have some extra assembly overhead on
x86 - that I'm avoiding.

I also "see" a potential issue with the 1st and 2nd stack items, "top" and
"next", being in registers instead of on the stack. (Or, perhaps this was
what you were asking about?... :-)  They could be corrupted by other code
or
interrupts if care isn't taken to ensure they are preserved, or if care
isn't taken set them to registers which are known to be saved and
restored,
i.e., "callee-savee", by other code.


Rod Pemberton
 




 53 Posts in Topic:
I found a FORTH stack optimzer, but could use a better version.
"Rod Pemberton"  2008-01-06 00:26:01 
Re: I found a FORTH stack optimzer, but could use a better versi
mhx@[EMAIL PROTECTED] (M  2008-01-06 09:22:17 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 04:37:47 
Re: I found a FORTH stack optimzer, but could use a better versi
mhx@[EMAIL PROTECTED] (M  2008-01-06 11:00:53 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 06:10:48 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 06:24:17 
Re: I found a FORTH stack optimzer, but could use a better versi
mhx@[EMAIL PROTECTED] (M  2008-01-06 12:58:34 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:27:20 
Re: I found a FORTH stack optimzer, but could use a better versi
Coos Haak <chforth@[EM  2008-01-06 21:16:07 
Re: I found a FORTH stack optimzer, but could use a better versi
"Ed" <nospam  2008-01-07 17:51:08 
Re: I found a FORTH stack optimzer, but could use a better versi
Albert van der Horst <  2008-01-07 17:22:03 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 13:00:32 
Re: I found a FORTH stack optimzer, but could use a better versi
none <""jan\  2008-01-06 14:07:31 
Re: I found a FORTH stack optimzer, but could use a better versi
mhx@[EMAIL PROTECTED] (M  2008-01-06 15:27:04 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:32:53 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:05:30 
Re: I found a FORTH stack optimzer, but could use a better versi
stephenXXX@[EMAIL PROTECT  2008-01-06 13:42:55 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 06:09:25 
Re: I found a FORTH stack optimzer, but could use a better versi
stephenXXX@[EMAIL PROTECT  2008-01-06 13:46:06 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 18:25:08 
Re: I found a FORTH stack optimzer, but could use a better versi
stephenXXX@[EMAIL PROTECT  2008-01-07 10:58:44 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-07 21:39:25 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-07 22:57:58 
Re: I found a FORTH stack optimzer, but could use a better versi
Albert van der Horst <  2008-01-08 08:13:03 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-08 05:07:03 
Re: I found a FORTH stack optimzer, but could use a better versi
Albert van der Horst <  2008-01-08 18:26:32 
Re: I found a FORTH stack optimzer, but could use a better versi
Alex McDonald <blog@[E  2008-01-08 03:04:52 
Re: I found a FORTH stack optimzer, but could use a better versi
Roelf Toxopeus <these3  2008-01-06 15:24:29 
Re: I found a FORTH stack optimzer, but could use a better
winston19842005 <bjjly  2008-01-06 10:13:11 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:01:26 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:52:02 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:54:01 
Re: I found a FORTH stack optimzer, but could use a better versi
Bernd Paysan <bernd.pa  2008-01-06 18:34:43 
Re: I found a FORTH stack optimzer, but could use a better versi
helmwo@[EMAIL PROTECTED]   2008-01-06 10:27:48 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 13:26:05 
Re: I found a FORTH stack optimzer, but could use a better versi
Bernd Paysan <bernd.pa  2008-01-06 23:02:25 
Re: I found a FORTH stack optimzer, but could use a better versi
kenney@[EMAIL PROTECTED]   2008-01-07 09:47:13 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 13:43:00 
Re: I found a FORTH stack optimzer, but could use a better versi
Jenny Brien <jennybrie  2008-01-08 14:06:38 
Re: I found a FORTH stack optimzer, but could use a better versi
Bill <bill@[EMAIL PROT  2008-01-08 21:20:47 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-09 04:57:34 
Re: I found a FORTH stack optimzer, but could use a better versi
Jenny Brien <jennybrie  2008-01-10 09:50:29 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-11 03:34:02 
Re: I found a FORTH stack optimzer, but could use a better versi
"Jenny Brien" &  2008-01-11 17:49:07 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-12 04:31:21 
Re: I found a FORTH stack optimzer, but could use a better versi
astrobe <fdubois76@[EM  2008-01-14 09:31:33 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-19 10:11:10 
Re: I found a FORTH stack optimzer, but could use a better versi
stephenXXX@[EMAIL PROTECT  2008-01-20 15:33:32 
Re: I found a FORTH stack optimzer, but could use a better versi
ygrek <ygrek@[EMAIL PR  2008-01-06 12:31:47 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 17:58:45 
Re: I found a FORTH stack optimzer, but could use a better versi
anton@[EMAIL PROTECTED]   2008-01-06 18:22:00 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 18:18:56 
Re: I found a FORTH stack optimzer, but could use a better versi
ygrek <ygrek@[EMAIL PR  2008-01-07 09:05:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 13:57:48 CST 2008.