Numeric comparisons

Peter da Silva peter at graffiti.UUCP
Tue Sep 3 21:40:25 AEST 1985


> Compiler users note -- if your compiler gives the wrong results, the
> compiler writer might not be completely at fault.  Many early CPU
> chips (8080A, Z80, 6502, etc.) did comparison by subtraction, and a
> compiler would have had to generate extra code to test for Overflow
> in order to get the correct result.

Most chips that I know of handle compare by doing a subtraction, setting the
bits, and throwing away the results. Since most chips also allow a single
instruction to test any number of flags no extra code need be generated to
differentiate between the two. Maybe you're thinking of FORTH which generally
does what you just described...

Anyway, in Z80, 6502, 8080, 6809, PDP-11, and so on the scenario I just
described takes place. the BLT <xxx> instruction tests for N bit xor V bit
(I think I've got that right). Or does it test for a nice light sandwich
made with bacon, lettuce, and tomato? I don't remember. It's too early.



More information about the Comp.lang.c mailing list