Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for varying displacement sizes (#7)
* Added values for different sized displacements Checking clauses has been added to leverage the `OP_MODRM_DISP32` and `OP_MODRM_DISP8` values (which corrispond to theModR/M values from `operand.h`) which allows the sizes of the following displa- cement bytes of the instructions to be truncated to 8 or 32 bits and allowing extra space for offsets where needed. For example a value of 123 would be originally 4 bytes wide padded with zeros at the end of the instruction, now the new ModR/M mode will allow the value of 123 to be packed neatly into a single byte at the end of the instruction * Updated test file: operand. Removed duplicate test cases and added new test cases for commit number f9094eb, mostly targetted at displacements. Note: test file currently failing * Correction: Corrected test case Changed expected value to `OP_MODRM_DISP32` since `0xFFFF` is grea- ter than the value to be checked against - `0xFF`(Which is defined as the largest value of a `uint8-t`) * Added type cast to smaller type * Added `write_offset()` This function not only encapsulates the process of writing prefixes to the corrisponding ModR/M byte but also checks the mode generated from the change specified in commit number 4df7a23 and checks for the size of the offset before writing the offset with the size into the buffer array * Fixed issue with signed offsets According to the Intel manuals, all offsets regardless of size are signed integers, therefore, we cannot assume to use its signed max value of 255 as specified in `UINT8_MAX` (defined in <stdint.h>) but instead needs to use the corrisponding maximum value for the signed counterpart to `uint8_t` which is `INT8_MAX` Now the `op_modrm_mode()` will accept the offset values in the form of `int8_t`s as the `uint8_t`s will not properly support signed of- fsets that Intel expects to be written to the end of the instruction encoded form. * Added comments to reflect changes in e0ad9bf
- Loading branch information