Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:multiasm:cs:chapter_3_11 [2025/12/11 14:04] ktokarzen:multiasm:cs:chapter_3_11 [2026/03/29 18:24] (current) – [Endianness] ktokarz
Line 1: Line 1:
 ====== Fundamentals of Data Encoding, Big Endian, Little Endian ====== ====== Fundamentals of Data Encoding, Big Endian, Little Endian ======
-The processor can work with different types of data. These include integers of different sizes, floating point numbers, texts, structures and even single bits. All this data is stored in the memory as a single byte or multiple bytes. +The processor can work with different types of data. These include integers of different sizes, floating-point numbers, text, structuresand even single bits. All this data is stored in the memory as a single byte or multiple bytes. 
  
 ===== Integers ===== ===== Integers =====
-Integer data types can be 8, 16, 32 or 64 bits long. If the encoded number is unsigned, it is stored in binary representation, while if the value is signed, the representation is two's complement. A natural binary number range starts with zero. In such a case, it contains all bits equal to zero. While it contains all bits equal to one, the value can be calculated with the expression {{ :en:multiasm:cs:equation_binary.png?200 |}}, where n is the number of bits in a number. +Integer data types can be 8, 16, 32 or 64 bits long. If the encoded number is unsigned, it is stored in binary representation, while if the value is signed, the representation is two's complement. A natural binary number range starts with zero. In such a case, it contains all bits equal to zero. While it contains all bits equal to one, the value can be calculated with the expression\\  
 +{{:en:multiasm:cs:equation_binary.png?100 |}},\\ \\  
 +where n is the number of bits in a number. 
  
 In two's complement representation, the most significant bit (MSB) represents the sign of the number. Zero means a non-negative number; one represents a negative value. The table {{ref>binarynumbers}} shows the integer data types with their ranges. In two's complement representation, the most significant bit (MSB) represents the sign of the number. Zero means a non-negative number; one represents a negative value. The table {{ref>binarynumbers}} shows the integer data types with their ranges.
Line 24: Line 26:
   * Exponent (E)   * Exponent (E)
   * Mantissa (M)   * Mantissa (M)
-fulfilling the equation +fulfilling the equation\\ 
-{{ :en:multiasm:cs:equation_floating.png?200 |}}+{{:en:multiasm:cs:equation_floating.png?100 |}}.\\
  
-There are two main types of real numbers, called floating-point values. Single precision is a number which is encoded in 32 bits. Double-precision floating-point number is encoded with 64 bits. They are presented in Fig{{ref>realtypes}}.+There are two main types of real numbers, called floating-point values. Single precision is a number which is encoded in 32 bits. A double-precision floating-point number is encoded with 64 bits. They are presented in Fig{{ref>realtypes}}.
  
 <figure realtypes> <figure realtypes>
-{{ :en:multiasm:cs:floating_numbers.png?600 |Illustration of a single and double precision real numbers}}+{{:en:multiasm:cs:floating_numbers.png?600 |Illustration of a single and double precision real numbers}}
 <caption>Illustration of a single and double precision real numbers </caption> <caption>Illustration of a single and double precision real numbers </caption>
 </figure> </figure>
Line 38: Line 40:
 <table realnumbers> <table realnumbers>
 <caption> Floating point numbers</caption> <caption> Floating point numbers</caption>
-^ Precision        ^ Exponent  ^ Mantissa  ^ The smallest                             ^ The largest                              +^ Precision        ^ Exponent  ^ Mantissa  ^ The smallest                            ^ The largest                             
-| Single (32 bit)  | 8 bits    | 23 bits   | {{ :en:multiasm:cs:min_fp_32.png?105 }}  | {{ :en:multiasm:cs:max_fp_32.png?100 }}  | +| Single (32 bit)  | 8 bits    | 23 bits   | {{ :en:multiasm:cs:min_fp_32.png?50 }}  | {{ :en:multiasm:cs:max_fp_32.png?50 }}  | 
-| Double (64 bit)  | 11 bits   | 52 bits   | {{ :en:multiasm:cs:min_fp_64.png?120 }}  | {{ :en:multiasm:cs:max_fp_64.png?100 }}  |+| Double (64 bit)  | 11 bits   | 52 bits   | {{ :en:multiasm:cs:min_fp_64.png?60 }}  | {{ :en:multiasm:cs:max_fp_64.png?50 }}  |
 </table> </table>
  
-The most common representation for real numbers on computers is standardised in the document IEEE Standard 754. There are two modifications implemented which make the calculations easier for computers. +The most common representation for real numbers on computers is standardised in the document IEEE Standard 754. Two features have been implemented to make the calculations easier for computers: 
-  * The Biased exponent +  * the Biased exponent, 
-  * The Normalised Mantissa+  * the Normalised Mantissa.
 A biased exponent means that the bias value is added to the real exponent value. This results in all positive exponents, which makes it easier to compare numbers. A biased exponent means that the bias value is added to the real exponent value. This results in all positive exponents, which makes it easier to compare numbers.
 The normalised mantissa is adjusted to have only one bit of the value "1" to the left of the decimal. It requires an appropriate exponent adjustment. The normalised mantissa is adjusted to have only one bit of the value "1" to the left of the decimal. It requires an appropriate exponent adjustment.
Line 65: Line 67:
 <caption>Illustration of Little and Big Endian data placement in the memory</caption> <caption>Illustration of Little and Big Endian data placement in the memory</caption>
 </figure> </figure>
 +
 +Big-endian is mainly used in network protocols, where the most significant bytes are sent first. In modern processors, the dominant order of data placement in memory is little-endian, although some processors (including ARM) can support both modes. Big endian is more human intuitive, but little endian makes it possible to access the same data with different sizes at the same address. It is important for fast data type casting (for example, treating a 32-bit integer as a 16-bit integer) because the starting address doesn't change. Some processors support conversion between little- and big-endianness with special instructions.
en/multiasm/cs/chapter_3_11.1765454661.txt.gz · Last modified: by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0