Skip to main content
Top

2016 | OriginalPaper | Chapter

3. Base 2, 8, and 16 Notations

Author : Giuseppe Di Cataldo

Published in: Stack Frames

Publisher: Apress

Activate our intelligent search to find suitable subject content or patents.

search-config
loading …

Abstract

On the subject of numerical representations—notations—we just need to review some basic information before continuing; this chapter is a brief summary of the most important concepts about binary, octal, hexadecimal notations. In the next two chapters we’ll find hexadecimal constants inside assembler code and memory dumps, so it's useful to remind ourselves what binary and hex numbers are, as well as how to read and convert them.

Dont have a licence yet? Then find out more about our products and how to get one now:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Footnotes
1
Side-by-side with their decimal equivalents, the hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A(10), B(11), C(12), D(13), E(14), F(15).
 
2
If we consider a byte value as an unsigned number, the four most significant bits are those with the highest weight (power of 2), therefore on the left side.
 
3
In x86+ operating systems (with little-endian order), the memory address of any object points to its lower byte.
 
4
In the big-endian encoding the correct order is Year/Month/Day since the year is the most significant information. In this case it's the field order (year–month–day) to vary if we change the encoding, not the character order. If we need some files (usually images, documents, and the like) to have names including their creation date, then the big-endian encoding is the most suitable; for example: 2014_06_25.jpg, 2013_08_30.jpg, 2012_12_04.jpg. With little-endian field order we get instead 25_06_2014.jpg, 30_08_2013.jpg, 04_12_2012.jpg, but the list has now no order at all for us; for instance if we choose the ascending order (by changing the view options in the File Manager menu) we see 04_12_2012.jpg, then 25_06_2014.jpg, and, as the last image, 30_08_2013.jpg. This is because 04 comes before 25, which comes before 30.
 
5
This refers to general-purpose registers; there are others, for particular needs, with different sizes.
 
6
On an x86-64 PC we can install a 32-bit OS which will only use 32-bit registers. In this case the hardware word size is 32 bits.
 
7
In AT&T syntax, the prefix $ characterizes a constant number, while % characterizes a register.
 
8
Any operand may be the mask: bitwise operators have both left-associative and commutative properties.
 
9
They are described as symmetric because they use the same key to encrypt and decrypt. Algorithms are very hard to decrypt if the key is longer than the plaintext to encrypt.
 
10
There is another difference: the & operator always evaluates both expressions that form the two operands, while && evaluates the second expression only if the first one is not null (that is, if it is “true”).
 
11
The logical XOR (^^) between two logical expressions mask and exp, inverts exp if mask=TRUE. To be more precise: if mask0mask^^exp = !exp; if mask=0mask^^exp = exp. The logical XOR may be implemented this way: #define XOR(a, b) (!(a) != !(b)). In particular, if aÎ{0, 1}, bÎ{0, 1} then a^^b is equivalent to a!=b; in fact: (0^^0)(0 != 0), (1^^0)(1 != 0), (0^^1)(0 != 1), and (1^^1)(1 != 1). Therefore we don't need the ^^ operator, since we already have another one with the same functionality.
 
12
The low byte of EAX is 00101110. Because of the shift, EAX loses three bits on the right and gains three null bits on the left, so it becomes 00000101.
 
13
Usually, the type of shift used by C compilers is not known a priori; for instance, gcc uses shr for unsigned variables and sar for signed ones.
 
14
The instruction printf("%d %d\n", -46>>4, -46/16) prints 2 different values: –3 –2. If EAX = –1 (0xFFFFFFFF), then “sar $4, %eax” saves –1 (the integer ≤ –1/16)" into EAX, while “printf("%d %d\n", -1>>4, -1/16)” prints –1 0.
 
15
Both add four null bits on the right to balance the lost bits on the left.
 
Metadata
Title
Base 2, 8, and 16 Notations
Author
Giuseppe Di Cataldo
Copyright Year
2016
Publisher
Apress
DOI
https://doi.org/10.1007/978-1-4842-2181-5_3

Premium Partner