Binary

Since each bit of a register or memory location can store a one or a zero, we have to learn about binary arithmetic.

This is similar to the ordinary decimal (base 10) arithmetic that we are used to, except instead of there being 10 possible digits in each place (0-9), there are now only two possible digits we can use (0-1).

This means that the places in binary numbers correspond to powers of 2. The following table illustrates this.

BinaryDecimal
12^0 = 1
102^1 = 2
1002^2 = 4
10002^3 = 8
100002^4 = 16
1000002^5 = 32
10000002^6 = 64
100000002^7 = 128

To make other binary numbers, we simply add powers of 2 together. For example:

BinaryDecimal
11012^3 + 2^2 + 2^0 = 8 + 4 + 1 = 13
1012^2+2^0 = 4 + 1 = 5
10012^3 + 2^0 = 8 + 1 = 9
101002^4 + 2^2 = 16 + 4 = 20

Each number can be expressed uniquely as a binary number.

To write a binary number in assembly language, we append a b to the number to indicate that it is binary, e.g. 11010110b. This corresponds to the decimal number 214. So now we have two ways to move the number 214 into a register, e.g.

MOV AH, 11010110b
MOV BH, 214