Bit: The smallest unit in computers. It is either a 1 or a 0.

Nibble: Half a byte, or 4 bites.

Byte: 8 bits together form one byte, a number from 0 to 255. Bits in the byte are numbered starting from the right at 0.

Short: Two bytes put together is 16 bits, forming a number from 0 to 65535. The low byte is the rightmost eight bits.

Hex Number: A HEX number consisting of 4 numbers is 16-bit.

Hexadecimal to Binary Conversion

0

0000

4

0100

8

1000

C

1100

1

0001

5

0101

9

1001

D

1101

2

0010

6

0110

A

1010

E

1110

3

0011

7

0111

B

1011

F

1111

Arithmetic

Addition

input

ADD

output

carry

0

1

1

0

0

0

0

0

1

1

0

1

1

0

1

0

Subtraction

input

SUB

output

borrow

0

1

1

1

0

0

0

0

1

1

0

0

1

0

1

0

Multiplication

input

MUL

output

0

1

0

0

0

0

1

1

1

1

0

0

Bit Masks

AND, or "both", sets individual bits to 0. AND is useful for masking bits, for example, to mask the high order bits of a value AND with $0F: $36 AND $0F = $06.

input

AND

output

0

1

1

0

0

0

1

1

0

1

0

1

ORA(OR), or "either one or both", sets individual bits to 1. OR is useful for setting a particular bit, for example, $80 OR $08 = $88

input

ORA

output

0

1

1

0

0

0

1

1

1

1

0

1

EOR(XOR), or "one or the other but not both", inverts individual bits.

input

EOR

output

0

1

1

0

0

0

1

1

0

1

0

1

Signed Integers

If Bit 7 is not set (as in the first example) the representation of signed and unsigned numbers is the same. However, when Bit 7 is set, the number is always negative. For this reason Bit 7 is sometimes called the sign bit.