Merge branch '86Box:master' into master

This commit is contained in:
starfrost
2025-03-03 01:28:17 +00:00
committed by GitHub
5 changed files with 70 additions and 48 deletions

View File

@@ -132,7 +132,6 @@ option(RTMIDI "RtMidi"
option(FLUIDSYNTH "FluidSynth" ON)
option(MUNT "MUNT" ON)
option(VNC "VNC renderer" OFF)
option(NEW_DYNAREC "Use the PCem v15 (\"new\") dynamic recompiler" OFF)
option(MINITRACE "Enable Chrome tracing using the modified minitrace library" OFF)
option(GDBSTUB "Enable GDB stub server for debugging" OFF)
option(DEV_BRANCH "Development branch" OFF)
@@ -144,6 +143,12 @@ if (NV_LOG)
add_compile_definitions(ENABLE_NV_LOG)
endif()
if((ARCH STREQUAL "arm64") OR (ARCH STREQUAL "arm"))
set(NEW_DYNAREC ON)
else()
option(NEW_DYNAREC "Use the PCem v15 (\"new\") dynamic recompiler" OFF)
endif()
if(WIN32)
set(QT ON)
option(CPPTHREADS "C++11 threads" OFF)

View File

@@ -223,7 +223,6 @@ elseif(APPLE AND NOT QT)
COMPONENT Runtime)
endif()
# Install the PDB file on Windows builds
if(MSVC)
# CMake fully supports PDB files on MSVC-compatible compilers

View File

@@ -315,13 +315,19 @@ codegen_backend_init(void)
# endif
host_x86_CALL(block, (void *) x86gpf);
codegen_exit_rout = &codeblock[block_current].data[block_pos];
#ifdef _WIN64
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x38);
#else
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x48);
#endif
host_x86_POP(block, REG_R15);
host_x86_POP(block, REG_R14);
host_x86_POP(block, REG_R13);
host_x86_POP(block, REG_R12);
#ifdef _WIN64
host_x86_POP(block, REG_RDI);
host_x86_POP(block, REG_RSI);
#endif
host_x86_POP(block, REG_RBP);
host_x86_POP(block, REG_RDX);
host_x86_RET(block);
@@ -346,13 +352,19 @@ codegen_backend_prologue(codeblock_t *block)
block_pos = BLOCK_START; /*Entry code*/
host_x86_PUSH(block, REG_RBX);
host_x86_PUSH(block, REG_RBP);
#ifdef _WIN64
host_x86_PUSH(block, REG_RSI);
host_x86_PUSH(block, REG_RDI);
#endif
host_x86_PUSH(block, REG_R12);
host_x86_PUSH(block, REG_R13);
host_x86_PUSH(block, REG_R14);
host_x86_PUSH(block, REG_R15);
#ifdef _WIN64
host_x86_SUB64_REG_IMM(block, REG_RSP, 0x38);
#else
host_x86_SUB64_REG_IMM(block, REG_RSP, 0x48);
#endif
host_x86_MOV64_REG_IMM(block, REG_RBP, ((uintptr_t) &cpu_state) + 128);
if (block->flags & CODEBLOCK_HAS_FPU) {
host_x86_MOV32_REG_ABS(block, REG_EAX, &cpu_state.TOP);
@@ -360,19 +372,25 @@ codegen_backend_prologue(codeblock_t *block)
host_x86_MOV32_BASE_OFFSET_REG(block, REG_RSP, IREG_TOP_diff_stack_offset, REG_EAX);
}
if (block->flags & CODEBLOCK_NO_IMMEDIATES)
host_x86_MOV64_REG_IMM(block, REG_R12, (uintptr_t) ram);
host_x86_MOV64_REG_IMM(block, REG_R12, ((uintptr_t) ram) + 2147483648ULL);
}
void
codegen_backend_epilogue(codeblock_t *block)
{
#ifdef _WIN64
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x38);
#else
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x48);
#endif
host_x86_POP(block, REG_R15);
host_x86_POP(block, REG_R14);
host_x86_POP(block, REG_R13);
host_x86_POP(block, REG_R12);
#ifdef _WIN64
host_x86_POP(block, REG_RDI);
host_x86_POP(block, REG_RSI);
#endif
host_x86_POP(block, REG_RBP);
host_x86_POP(block, REG_RDX);
host_x86_RET(block);

View File

@@ -1,5 +1,5 @@
/*RBP = cpu_state + 128
R12 = ram (if block->flags & CODEBLOCK_NO_IMMEDIATES)*/
R12 = ram + 2147483648 (if block->flags & CODEBLOCK_NO_IMMEDIATES)*/
#define REG_AX 0
#define REG_CX 1
#define REG_DX 2

View File

@@ -505,7 +505,7 @@ host_x86_MOV8_ABS_IMM(codeblock_t *block, void *p, uint32_t imm_data)
{
int64_t offset = (uintptr_t) p - (((uintptr_t) &cpu_state) + 128);
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 4);
codegen_addbyte3(block, 0xc6, 0x45, offset); /*MOVB offset[RBP], imm_data*/
codegen_addbyte(block, imm_data);
@@ -528,7 +528,7 @@ host_x86_MOV16_ABS_IMM(codeblock_t *block, void *p, uint16_t imm_data)
{
int64_t offset = (uintptr_t) p - (((uintptr_t) &cpu_state) + 128);
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 6);
codegen_addbyte4(block, 0x66, 0xc7, 0x45, offset); /*MOV offset[RBP], imm_data*/
codegen_addword(block, imm_data);
@@ -551,7 +551,7 @@ host_x86_MOV32_ABS_IMM(codeblock_t *block, void *p, uint32_t imm_data)
{
int64_t offset = (uintptr_t) p - (((uintptr_t) &cpu_state) + 128);
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 7);
codegen_addbyte3(block, 0xc7, 0x45, offset); /*MOV offset[RBP], imm_data*/
codegen_addlong(block, imm_data);
@@ -578,7 +578,7 @@ host_x86_MOV8_ABS_REG(codeblock_t *block, void *p, int src_reg)
if (src_reg & 8)
fatal("host_x86_MOV8_ABS_REG - bad reg\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 3);
codegen_addbyte3(block, 0x88, 0x45 | ((src_reg & 7) << 3), offset); /*MOVB offset[RBP], src_reg*/
} else if (offset < (1ULL << 32)) {
@@ -602,7 +602,7 @@ host_x86_MOV16_ABS_REG(codeblock_t *block, void *p, int src_reg)
if (src_reg & 8)
fatal("host_x86_MOV16_ABS_REG - bad reg\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x66, 0x89, 0x45 | ((src_reg & 7) << 3), offset); /*MOV offset[RBP], src_reg*/
} else if (offset < (1ULL << 32)) {
@@ -622,7 +622,7 @@ host_x86_MOV32_ABS_REG(codeblock_t *block, void *p, int src_reg)
if (src_reg & 8)
fatal("host_x86_MOV32_ABS_REG - bad reg\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 3);
codegen_addbyte3(block, 0x89, 0x45 | ((src_reg & 7) << 3), offset); /*MOV offset[RBP], src_reg*/
} else if (offset < (1ULL << 32)) {
@@ -646,7 +646,7 @@ host_x86_MOV64_ABS_REG(codeblock_t *block, void *p, int src_reg)
if (src_reg & 8)
fatal("host_x86_MOV64_ABS_REG - bad reg\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x48, 0x89, 0x45 | ((src_reg & 7) << 3), offset); /*MOV offset[RBP], src_reg*/
} else if (offset < (1ULL << 32)) {
@@ -706,19 +706,19 @@ void
host_x86_MOV8_REG_ABS(codeblock_t *block, int dst_reg, void *p)
{
int64_t offset = (uintptr_t) p - (((uintptr_t) &cpu_state) + 128);
int64_t ram_offset = (uintptr_t) p - (uintptr_t) ram;
int64_t ram_offset = (uintptr_t) p - (((uintptr_t) ram) + 2147483648ULL);
if (dst_reg & 8)
fatal("host_x86_MOV8_REG_ABS reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 3);
codegen_addbyte3(block, 0x8a, 0x45 | ((dst_reg & 7) << 3), offset); /*MOV dst_reg, offset[RBP]*/
} else if (offset < (1ULL << 32)) {
codegen_alloc_bytes(block, 6);
codegen_addbyte2(block, 0x8a, 0x85 | ((dst_reg & 7) << 3)); /*MOV dst_reg, offset[RBP]*/
codegen_addlong(block, offset);
} else if ((ram_offset < (1ULL << 32)) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
} else if ((ram_offset >= -2147483648LL) && (ram_offset <= 2147483647LL) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
codegen_alloc_bytes(block, 8);
codegen_addbyte4(block, 0x41, 0x8a, 0x84 | ((dst_reg & 7) << 3), 0x24); /*MOV dst_reg, ram_offset[R12]*/
codegen_addlong(block, ram_offset);
@@ -730,19 +730,19 @@ void
host_x86_MOV16_REG_ABS(codeblock_t *block, int dst_reg, void *p)
{
int64_t offset = (uintptr_t) p - (((uintptr_t) &cpu_state) + 128);
int64_t ram_offset = (uintptr_t) p - (uintptr_t) ram;
int64_t ram_offset = (uintptr_t) p - (((uintptr_t) ram) + 2147483648ULL);
if (dst_reg & 8)
fatal("host_x86_MOV16_REG_ABS reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x66, 0x8b, 0x45 | ((dst_reg & 7) << 3), offset); /*MOV dst_reg, offset[RBP]*/
} else if (offset < (1ULL << 32)) {
codegen_alloc_bytes(block, 7);
codegen_addbyte3(block, 0x66, 0x8b, 0x85 | ((dst_reg & 7) << 3)); /*MOV dst_reg, offset[RBP]*/
codegen_addlong(block, offset);
} else if ((ram_offset < (1ULL << 32)) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
} else if ((ram_offset >= -2147483648LL) && (ram_offset <= 2147483647LL) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
codegen_alloc_bytes(block, 9);
codegen_addbyte4(block, 0x66, 0x41, 0x8b, 0x84 | ((dst_reg & 7) << 3)); /*MOV dst_reg, ram_offset[R12]*/
codegen_addbyte(block, 0x24);
@@ -760,19 +760,19 @@ void
host_x86_MOV32_REG_ABS(codeblock_t *block, int dst_reg, void *p)
{
int64_t offset = (uintptr_t) p - (((uintptr_t) &cpu_state) + 128);
int64_t ram_offset = (uintptr_t) p - (uintptr_t) ram;
int64_t ram_offset = (uintptr_t) p - (((uintptr_t) ram) + 2147483648ULL);
if (dst_reg & 8)
fatal("host_x86_MOV32_REG_ABS reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 3);
codegen_addbyte3(block, 0x8b, 0x45 | ((dst_reg & 7) << 3), offset); /*MOV dst_reg, offset[RBP]*/
} else if (offset < (1ULL << 32)) {
codegen_alloc_bytes(block, 6);
codegen_addbyte2(block, 0x8b, 0x85 | ((dst_reg & 7) << 3)); /*MOV dst_reg, offset[RBP]*/
codegen_addlong(block, offset);
} else if ((ram_offset < (1ULL << 32)) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
} else if ((ram_offset >= -2147483648LL) && (ram_offset <= 2147483647LL) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
codegen_alloc_bytes(block, 8);
codegen_addbyte4(block, 0x41, 0x8b, 0x84 | ((dst_reg & 7) << 3), 0x24); /*MOV dst_reg, ram_offset[R12]*/
codegen_addlong(block, ram_offset);
@@ -792,7 +792,7 @@ host_x86_MOV64_REG_ABS(codeblock_t *block, int dst_reg, void *p)
if (dst_reg & 8)
fatal("host_x86_MOV64_REG_ABS reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x48, 0x8b, 0x45 | ((dst_reg & 7) << 3), offset); /*MOV dst_reg, offset[RBP]*/
} else if (offset < (1ULL << 32)) {
@@ -845,14 +845,14 @@ host_x86_MOV16_REG_BASE_OFFSET(codeblock_t *block, int dst_reg, int base_reg, in
if ((dst_reg & 8) || (base_reg & 8))
fatal("host_x86_MOV16_REG_BASE_OFFSET reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
if (base_reg == REG_RSP) {
codegen_alloc_bytes(block, 5);
codegen_addbyte(block, 0x66);
codegen_addbyte(block, 0x66); /* MOV dst_reg, [RSP + offset] */
codegen_addbyte4(block, 0x8b, 0x40 | base_reg | (dst_reg << 3), 0x24, offset);
} else {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x66, 0x8b, 0x40 | base_reg | (dst_reg << 3), offset);
codegen_addbyte4(block, 0x66, 0x8b, 0x40 | base_reg | (dst_reg << 3), offset); /* MOV dst_reg, [base_reg + offset] */
}
} else
fatal("MOV16_REG_BASE_OFFSET - offset %i\n", offset);
@@ -863,13 +863,13 @@ host_x86_MOV32_REG_BASE_OFFSET(codeblock_t *block, int dst_reg, int base_reg, in
if ((dst_reg & 8) || (base_reg & 8))
fatal("host_x86_MOV32_REG_BASE_OFFSET reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
if (base_reg == REG_RSP) {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x8b, 0x40 | base_reg | (dst_reg << 3), 0x24, offset);
codegen_addbyte4(block, 0x8b, 0x40 | base_reg | (dst_reg << 3), 0x24, offset); /* MOV dst_reg, [RSP + offset] */
} else {
codegen_alloc_bytes(block, 3);
codegen_addbyte3(block, 0x8b, 0x40 | base_reg | (dst_reg << 3), offset);
codegen_addbyte3(block, 0x8b, 0x40 | base_reg | (dst_reg << 3), offset); /* MOV dst_reg, [base_reg + offset] */
}
} else
fatal("MOV32_REG_BASE_OFFSET - offset %i\n", offset);
@@ -880,14 +880,14 @@ host_x86_MOV64_REG_BASE_OFFSET(codeblock_t *block, int dst_reg, int base_reg, in
if ((dst_reg & 8) || (base_reg & 8))
fatal("host_x86_MOV64_REG_BASE_OFFSET reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
if (base_reg == REG_RSP) {
codegen_alloc_bytes(block, 5);
codegen_addbyte(block, 0x48);
codegen_addbyte(block, 0x48); /* MOV dst_reg, [RSP + offset] */
codegen_addbyte4(block, 0x8b, 0x40 | base_reg | (dst_reg << 3), 0x24, offset);
} else {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x48, 0x8b, 0x40 | base_reg | (dst_reg << 3), offset);
codegen_addbyte4(block, 0x48, 0x8b, 0x40 | base_reg | (dst_reg << 3), offset); /* MOV dst_reg, [base_reg + offset] */
}
} else
fatal("MOV32_REG_BASE_OFFSET - offset %i\n", offset);
@@ -899,13 +899,13 @@ host_x86_MOV32_BASE_OFFSET_REG(codeblock_t *block, int base_reg, int offset, int
if ((src_reg & 8) || (base_reg & 8))
fatal("host_x86_MOV32_BASE_OFFSET_REG reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
if (base_reg == REG_RSP) {
codegen_alloc_bytes(block, 4);
codegen_alloc_bytes(block, 4); /* MOV [RSP + offset], src_reg*/
codegen_addbyte4(block, 0x89, 0x40 | base_reg | (src_reg << 3), 0x24, offset);
} else {
codegen_alloc_bytes(block, 3);
codegen_addbyte3(block, 0x89, 0x40 | base_reg | (src_reg << 3), offset);
codegen_addbyte3(block, 0x89, 0x40 | base_reg | (src_reg << 3), offset); /* MOV [base_reg + offset], src_reg*/
}
} else
fatal("MOV32_BASE_OFFSET_REG - offset %i\n", offset);
@@ -916,14 +916,14 @@ host_x86_MOV64_BASE_OFFSET_REG(codeblock_t *block, int base_reg, int offset, int
if ((src_reg & 8) || (base_reg & 8))
fatal("host_x86_MOV64_BASE_OFFSET_REG reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
if (base_reg == REG_RSP) {
codegen_alloc_bytes(block, 5);
codegen_addbyte(block, 0x48);
codegen_addbyte(block, 0x48); /* MOV [RSP + offset], src_reg*/
codegen_addbyte4(block, 0x89, 0x40 | base_reg | (src_reg << 3), 0x24, offset);
} else {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x48, 0x89, 0x40 | base_reg | (src_reg << 3), offset);
codegen_addbyte4(block, 0x48, 0x89, 0x40 | base_reg | (src_reg << 3), offset); /* MOV [base_reg + offset], src_reg*/
}
} else
fatal("MOV64_BASE_OFFSET_REG - offset %i\n", offset);
@@ -935,14 +935,14 @@ host_x86_MOV32_BASE_OFFSET_IMM(codeblock_t *block, int base_reg, int offset, uin
if (base_reg & 8)
fatal("host_x86_MOV32_BASE_OFFSET_IMM reg & 8\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
if (base_reg == REG_RSP) {
codegen_alloc_bytes(block, 8);
codegen_addbyte4(block, 0xc7, 0x40 | base_reg, 0x24, offset);
codegen_addbyte4(block, 0xc7, 0x40 | base_reg, 0x24, offset); /* MOV [RSP + offset], imm_data */
codegen_addlong(block, imm_data);
} else {
codegen_alloc_bytes(block, 7);
codegen_addbyte3(block, 0xc7, 0x40 | base_reg, offset);
codegen_addbyte3(block, 0xc7, 0x40 | base_reg, offset); /* MOV [base_reg + offset], src_reg*/
codegen_addlong(block, imm_data);
}
} else
@@ -1107,16 +1107,16 @@ void
host_x86_MOVZX_REG_ABS_16_8(codeblock_t *block, int dst_reg, void *p)
{
int64_t offset = (uintptr_t) p - (((uintptr_t) &cpu_state) + 128);
int64_t ram_offset = (uintptr_t) p - (uintptr_t) ram;
int64_t ram_offset = (uintptr_t) p - (((uintptr_t) ram) + 2147483648ULL);
if (dst_reg & 8)
fatal("host_x86_MOVZX_REG_ABS_16_8 - bad reg\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 5);
codegen_addbyte(block, 0x66);
codegen_addbyte4(block, 0x0f, 0xb6, 0x45 | ((dst_reg & 7) << 3), offset); /*MOVZX dst_reg, offset[RBP]*/
} else if ((ram_offset < (1ULL << 32)) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
} else if ((ram_offset >= -2147483648LL) && (ram_offset <= 2147483647LL) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
codegen_alloc_bytes(block, 10);
codegen_addbyte2(block, 0x66, 0x41);
codegen_addbyte4(block, 0x0f, 0xb6, 0x84 | ((dst_reg & 7) << 3), 0x24); /*MOVZX dst_reg, ram_offset[R12]*/
@@ -1134,14 +1134,14 @@ void
host_x86_MOVZX_REG_ABS_32_8(codeblock_t *block, int dst_reg, void *p)
{
int64_t offset = (uintptr_t) p - (((uintptr_t) &cpu_state) + 128);
int64_t ram_offset = (uintptr_t) p - (uintptr_t) ram;
int64_t ram_offset = (uintptr_t) p - (((uintptr_t) ram) + 2147483648ULL);
#if 0
if (dst_reg & 8)
fatal("host_x86_MOVZX_REG_ABS_32_8 - bad reg\n");
#endif
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
if (dst_reg & 8) {
codegen_alloc_bytes(block, 5);
codegen_addbyte(block, 0x44);
@@ -1150,7 +1150,7 @@ host_x86_MOVZX_REG_ABS_32_8(codeblock_t *block, int dst_reg, void *p)
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x0f, 0xb6, 0x45 | ((dst_reg & 7) << 3), offset); /*MOVZX dst_reg, offset[RBP]*/
}
} else if ((ram_offset < (1ULL << 32)) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
} else if ((ram_offset >= -2147483648LL) && (ram_offset <= 2147483647LL) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
if (dst_reg & 8)
fatal("host_x86_MOVZX_REG_ABS_32_8 - bad reg\n");
@@ -1173,15 +1173,15 @@ void
host_x86_MOVZX_REG_ABS_32_16(codeblock_t *block, int dst_reg, void *p)
{
int64_t offset = (uintptr_t) p - (((uintptr_t) &cpu_state) + 128);
int64_t ram_offset = (uintptr_t) p - (uintptr_t) ram;
int64_t ram_offset = (uintptr_t) p - (((uintptr_t) ram) + 2147483648ULL);
if (dst_reg & 8)
fatal("host_x86_MOVZX_REG_ABS_32_16 - bad reg\n");
if (offset >= -128 && offset < 127) {
if (offset >= -128 && offset <= 127) {
codegen_alloc_bytes(block, 4);
codegen_addbyte4(block, 0x0f, 0xb7, 0x45 | ((dst_reg & 7) << 3), offset); /*MOVZX dst_reg, offset[RBP]*/
} else if ((ram_offset < (1ULL << 32)) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
} else if ((ram_offset >= -2147483648LL) && (ram_offset <= 2147483647LL) && (block->flags & CODEBLOCK_NO_IMMEDIATES)) {
codegen_alloc_bytes(block, 9);
codegen_addbyte(block, 0x41);
codegen_addbyte4(block, 0x0f, 0xb7, 0x84 | ((dst_reg & 7) << 3), 0x24); /*MOVZX dst_reg, ram_offset[R12]*/