This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:papc:chapter_6_4 [2025/05/15 11:21] – [Floating point values] ktokarz | en: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 " | + | 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 " |
| + | <table uinttypes> | ||
| + | < | ||
| ^ 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 | | Doubleword | ||
| | Quadword | | Quadword | ||
| + | </ | ||
| - | + | 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; | |
| - | 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; | + | <table sinttypes> |
| + | < | ||
| ^ 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 | | Signed Doubleword | ||
| | Signed Quadword | | Signed Quadword | ||
| + | </ | ||
| ===== 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, | + | 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, |
| <figure floattypes> | <figure floattypes> | ||
| Line 69: | Line 73: | ||
| </ | </ | ||
| - | ^ Name ^ Bits ^ Mantissa | + | <table tablefloattypes> |
| - | | Double extended | + | < |
| - | | Double precision | + | ^ Name ^ Bits ^ Mantissa |
| - | | Single precision | + | | Double extended |
| - | | Half precision | + | | Double precision |
| - | | Brain Float | 16 | 7 | + | | Single precision |
| + | | Half precision | ||
| + | | Brain Float | 16 | 7 | 8 | {{: | ||
| + | </ | ||
| + | |||
| + | ===== 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> | ||
| + | It is worth mentioning that some instructions operate on a single floating-point value, using only the lowest elements of the operands. | ||
| + | |||
| + | <figure packedfloattypes> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | ===== 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> | ||
| + | |||
| + | <figure bitfieldtype> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== 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> | ||
| + | |||
| + | <figure pointertypes> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | The offset is often the result of complex addressing mode calculations and is called an effective address. | ||
| + | </ | ||
| - | Single precision | ||
| - | Double precision | ||
| - | Double extended precision | ||
| - | Half precision | ||
| - | Brain Float | ||