MCPcopy Create free account
hub / github.com/GJDuck/e9patch / sendMovFromStackToR64

Function sendMovFromStackToR64

src/e9tool/e9codegen.cpp:1286–1310  ·  view source on GitHub ↗

* Send a `mov offset(%rsp),%r64' instruction. */

Source from the content-addressed store, hash-verified

1284 * Send a `mov offset(%rsp),%r64' instruction.
1285 */
1286void sendMovFromStackToR64(FILE *out, int32_t offset, int regno)
1287{
1288 const uint8_t REX[] =
1289 {0x48, 0x48, 0x48, 0x48, 0x4c, 0x4c, 0x00,
1290 0x48, 0x4c, 0x4c, 0x48, 0x48, 0x4c, 0x4c, 0x4c, 0x4c, 0x48};
1291 const uint8_t MODRM_0[] =
1292 {0x3c, 0x34, 0x14, 0x0c, 0x04, 0x0c, 0x00,
1293 0x04, 0x14, 0x1c, 0x1c, 0x2c, 0x24, 0x2c, 0x34, 0x3c, 0x24};
1294 const uint8_t MODRM_8[] =
1295 {0x7c, 0x74, 0x54, 0x4c, 0x44, 0x4c, 0x00,
1296 0x44, 0x54, 0x5c, 0x5c, 0x6c, 0x64, 0x6c, 0x74, 0x7c, 0x64};
1297 const uint8_t MODRM_32[] =
1298 {0xbc, 0xb4, 0x94, 0x8c, 0x84, 0x8c, 0x00,
1299 0x84, 0x94, 0x9c, 0x9c, 0xac, 0xa4, 0xac, 0xb4, 0xbc, 0xa4};
1300
1301 if (offset == 0)
1302 fprintf(out, "%u,%u,%u,%u,",
1303 REX[regno], 0x8b, MODRM_0[regno], 0x24);
1304 else if (offset >= INT8_MIN && offset <= INT8_MAX)
1305 fprintf(out, "%u,%u,%u,%u,{\"int8\":%d},",
1306 REX[regno], 0x8b, MODRM_8[regno], 0x24, offset);
1307 else
1308 fprintf(out, "%u,%u,%u,%u,{\"int32\":%d},",
1309 REX[regno], 0x8b, MODRM_32[regno], 0x24, offset);
1310}
1311
1312/*
1313 * Send a `movslq offset(%rsp),%r64' instruction.

Callers 7

sendTemporaryRestoreRegFunction · 0.85
sendUndoTemporaryMovRegFunction · 0.85
sendLoadRegToArgFunction · 0.85
sendLoadTargetMetadataFunction · 0.85
sendCallMetadataMethod · 0.85
sendPushFunction · 0.85
sendPopFunction · 0.85

Calls 1

fprintfFunction · 0.50

Tested by

no test coverage detected