From 2ebf959ec02048c15323e1bbfc63faedcf5067b6 Mon Sep 17 00:00:00 2001 From: navewindre Date: Fri, 12 Jul 2024 00:55:39 +0200 Subject: ha haaa --- src/x86.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/x86.h (limited to 'src/x86.h') diff --git a/src/x86.h b/src/x86.h new file mode 100644 index 0000000..484e5c2 --- /dev/null +++ b/src/x86.h @@ -0,0 +1,58 @@ +//|_ _ _. _ ._ |_ _. _ | +//| | (/_ (_| \/ (/_ | | | | (_| (_ |< + +#pragma once +#include "typedef.h" + +enum X86Regs_t : U8 { + eax = 0, + ecx, + edx, + ebx, + esp, + ebp, + esi, + edi +}; + +enum X64Regs_t : U8 { + rax = 0, + rcx, + rdx, + rbx, + rsp, + rbp, + rsi, + rdi, + r8, + r9, + r10, + r11, + r12, + r13, + r14, + r15 +}; + +union REG64 { + REG64() = default; + REG64( U64 x ) : u64( x ) {} + REG64( U32 x ) { u64 = x; } + + REG64( I64 x ) : u64( *(U64*)( &x ) ) {} + REG64( I32 x ) { u64 = *(U32*)( &x ); } + + U32 u32[2]; + U64 u64; +}; + +constexpr U32 x86_encode_mov_imm32( U32 reg ) { return ( 0xb8 + reg ); } +constexpr U32 x86_encode_push_reg( U32 reg ) { return 0x50 | ( reg & 7 ); } +constexpr U32 x86_encoded_pop_reg( U32 reg ) { return 0x58 | ( reg & 7 ); } + +enum X86Instructions_t : U8 { + RET_NEAR = 0xc3, + RET_FAR = 0xcb, + RET_NEAR_IMM16 = 0xc2, + RET_FAR_IMM16 = 0xca, +}; \ No newline at end of file -- cgit v1.2.3