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

Re: [colorforth] Understanding the x18 instruction jump table



--- Helen Austin <gwenhwyfaer@xxxxxxxxx> wrote:

> On 6/13/06, John Drake <jmdrake_98@xxxxxxxxx> wrote:
> > : inst ( n ) 1 slot +! 1f and jump jmp jmp call
> call
> > jz jz jns jns @b @+ n @a !b !+ nul !a -x 2*x 2/x
> +*
> > orx andx nul +x r@ a@ t@ s@ r! a!x nul t!
> >
> > Why are the opcodes jmp, call and jns repeated?
> 
> At a guess, because the LSB of those four
> instructions (call, jmp, jz,
> jns) either affects their operation or is ignored
> when decoding them.
> Note that after "1f and jump" there are exactly 32
> words - one for
> every 5-bit opcode, I'd guess.
> 
> Helpful?
> 
> Regards
> Helen

Hello Helen,

I'm aware of the "32 words - one for every 5-bit
opcode" part.  I guess that's why I found the 
repeated instructions a bit odd.  It's also 
different from what was reported in Chuck's
paper on the subject.

http://dec.bournemouth.ac.uk/forth/euro/ef01/moore01b.pdf

: inst ( n ) 1 slot +! 1f and jump ret nul call
jmp nul nul jz jns n @+ @b @a !r !+ !b !a 
+* 2* 2/ - + and or drop dup over pop a nul
b! push a!

These correspond 1 to 1 to the instruction table
listed in the c18 compiler paper.

http://dec.bournemouth.ac.uk/forth/euro/ef01/moore01a.pdf

It's interesting to note that in the version from
the paper there are 4 nuls in the jump table.
In the source there's only 3.  Also the jump
table from the paper includes a "ret" instruction.
The source version does not, even though "ret"
is defined as an instruction.  Also "!r" is 
absent.  So 3 nuls minus 2 "missing" 
instructions plus 3 "repeated" instructions
equals 4 nuls in the jump table in the paper.
My conclusion?  The repeated instructions might
as well be nulls.  (Admittedly I could be wrong
on that).

As for the "missing" instructions, well it seems
"@r" had already been dropped since its missing
from the c18 compiler paper, so I suppose losing
"!r" isn't a biggie.  While there's no "ret" in
the jump table, there is a ";" word defined for
the x18 compiler.

: ; 4 [ ip ] +! ;

I'm not sure at the moment how this is supposed
to work.  Most of the other instructions 
actually compile something into a "slot" but
this is saying increment the IP by 4.  How does
that execute a return?

One more note.  I got my "mini decompiler" to
work.  Now I can step through the example code
from block 114:

( 25x rom ) 180 org 0 dup - dup - dup - dup - 
dup - dup - dup - dup - dup push push push 
push push push push push push a! a nop 

So instead of just seeing the stack grow, I
can actually see the opcode that was just
executed.  Of course I still have no idea 
what this code is actually supposed to do.

So, has anyone else been experimenting with
the X18 compiler/simulator?

Regards,

John M. Drake

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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