[comp.lang.pascal] V20/V30 BCD string instructions

vereijken@rulcri.leidenuniv.nl (Jan Joris Vereijken) (05/05/91)

Hi,

I'm trying to write a BCD toolkit in Turbo Pascal 6.0. Interestingly, I own a
V30 based PC-clone. The NEC V30 chip, a 8086 clone, has several insturctions the
8086 does not have. Among them are ADD4S, SUB4S and CMP4S, which add, subtract 
and compare whole BCD strings in 1 instruction (not unlike MOVS moves a string).

I managed to set up the strings, the pointers to source and destination, and the
digit count. Then when when I do an ADD4S, the addition gets done, correctly!

However, every once in a while the computation of ADD4S(x,y) does not yield
"x+y", but "x+y+1" instead. Weird! The sensible thing to conclude is: the carry 
flag gets also added to the sum. Wrong bet, clearing the carry (CLC just before
the ADD4S) doesn't cure the problem. I also tried setting AX to zero, no cure 
either.

Just in case you want to know: I have the original NEC V30 datasheet, and it 
doesn't help me out on this one. (altough it did a great job on teaching me how
to run the V30 in 8080 (as in CP/M-80) compatibility mode, another nice V30 
feature)


Anyone any clues, please?


Thanx in advance!

- Jan Joris Vereijken -

forchk@hlerul53.bitnet, forchk@rullf2.LeidenUniv.NL

PS: I do not have regular access to netnews, could you also mail me privately?