The "Go" tools
The GoAsm manual
bits and binary
by Jeremy Gordon -
This file is intended for those interested in 32 bit assembler
programming, in particular for Windows.
A bit is an electrical element within the computer which can be either "on" or "off".
In physical terms, it is a semi-conductor which is able to conduct a
tiny amount of electricity when it is "on" but cannot do so when it
is "off". When it is "on" it can be regarded as having the value one.
In computer language the bit is then said to be "set". When it is "off" it
can be regarded as having the value zero. In computer language
the bit is "clear". Bits can only be set or clear and cannot have any
other state. Therefore a bit can only have a binary value of 0 or 1.
Two or more bits can be joined
together to create larger numbers. When bits are joined together, the bit
on the right is the least significant and if it is "set" it represents the
value one. The next bit to the left is more significant by a factor of two.
When that bit is "set" it represents the value of two. So suppose you have
a number formed with two bits. Then the
number (in binary) can be 00 or 01 or 10 or 11. The equivalent in decimal
is 0, 1, 2 and 3 respectively.
Bytes words and dwords
Bytes words and dwords are the basic chunks of data used in programming.
The processor will work with the data size to suit the instruction it is
A byte is 8 bits, a word is 16 bits (2 bytes) and a dword is 32 bits
(4 bytes). A byte can represent the decimal values 0 to 255. The decimal
value 255 is the total of the values of all 8 of bits in the byte, that is
decimal 128, 64, 32, 16, 8, 4, 2 and 1 respectively. A word can represent
the decimal values 0 to 65,535 (64 Kilobytes). 64KB is the total of the
values of all 16 bits.
A dword (literally a "double word") can represent the decimal values 0
to 4,294,967,295 (4 Gigabytes). 4GB is the total of the values of all
There are some even larger chunks of data which the processor can handle
- a qword (literally a "quad word") is 64 bits of data (4 words or 8
bytes), a tword is 80 bits of data (10 bytes) and some instructions can
even use 128 bits (16 bytes). You can see that these numbers are very
A nibble is half a byte. It is four bits of data. In a byte there
are two nibbles. Each nibble has a value which can be represented
as a single hex number. Take for example
the hex number 148C. This is in two bytes. The first byte contains the
value 14h and the second 8Ch. The nibbles contain the values 1, 4, 8 and
Copyright © Jeremy Gordon 2002-2003
Back to top