The Math of Logic

Boolean Algebra is the mathematics of one bit logic, and to build computers we are interested in representing everything, and since they are built with two valued logic, we necessarily have to represent anything more complex in terms of that underlying two valued logic. That's why computers use binary numbers everywhere, if the data is characters instead, we give every possible character into a number. We will leave aside floating point numbers for now and just consider integers.

An N-bit number on a wire, or stored in a memory is able to store 2N different values, so as an unsigned number, that is from zero (all false/0 values) to 2N-1, or as signed, from minus 2N-1 to 2N-1-1 when stored as a twos complement number. You can look that up for the details, but by using the kind of numbers, addition and subtraction are the same action. To change the value of I to -I, take the ones complement (just flip all the bits) -1. In twos complement, -1 is the ones complement of zero, so it is all true/1.

Inside a processor, binary representations will be used in many ways to describe the logic. A number of pins, or a register will contain an address that will be interpreted by a memory device as the number of a storage location in an array. Memories are characterized by size (almost always a power of two) and a width, which is the number of bits stored at each address. The arithmetic of the ALU is all based on the same base two representation of an interger some number of bits wide, with the bits labelled from highest, or most significant to lower (usually labelled zero). For this reason, the same arithmetic that is used for numbers in more abstract representations, is used to calculate addresses in memory for both programs and data.

The programs themselves are stored as data, and addressed with an unsigned value in a register almost universally called a PC or program counter. An architecture is defined by the bit widths of different components, most critically the data path and ALU, and addresses as stored and in accessing program and data memory.