# EDN Access--12.05.96  A minus B=A+NOT(B)+1(Part 1

-December 05, 1996

 Design FeaturesDecember 5, 1996

## A minus B=A+NOT(B)+1(Part 1)

### Clive "Max" Maxfield, Intergraph Computer Systems

Upon examining an ALU, it is surprising to find a 1's complementor glaring balefully at you,
instead of the 2's complementor you expected to be there.

Following the joys of the "Microprocessor 101'' courses you endured in college, most of you are reasonably confident that you understand the way in which computers add and subtract binary numbers. Thereafter, you bask in the rosy glow that assembly-level instructions, such as add without carry (ADD), add with carry (ADDC), subtract without carry/borrow (SUB), and subtract with carry/borrow (SUBC), don't scare you anymore.

The years race by as if they are in a desperate hurry to get somewhere, until you arrive at that grim and fateful day when someone asks you to replicate an adder/subtractor function, either as a chunk of logic for a design or possibly using a hardware description language to create a model for simulation and synthesis. The first port of call may well be to blow the cobwebs off your microprocessor course notes, only to find that there's more to this than you seem to recall. The description of the ADD instruction, which doesn't require a carry-in, looks simple enough and says something such as: a[7:0] plus b[7:0]=a[7:0]+b[7:0] (assuming an 8-bit datapath). It's when you turn your attention to the SUB, whose definition may be along the lines of a[7:0] minus b[7:0]=a[7:0]+NOT(b[7:0])+1, that you realize that perhaps you should have paid just a tad more attention in Professor Gonzo Dribbler's Monday morning lectures—possibly to the extent of actually staying awake.

Light begins to dawn after a few moments, as you recall that you can perform these calculations using 2's complement arithmetic. So, it comes as something of a shock when you peer at the block diagram of the ALU looking for a 2's complementor but instead find a humble 1's complementor glaring back at you as though it has every right to be there. "Holy socks, Batman, how can this be?" Obviously, you need to go back to first principles in order to figure this out…