Re: Disassembling Pentium ColorForth

"Jeff Fox" <[email protected]>
Newsgroups gmane.comp.lang.forth.colorforth
Message-ID <[email protected]>
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.  It is a branch if not negative, and
that includes 0.

I guess on Pentium colorforth -IF must not branch on 0 like it does
on MISC thus the -9 + instead of the -10 + that I would have expected
from MISC colorforth.

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

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.

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. Without that
it could be:

: digit ( n-n) -10 + -if 58 + ; then 65 + ;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.