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

Function sendLeaFromStackToR64

src/e9tool/e9codegen.cpp:1584–1604  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1582 * Send a `lea offset(%rsp),%r64' instruction.
1583 */
1584void sendLeaFromStackToR64(FILE *out, int32_t offset, int regno)
1585{
1586 const uint8_t REX[] =
1587 {0x48, 0x48, 0x48, 0x48, 0x4c, 0x4c, 0x00,
1588 0x48, 0x4c, 0x4c, 0x48, 0x48, 0x4c, 0x4c, 0x4c, 0x4c, 0x48};
1589 const uint8_t MODRM_8[] =
1590 {0x7c, 0x74, 0x54, 0x4c, 0x44, 0x4c, 0x00,
1591 0x44, 0x54, 0x5c, 0x5c, 0x6c, 0x64, 0x6c, 0x74, 0x7c, 0x64};
1592 const uint8_t MODRM_32[] =
1593 {0xbc, 0xb4, 0x94, 0x8c, 0x84, 0x8c, 0x00,
1594 0x84, 0x94, 0x9c, 0x9c, 0xac, 0xa4, 0xac, 0xb4, 0xbc, 0xa4};
1595
1596 if (offset == 0)
1597 sendMovFromR64ToR64(out, RSP_IDX, regno);
1598 else if (offset >= INT8_MIN && offset <= INT8_MAX)
1599 fprintf(out, "%u,%u,%u,%u,{\"int8\":%d},",
1600 REX[regno], 0x8d, MODRM_8[regno], 0x24, offset);
1601 else
1602 fprintf(out, "%u,%u,%u,%u,{\"int32\":%d},",
1603 REX[regno], 0x8d, MODRM_32[regno], 0x24, offset);
1604}
1605

Callers 3

sendLoadRegToArgFunction · 0.85
sendLoadArgumentMetadataFunction · 0.85
sendPushFunction · 0.85

Calls 2

sendMovFromR64ToR64Function · 0.85
fprintfFunction · 0.50

Tested by

no test coverage detected