diff options
author | Oxore <oxore@protonmail.com> | 2023-04-21 18:42:46 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-04-21 18:42:46 +0300 |
commit | 8856f2ee0e19f50c4c4fb3dc7fccc8150a00da81 (patch) | |
tree | 575d6b65bf425a27d487f6987c6331763e388ec8 /common.h | |
parent | 25762ee11dadb333f5b63c359abb615dc5f16b09 (diff) |
Refactor asm rendering
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/common.h b/common.h new file mode 100644 index 0000000..ab7a359 --- /dev/null +++ b/common.h @@ -0,0 +1,24 @@ +#pragma once + +constexpr size_t kInstructionSizeStepBytes = 2; + +static inline size_t Min(size_t a, size_t b) { return a < b ? a : b; } + +static inline uint16_t GetU16BE(uint8_t *buffer) +{ + return (static_cast<uint16_t>(buffer[0]) << 8) | static_cast<uint16_t>(buffer[1]); +} + +static inline int16_t GetI16BE(uint8_t *buffer) +{ + return (static_cast<uint16_t>(buffer[0]) << 8) | static_cast<uint16_t>(buffer[1]); +} + +static inline int32_t GetI32BE(uint8_t *buffer) +{ + return (static_cast<uint32_t>(buffer[0]) << 24) | + (static_cast<uint32_t>(buffer[1]) << 16) | + (static_cast<uint32_t>(buffer[2]) << 8) | + static_cast<uint32_t>(buffer[3]); +} + |