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

[colorforth] Disassembling Pentium ColorForth


Hello all,

I was wondering if someone could help me dissassemble
a small CF word.

: digit -9 + -if 57 + ; then 64 + ;

From the Pentium instruction defs I think this should 
be:

         add EAX, -9
         jns label
         add EAX, 57
         ret
label    add EAX, 64
         ret

I wrote this to compare with a post Elizabeth Rather
wrote in c.l.f. about optimizing compilers for ANS 
Forth.

===================================================
A favorite example is this definition: 

: DIGIT ( n -- n ) DUP 9 > IF 7 + THEN [CHAR] 0 + ; 

It converts a single digit to its equivalent
character.  It optimizes to 
(i386 version): 

46E89F   9 # EBX CMP        83FB09 
46E8A2   46E8AB JLE        0F8E03000000 
46E8A8   7 # EBX ADD       83C307 
46E8AB   30 # EBX ADD    83C330 
46E8AE   RET
===================================================

So 6 instructions for colorForth versus 6 
instructions for optimized SwiftForth.  Not 
bad!  But I want to make sure I've done the 
disassembly right.  Rummaging through the
c.l.f. archives I noticed Mark Slicker wrote
a definition for a non-existent MISC machine
that did it in 4 instructions.  His definition
used "+IF" which ColorForth doesn't have.
I suppose you could add that as a Pentium
macro though.

Oh, I noticed in the ColorForth for Windows
distribution there is a screen "X86 
dissassembler" in block 230.  But I can't get 
it to do anything.  Does anybody know the 
status of this?

Regards,

John M. Drake


	
		
__________________________________ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/

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