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

Re: [colorforth] Disassembling Pentium ColorForth



--- Jeff Fox <fox@xxxxxxxxxxxxxxxxxxx> wrote:

> I think this shows a difference between Pentium
> colorforth and MISC
> because on the MISC machines I have used the -IF
> opcode branches when the
> sign or carry bit is not set.  

No.  It shows that I screwed up. :) I went back
and retested my code.  I get the wrong answer for
9.  Your code works correctly under Pentium 
ColorForth.  I'm glad I didn't post this at
c.l.f. :)

> So on MISC to test for 0-9 or 10-15 I would do -10 +
> 0-9 becomes -10 to -1
> 10-15 becomes 0-5
> 
> you test sign or carry with -IF
> if 0-5 you add the char "A"
> if -10 to -1 you add the 10 back to get 0-9
> and you add the char "0"
> but you do just one + after the -IF
> 
> you use a ; after the second +
> 
> it packs into the same number of words either way
> but it makes one path through the word 33% faster
> (and will consume less power)
> 
> it is wasteful on MISC to fall through and do three
> +
> at runtime

Well my earlier version worked the same as yours
with regards to control flow.  It just gave the
wrong answer because I didn't really understand
-IF and used the wrong constants. :)  For reference
here's my (broken) first version again.

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

I guess getting rid of the short circuit ";"
wasn't an improvement afterall.  On the 
Pentium it save a tiny bit of space, but
at the cost of a loss of optimization.
 
> here it is a machineforth dialect that closely
> resembles
> misc colorforth
> 
> : digit ( 0-15 -- "0"-"9"|"A"-"F")
>  -10 +
>  -if [ char 0 10 + ], + ;
>  then [ char A ], + ;
> 
> The -if might pack into the same word as the first +
> it depends on the opcode bit-width, optional
> short-literal
> availability, any need for extra nop with +, and
> cell width etc.

I was wondering how that would pack on an F21.
Is this right?

      nop nop nop #
      -10
      + jns label
      nop nop nop #
      58
      + ret nop nop
label nop nop nop #
      65
      ret

> It could be written as one line, but I think it is
> easier
> to read.  I might put the + -IF on the same line if
> I knew it was
> going to pack.
> 
> I am used to yellow to green color transition in
> colorforth
> doing what the [ generate-number ], does above.

I thought about doing that (just learning how to 
do macros in cf) but then realized I didn't have
a "char" word.  Still we can use constants.

: ascia 65 ;
: asci0 48 ;

: digit -10 + -if [ ascia 10 + ] + then [ asci0 ] + ;

Regards,

John M. Drake



		
__________________________________________ 
Yahoo! DSL ? Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 


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