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:papc:chapter_6_4 [2025/05/15 11:21] – [Floating point values] ktokarzen:multiasm:papc:chapter_6_4 [2025/05/18 19:02] (current) – [Pointers] ktokarz
Line 14: Line 14:
  
 ===== Integer scalar data types ===== ===== Integer scalar data types =====
-Integer data types can be one, two, four or eight bytes in length. Unsigned integers are binary encoded in natural binary code. It means that the starting value is 0 (zero), and the maximum value is formed with bits "1" at all available positions. The x64 architecture supports the following unsigned integer data types.+Integer data types can be one, two, four or eight bytes in length. Unsigned integers are binary encoded in natural binary code. It means that the starting value is 0 (zero), and the maximum value is formed with bits "1" at all available positions. The x64 architecture supports the unsigned integer data types shown in table {{ref>uinttypes}}. 
 +<table uinttypes> 
 +<caption>Unsigned integer data types</caption>
 ^ Name        ^ Number of bits  ^ Minimum value  ^ Maximum value         ^ Minimum value (hex)  ^ Maximum value (hex)  ^ ^ Name        ^ Number of bits  ^ Minimum value  ^ Maximum value         ^ Minimum value (hex)  ^ Maximum value (hex)  ^
 | Byte        | 8               | 0              | 255                   | 0x00                 | 0xFF                 | | Byte        | 8               | 0              | 255                   | 0x00                 | 0xFF                 |
Line 20: Line 22:
 | Doubleword  | 32              | 0              | 4294967295            | 0x00000000           | 0xFFFFFFFF           | | Doubleword  | 32              | 0              | 4294967295            | 0x00000000           | 0xFFFFFFFF           |
 | Quadword    | 64              | 0              | 18446744073709551615  | 0x0000000000000000   | 0xFFFFFFFFFFFFFFFF   | | Quadword    | 64              | 0              | 18446744073709551615  | 0x0000000000000000   | 0xFFFFFFFFFFFFFFFF   |
 +</table>
  
- +Signed integers are binary encoded in 2's complement binary code. The highest bit of the value is a sign bit. If it is zero, the number is non-negative; if it is one, the value is negative. It means that the starting value is encoded as the highest bit equal to 1 and all other bits equal to zero. The maximum value is formed with a "0" bit at the highest position and bits "1" at all other positions. The x64 architecture supports the signed integer data types shown in table {{ref>sinttypes}}. 
-Signed integers are binary encoded in 2's complement binary code. The highest bit of the value is a sign bit. If it is zero, the number is non-negative; if it is one, the value is negative. It means that the starting value is encoded as the highest bit equal to 1 and all other bits equal to zero. The maximum value is formed with a "0" bit at the highest position and bits "1" at all other positions. The x64 architecture supports the following signed integer data types.+<table sinttypes> 
 +<caption>Signed integer data types</caption>
 ^ Name        ^ Number of bits  ^ Minimum value  ^ Maximum value         ^ Minimum value (hex)  ^ Maximum value (hex)  ^ ^ Name        ^ Number of bits  ^ Minimum value  ^ Maximum value         ^ Minimum value (hex)  ^ Maximum value (hex)  ^
 | Signed Byte | 8               | -128           | 127                   | 0x80                 | 0x7F                 | | Signed Byte | 8               | -128           | 127                   | 0x80                 | 0x7F                 |
Line 28: Line 32:
 | Signed Doubleword  | 32       | -2147483648    | 2147483647            | 0x80000000           | 0x7FFFFFFF           | | Signed Doubleword  | 32       | -2147483648    | 2147483647            | 0x80000000           | 0x7FFFFFFF           |
 | Signed Quadword    | 64       | -9223372036854775808 | 9223372036854775807  | 0x8000000000000000   | 0x7FFFFFFFFFFFFFFF   | | Signed Quadword    | 64       | -9223372036854775808 | 9223372036854775807  | 0x8000000000000000   | 0x7FFFFFFFFFFFFFFF   |
 +</table>
 ===== Integer vector data types ===== ===== Integer vector data types =====
 Vector data types were introduced with SIMD instructions starting with the MMX extension, and followed in the SSE and AVX extensions. They form the packed data types containing multiple elements of the same size. The elements can be considered as signed or unsigned depending on the algorithm and instructions used. Vector data types were introduced with SIMD instructions starting with the MMX extension, and followed in the SSE and AVX extensions. They form the packed data types containing multiple elements of the same size. The elements can be considered as signed or unsigned depending on the algorithm and instructions used.
Line 62: Line 66:
  
 ===== Floating point values ===== ===== Floating point values =====
-Floating point values store the data encoded for calculation on real numbers. Depending on the precision required for the algorithm, we can use different data sizes. Scalar data types are supported by the FPU (Floating Point Unit), offering single precision, double precision or double extended precision real numbers. In C/C++ compilers, they are referred to as float, double and long double data types, respectively. Vector (packed) floating-point data types can be processed by many SSE and AVX instructions, offering fast vector, matrix or artificial intelligence calculations. Vector units can process half precision, single precision and double precision formats. The 16-bit Brain Float format was introduced to calculate the dot scalar product to improve the efficiency of AI training and inference algorithms. Floating point scalar data types are shown in figure {{ref>floattypes}} and described in the table.+Floating point values store the data encoded for calculation on real numbers. Depending on the precision required for the algorithm, we can use different data sizes. Scalar data types are supported by the FPU (Floating Point Unit), offering single precision, double precision or double extended precision real numbers. In C/C++ compilers, they are referred to as float, double and long double data types, respectively. Vector (packed) floating-point data types can be processed by many SSE and AVX instructions, offering fast vector, matrix or artificial intelligence calculations. Vector units can process half precision, single precision and double precision formats. The 16-bit Brain Float format was introduced to calculate the dot scalar product to improve the efficiency of AI training and inference algorithms. Floating point data types are shown in figure {{ref>floattypes}} and described in table {{ref>tablefloattypes}}. The table shows the number of bits used. In reality, the number of mantissa bits is assumed to be one bit longer, because the highest bit representing the integer part is always "1", so there is no need to store it (except for Double extended data format, where the integer bit is present).
  
 <figure floattypes> <figure floattypes>
Line 69: Line 73:
 </figure> </figure>
  
-^ Name              ^ Bits  ^ Mantissa  ^ Exponent  ^ Min value                                 ^ Max value                                 ^ +<table tablefloattypes> 
-| Double extended   | 80    | 64        | 15        | {{:en:multiasm:cs:float_ep_min.png?125}}  | {{:en:multiasm:cs:float_ep_max.png?125}} +<caption>Floating point data types</caption> 
-| Double precision  | 64    | 52        | 11        | {{:en:multiasm:cs:float_dp_min.png?120}}  | {{:en:multiasm:cs:float_dp_max.png?115}} +^ Name              ^ Bits  ^ Mantissa bits  ^ Exponent bits  ^ Min value                                 ^ Max value                                 ^ 
-| Single precision  | 32    | 23        | 8         | {{:en:multiasm:cs:float_sp_min.png?120}}  | {{:en:multiasm:cs:float_sp_max.png?110}} +| Double extended   | 80    | 64             | 15             | {{:en:multiasm:cs:float_ep_min.png?125}}  | {{:en:multiasm:cs:float_ep_max.png?125}} 
-| Half precision    | 16    | 10        | 5         | {{:en:multiasm:cs:float_hp_min.png?110}}  | {{:en:multiasm:cs:float_hp_max.png?100}} +| Double precision  | 64    | 52             | 11             | {{:en:multiasm:cs:float_dp_min.png?120}}  | {{:en:multiasm:cs:float_dp_max.png?115}} 
-| Brain Float       | 16    | 7         | 8         | {{:en:multiasm:cs:float_bf_min.png?120}}  | {{:en:multiasm:cs:float_bf_max.png?110}}  |+| Single precision  | 32    | 23             | 8              | {{:en:multiasm:cs:float_sp_min.png?120}}  | {{:en:multiasm:cs:float_sp_max.png?110}} 
 +| Half precision    | 16    | 10             | 5              | {{:en:multiasm:cs:float_hp_min.png?110}}  | {{:en:multiasm:cs:float_hp_max.png?100}} 
 +| Brain Float       | 16    | 7              | 8              | {{:en:multiasm:cs:float_bf_min.png?120}}  | {{:en:multiasm:cs:float_bf_max.png?110}}  | 
 +</table> 
 + 
 +===== Floating point vector data types ===== 
 +Floating point vectors are formed with single or double precision packed data formats. They are processed by SSE or AVX instructions in a SIMD approach of processing. A 128-bit packed data format can store four single-precision data elements or two double-precision data elements. A 256-bit packed data format can store eight single-precision values or four double-precision values. A 512-bit packed data format can store sixteen single-precision values or eight double-precision values. These packed data types are shown in figure {{ref>packedfloattypes}}. Instructions operating on 16-bit half-precision values or Brain Floats can use twice as many such elements simultaneously in comparison to single-precision data. 
 +It is worth mentioning that some instructions operate on a single floating-point value, using only the lowest elements of the operands.  
 + 
 +<figure packedfloattypes> 
 +{{ :en:multiasm:cs:packed_floats.png?800 |Illustration of packed floating point data types}} 
 +<caption>Pcked floating point data types in x64 architecture</caption> 
 +</figure> 
 + 
 +===== Bit field data type ===== 
 +A bit field is a data type whose size is counted by the number of bits it occupies. The bit field can start at any bit position in the fundamental data type and can be up to 32 bits long. MASM supports it with the RECORD data type. The bit field type is shown in figure {{ref>bitfieldtype}}. 
 + 
 +<figure bitfieldtype> 
 +{{ :en:multiasm:cs:bit_field_type.png?300 |Illustration of bit field data type}} 
 +<caption>The bit field data type</caption> 
 +</figure> 
 + 
 + 
 +===== Pointers ===== 
 +Pointers store the address of the memory which contains interesting information. They can point to the data or the instruction. If the segmentation is enabled, pointers can be near or far. The far pointer contains the logical address (formed with the segment and offset parts). The near pointer contains the offset only. The offset can be 16, 32 or 64 bits long. The segment selector is always stored as a 16-bit number. Illustration of possible pointer types is shown in figure {{ref>pointertypes}}. 
 + 
 +<figure pointertypes> 
 +{{ :en:multiasm:cs:pointers_types.png?600 |Illustration of near and far pointers types}} 
 +<caption>The near and far pointers types</caption> 
 +</figure> 
 + 
 +<note> 
 +The offset is often the result of complex addressing mode calculations and is called an effective address. 
 +</note>
  
-Single precision 
-Double precision 
-Double extended precision 
-Half precision 
-Brain Float 
en/multiasm/papc/chapter_6_4.1747308105.txt.gz · Last modified: 2025/05/15 11:21 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