The "Go" tools
The GoAsm manual
understand ....
hex numbers
This file is intended for those interested in 32 bit assembler
programming, in particular for Windows.
Programmers represent numbers in hex for a number of reasons. One reason is
because this is a convenient way to visualise the number in data. This not
only helps when dealing with large numbers, but it also enables the
programmer to know what bits in data are "set" or "clear" in a particular
number, something useful when testing individual bits. Another reason is
that using hex numbers makes it easier and less error prone to use the
logical instructions (eg. OR, AND, TEST, BT).
Hex numbers are to base sixteen. Hex is short for "hexadecimal"
which comes from "hex" meaning six and "dec" meaning ten. Each hex number
has a value of 0 to 9 or A, B, C, D, E, or F. Each hex number
represents four bits of binary data. Here are the values
which can be created from four bits and the hex and decimal values in
each case:-
|
binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
|
hex
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
|
decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
|
A byte can be represented as two hex numbers, a word as four hex numbers
and a dword as eight hex numbers. You can see the real advantage of hex
numbers when looking at larger numbers which become unwieldy when represented
in decimal:-
|
binary
10000000
1000000000000001
1111111111111111
10000000000000000000000000000001
11111111111111111111111111111111
|
hex
80
8001
FFFF
80000001
FFFFFFFF
|
decimal
128
32,769
65,535
2,147,483,649
4,294,967,295
|
(byte)
(word)
(word)
(dword)
(dword)
|
Copyright © Jeremy Gordon 2002-2003
Back to top
|