[net.arch] 8086 flag bit stylistics

gordonl@microsoft.UUCP (Gordon Letwin) (11/09/84)

Many "original-design mini" architectures set the flag bits often...
when a register is loaded, for example.  The PDP-11, by my recollection,
does this.

The 8086/286/386 family sets the registers only on logical/arithmetic
operations, not for loads,stores, and moves.  The reason for this dates
back to the 8080 which dates back to the 8008: to do any operation involving
more than 8 bits required a lot of moving around... if the moves modified
the flag bits (espeically CARRY) then multi-byte operations would have
been ruled out.

sullivan@harvard.ARPA (John Sullivan) (11/19/84)

> Many "original-design mini" architectures set the flag bits often...
> when a register is loaded, for example.  The PDP-11, by my recollection,
> does this.
> ...

Early machines with just one accumulator tended not to have flag bits.  If
I remember the IBM 1130 correctly, a conditional branch on sign or zero
would just look at the current value in the accumulator.

Machines with many registers usually need flags, and they are often set by
most instructions.  But I don't think I've ever seen one that sets the
carry on a move--this is not unique to 8080 family.  Certainly the PDP-11
move instruction (among others) leaves the carry bit alone.

But I would tend to agree that automatic flag setting may not be worthwhile.
Experience teaching people to program in assembly language on PDP's and VAX's
shows that even in hand-written code many superfluous TSTs are used.  Who wants
to refer to the manual every time to see just how the flags are set on a divide?
(I think the PDP-11 multiply and divide use carry for overflow or vice versa.)
I imagine there are many compilers around that similarly don't bother to remove
all the test instructions they could.

I would like to see a machine that would simply have optional traps for
overflow and carry.  Since these bits probably are rarely set I imagine
this would be much faster than code that consistently tested flags.


	John M. Sullivan
	{allegra,decvax,ihnp4}!harvard!sullivan