home .. forth .. misc mail list archive ..

Re: Carry propagation, +, T=0 ???


On Tue, 1 Apr 1997 kolov@mail.geocities.com wrote:

>      Dear MISC Readers,
> I had problems debugging a piece of code for MuP21. 
> Hunting the bug, I came down to writing the following two FORTH 
> words, T1 and T2, which behave differently, although I can see no 
> explanation for it in the documantaion I have. 
> The documenatation from Offette Enterprises I have says, explaining 
> the + instruction, that "the  sum and the carry will be stabilized in 
> the next word", which does not seem to me to be the case.
> 
> Having compiled T1 and T2 words, here is what I get:
> HEX ok
> 11 T1 . <CR> 0 ok
> 11 T2 . <CR> 1 ok
>  ok
> 
> 
> The test was run on a P21B5 board, with a PLCC P21.
> I will be very grateful to anyone pointing to me this part of the 
> documentation on MuP21 which explains this behavior. While waiting, 
> I will not  be sparing NOPs.
> 
>  The words source:
> HEX 
> CODE T1
> a push nop a! 
> @ 10 # com +       ( <-------------------This line ..... )

> CODE T2
> a push nop a! 
> @ 10 # com nop   ( <-----------------...replaced by these )
> + nop nop nop    ( <----------------+)

The rule of thumb is: carry propagates n bits for the time of one
instruction slot, where n is, I guess, 8 for P21.  Therefore, if you need
to fast carry propagation all the way up of numbers of small precision,
you should _left_ justify them, so carry starts as left as possible and
reaches T20 quickly.  Adding nops at 8 bits/nop i helpful.  You need two
nops to cover the entire possible range.  An instruction fetch from DRAM
counts as many,many nops, so plating a + in the _first_ slot in DRAM is
safe.

As usual, I remind, that intructions execute in parallel, that is, if you
put a nop, the carry propagates behind the scenes.  The instruction itself
_latches_ the result of the respective unit in TOS, that is you need nops
_before_ the "instruction". 


The number 8 is off the top of my head.  Jeff could be more specific.  Or
I should get the FAQ going :-)  in cases, the experiment to measure it is
trivial. 

Cheers,

--
Penio Penev <Penev@pisa.Rockefeller.edu> 1-212-327-7423