Fri, 13 Aug 1993 18:26:01 +0200
|
I am posting this in case other people are writing non-PASCAL subroutines
called from PASCAL so you don't waste an hour finding out what your
problem was.
I don't know of any formal description of the machine format of VS PASCAL
booleans in the manuals, other than saying that they are unaligned and
one byte long. Of course, I may just have missed it. The code the
compiler generates for IF instructions and the like checks for a value of
zero, anything else is TRUE. And of course when you code IF NOT, it also
checks for a value of zero and just inverts the branches. It seemed
straightforward enough. But it turns out that VS PASCAL booleans really
have three values: FALSE (zero), TRUE (one), and TRUE-NO-MATTER-WHAT
(anything else). These booleans of the third type work fine as long as
you just test them, but once you use them in an expression which is
stored in a variable or passed as a function argument, both X and NOT X
turn out to be true. This is because VS PASCAL does not see fit to flip
the higher order bits, so the result is nonzero no matter what. Your non
PASCAL subroutines had better return 1 and not 255, or it will only work
most of the time.
Eric
|
|
|