Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #13174

Re: SEE in gforth 7.0.0 64 bits

From "Rod Pemberton" <do_not_have@notemailnot.cmm>
Newsgroups comp.lang.forth
Subject Re: SEE in gforth 7.0.0 64 bits
Date 2012-06-22 16:01 -0400
Organization Aioe.org NNTP Server
Message-ID <js2is7$d59$1@speranza.aioe.org> (permalink)
References <m5zjxf.lgd@spenarnc.xs4all.nl> <7xlijgw00e.fsf@ruckus.brouhaha.com> <66e90eec-da8d-4b9c-862c-b4a4aef7f4b0@d6g2000vbe.googlegroups.com>

Show all headers | View raw


"Mark Wills" <markrobertwills@yahoo.co.uk> wrote in message
news:66e90eec-da8d-4b9c-862c-b4a4aef7f4b0@d6g2000vbe.googlegroups.com...
> On Jun 22, 3:31 am, Paul Rubin <no.em...@nospam.invalid> wrote:
...

> > Works fine for me on an Intel Core 2:
> >
> > Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
> > Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
> > Type `bye' to exit
> > see dup
> > Code dup
> > 0x00000000004060be <gforth_engine+9470>: mov
> > %rbx,0x23b63b(%rip) # 0x641700 <saved_ip>
> > 0x00000000004060c5 <gforth_engine+9477>: mov (%r15),%rdx
> > 0x00000000004060c8 <gforth_engine+9480>: mov %r15,%rax
> > 0x00000000004060cb <gforth_engine+9483>: lea -0x8(%r15),%r15
> > 0x00000000004060cf <gforth_engine+9487>: add $0x8,%rbx
> > 0x00000000004060d3 <gforth_engine+9491>: mov %rdx,-0x8(%rax)
> > 0x00000000004060d7 <gforth_engine+9495>: mov -0x8(%rbx),%rbp
> > 0x00000000004060db <gforth_engine+9499>: mov %rbp,%rax
> > 0x00000000004060de <gforth_engine+9502>: jmpq 0x403c21
> > <gforth_engine+97>
> > end-code
> > ok
>
> Wow. Don't want to hijack this thread, but why so much code for a DUP?
>

The x86 instruction set is setup for pushes and pops to stacks, not "shifts"
or "copies" of stack items.  So, stack to stack moves or stack copies are
"expensive" on x86, e.g., ROT or ROLL and slightly so for DUP.  It's
probably best to keep the top two data stack items in registers on x86.
Then, DUP or SWAP etc can be a single instruction.  However, using registers
for TOS and NOS (2nd) means that stack words using more than two items
become more "expensive" in terms of instructions used, e.g., OVER, ROT, etc.
The 2-series of instructions become even more "expensive".  x86 is also
setup for just one stack.  A C compiler typically uses that stack and
associated registers (%esp, %ebp) for itself for it's procedure stackframes.
So, for a Forth in C, other registers must be used for Forth's
data/parameter stack pointer (e.g., SP) and return stack pointer (e.g., RP).
The x86 instruction set isn't as effective using multiple stacks.  So, using
stacks through other registers is "expensive", i.e., no specialized
instructions, recall x86 is CISC.  So, the choice is to use more generic
instruction sequences, or swap registers to use more effective x86 stack
instructions.  A C compiler generally won't do the latter (it preserves the
registers it uses), i.e., more effective code requires assembly.


Rod Pemberton


Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

SEE in gforth 7.0.0 64 bits Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-06-21 21:05 +0000
  Re: SEE in gforth 7.0.0 64 bits Josh Grams <josh@qualdan.com> - 2012-06-21 22:52 +0000
    Re: SEE in gforth 7.0.0 64 bits Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-06-22 11:25 +0000
    Re: SEE in gforth 7.0.0 64 bits Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-06-22 12:23 +0000
      Re: SEE in gforth 7.0.0 64 bits anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-06-22 11:57 +0000
        Re: SEE in gforth 7.0.0 64 bits Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-06-22 20:42 +0000
          Re: SEE in gforth 7.0.0 64 bits rugxulo@gmail.com - 2012-06-24 05:28 -0700
  Re: SEE in gforth 7.0.0 64 bits Paul Rubin <no.email@nospam.invalid> - 2012-06-21 19:31 -0700
    Re: SEE in gforth 7.0.0 64 bits Mark Wills <markrobertwills@yahoo.co.uk> - 2012-06-22 00:54 -0700
      Re: SEE in gforth 7.0.0 64 bits anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-06-22 11:16 +0000
        Re: SEE in gforth 7.0.0 64 bits "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-06-22 16:17 -0400
          Re: SEE in gforth 7.0.0 64 bits anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-06-23 13:51 +0000
            Re: SEE in gforth 7.0.0 64 bits "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-06-24 04:06 -0400
              Re: SEE in gforth 7.0.0 64 bits Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-06-24 06:55 -0500
              Re: SEE in gforth 7.0.0 64 bits anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-06-24 13:24 +0000
                Re: SEE in gforth 7.0.0 64 bits "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-06-24 18:44 -0400
                Re: SEE in gforth 7.0.0 64 bits Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-06-25 05:00 -0500
                Re: SEE in gforth 7.0.0 64 bits "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-06-25 17:54 -0400
                Re: SEE in gforth 7.0.0 64 bits Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-06-26 03:41 -0500
            Re: SEE in gforth 7.0.0 64 bits rugxulo@gmail.com - 2012-06-24 05:25 -0700
              Re: SEE in gforth 7.0.0 64 bits anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-06-24 14:08 +0000
                Re: SEE in gforth 7.0.0 64 bits rugxulo@gmail.com - 2012-06-25 07:56 -0700
        OT: fixing Mark's A0's, was [Re: SEE in gforth 7.0.0 64 bits] "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-06-22 16:18 -0400
          Re: OT: fixing Mark's A0's, was [Re: SEE in gforth 7.0.0 64 bits] Marc Olschok <nobody@nowhere.invalid> - 2012-06-25 12:42 +0000
            Re: OT: fixing Mark's A0's, was [Re: SEE in gforth 7.0.0 64 bits] Mark Wills <markrobertwills@yahoo.co.uk> - 2012-06-25 06:30 -0700
              Re: OT: fixing Mark's A0's, was [Re: SEE in gforth 7.0.0 64 bits] rugxulo@gmail.com - 2012-06-25 08:04 -0700
                Re: OT: fixing Mark's A0's, was [Re: SEE in gforth 7.0.0 64 bits] Mark Wills <markrobertwills@yahoo.co.uk> - 2012-06-25 11:00 -0700
                Re: OT: fixing Mark's A0's, was [Re: SEE in gforth 7.0.0 64 bits] "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-06-25 17:47 -0400
      Re: SEE in gforth 7.0.0 64 bits "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-06-22 16:01 -0400
  Re: SEE in gforth 7.0.0 64 bits Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2012-06-24 15:15 +0100

csiph-web