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

Carry propagation, +, T=0 ???


     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 ..... )
if 
  drop 0 # nop nop
else
  drop 1 # nop nop
then
! a pop nop
a! @+ push ;'
END-CODE

CODE T2
a push nop a! 
@ 10 # com nop   ( <-----------------...replaced by these )
+ nop nop nop    ( <----------------+)
if 
  drop 0 # nop nop
else
  drop 1 # nop nop
then
! a pop nop
a! @+ push ;'
END-CODE

Appendix: This is how they look disassembled
ASEE T1
 1369: A PUSH NOP A!
 136A: @ N COM +
 136B: # 10
 136C: T=0  370
 136D: DROP N NOP NOP
 136E: # 0
 136F: JUMP  372
 1370: DROP N NOP NOP
 1371: # 1
 1372: ! A POP NOP
 1373: A! @+ PUSH :'
ASEE T2
 1374: A PUSH NOP A!
 1375: @ N COM NOP
 1376: # 10
 1377: + NOP NOP NOP
 1378: T=0  37C
 1379: DROP N NOP NOP
 137A: # 0
 137B: JUMP  37E
 137C: DROP N NOP NOP
 137D: # 1
 137E: ! A POP NOP
 137F: A! @+ PUSH :'
Assen Kolov <kolov@geocities.com>