Falsies Exist!!!
Jan Steinman
jans at orca.UUCP
Wed Sep 11 03:37:36 AEST 1985
In article <1341 at brl-tgr.ARPA> cottrell at NBS-VMS.ARPA (COTTRELL, JAMES) writes:
>@ >> ... But no machine I know of has a `branch if true' instruxion...
>
>@ The 808x/Z80 families of microprocessors set the 'zero' flag...
>
>Don't you think I know that? Doesn't everybody? You missed the point
>entirely! What I am saying is that at the assembly language level there
>is no notion of pure true or false as a primitive condition.
I can't quite figure out your point. Are you making a semantic issue of this,
or a logical one? Let's put these to bed one at a time, first the logical
argument:
>From "16-Bit Microprocessor User's Manual, Third Edition", page 168
(description of the Motorola 68000 "Scc" instruction):
The specified condition code is tested; if the condition is true, the
byte specified by the effective address is set to TRUE (all ones),
otherwise that byte is set to FALSE (all zeros).
>From "NS16000 Instruction Set Reference Manual", page 5-140 (description of
of the National 32032 "Scondi" instruction):
The Scondi instruction sets the dest operand to the integer value "1"
if the specified condition is true, and to "0" if false. These are
the Boolean values "True" and "False", respectively.
Now you have it from the horse's er, ah, manual. The Motorola 68000 specifies
-1 as a primitive true symbol, while the National 32000 uses 1. Both of them
represent false with a zero. (Both of these mesh nicely with the C definition
of "true" and "false" as "non-zero" and "zero", respectively.) I think this
clearly shows that at least two commonly available processors have a built-in
primitive notion about "true" and "false".
Now the tougher semantic argument: true, neither of these manuals specify a
"branch if true" instruction. If you examine the use of each processor's "Z"
flag, you see that each has the intent, if not the language. Most macro
assemblers, or even the C Preprocessor will let you redefine "beq" as "btrue"
and "bne" as "bfalse". In the classic example, a compiler might arrange for
C functions to return their values on the stack. In such a case, simply
loading the return value into a register will indicate success or failure of
the routine, using the MC68000's primitive notion of truth:
if(putchar(c)) printf("ERROR: EOF reached\n)
could result in:
jsr _putchar ;Do function (I know it's really a macro.)
move (a7)+,d0 ;Recover returned value.
btrue _error ;Function returned "true", do error routine.
(Of course this is a gross simplification. Flames like "you forgot a
semi-colon in..." to /dev/null.)
I think the argument has been reduced to one person's opinion.
>@ They may be too small for you to consider them 'machines', but an awful
>@ lot of work gets done on them.
>
>That's right, a lot that's awful.
Just what we need, more net.snobbery.
--
:::::: Jan Steinman Box 1000, MS 61-161 (w)503/685-2843 ::::::
:::::: tektronix!tekecs!jans Wilsonville, OR 97070 (h)503/657-7703 ::::::
More information about the Comp.lang.c
mailing list