home .. forth .. colorforth mail list archive ..

RE: [colorforth] FS/Forth for DOS: crude performance test


> I kept hearing about "pigeon-hole optimization", and now I can see where
> two inlined primitives will have xchg's that cancel out.

I implemented code to test this compared to other forms, and found out that it
was actually the slowest method of native code generation.  Even for various
threading mechanisms, accessing the stack using indexed addressing modes is
about 17% faster than using PUSH and POP, even if you optimize out the XCHG
instructions.

> >One problem with BP is that in the instruction encoding a nul displacment is
> >mandatory in all cases whereas it is not with [DI] and [SI]. OTOH you can
> >sometimes take advantage of the fact that you can index down your data
> >stack:
> >: SWAP XCHG AX,[BP+2] ;
> >But I guess you know that.
> >
> This is better than the SWAP I had. When I was first writing it, I thought
> that INC affected the x86 flags, but it doesn't (at least not the zero flag)
> So I was doing something strange like:
> 
> : XOR   INC BP  INC BP  XOR AX,[BP-2] ;

I find it is faster to do something like this instead:

: XOR   XOR AX,[BP]   LEA BP,[BP+2] ;

As indicated above, [BP] is implicitly [BP+0000h] at all times (and to make
matters worse, it's a 16-bit offset always).  If you use another register, such
as SI or DI, you can eliminate that offset, without any performance penalty.

> Sorry to everyone for wandering off-topic -- ColorForth. (Haven't been able
> to get it to run, but I haven't tried some of the other modified versions
> yet. I think one of them supports the old S3 video chip..)

I'm not sure it's off-topic, since ColorForth employs a static, native code
generating compiler which uses techniques such as the above.  Only it uses
LODSD to implement DROP, which is a complex (and hence, slow) instruction on
all modern architectures.  It's much faster to implement DROP as MOV EAX,[ESI] 
 LEA ESI,[ESI+4] .

--
Samuel A. Falvo II


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com