* Send a `mov %r64,offset(%rsp)' instruction. */
| 1400 | * Send a `mov %r64,offset(%rsp)' instruction. |
| 1401 | */ |
| 1402 | void sendMovFromR64ToStack(FILE *out, int regno, int32_t offset) |
| 1403 | { |
| 1404 | const uint8_t REX[] = |
| 1405 | {0x48, 0x48, 0x48, 0x48, 0x4c, 0x4c, 0x00, |
| 1406 | 0x48, 0x4c, 0x4c, 0x48, 0x48, 0x4c, 0x4c, 0x4c, 0x4c, 0x48}; |
| 1407 | const uint8_t MODRM_0[] = |
| 1408 | {0x3c, 0x34, 0x14, 0x0c, 0x04, 0x0c, 0x00, |
| 1409 | 0x04, 0x14, 0x1c, 0x1c, 0x2c, 0x24, 0x2c, 0x34, 0x3c, 0x24}; |
| 1410 | const uint8_t MODRM_8[] = |
| 1411 | {0x7c, 0x74, 0x54, 0x4c, 0x44, 0x4c, 0x00, |
| 1412 | 0x44, 0x54, 0x5c, 0x5c, 0x6c, 0x64, 0x6c, 0x74, 0x7c, 0x64}; |
| 1413 | const uint8_t MODRM_32[] = |
| 1414 | {0xbc, 0xb4, 0x94, 0x8c, 0x84, 0x8c, 0x00, |
| 1415 | 0x84, 0x94, 0x9c, 0x9c, 0xac, 0xa4, 0xac, 0xb4, 0xbc, 0xa4}; |
| 1416 | |
| 1417 | if (offset == 0) |
| 1418 | fprintf(out, "%u,%u,%u,%u,", |
| 1419 | REX[regno], 0x89, MODRM_0[regno], 0x24); |
| 1420 | else if (offset >= INT8_MIN && offset <= INT8_MAX) |
| 1421 | fprintf(out, "%u,%u,%u,%u,{\"int8\":%d},", |
| 1422 | REX[regno], 0x89, MODRM_8[regno], 0x24, offset); |
| 1423 | else |
| 1424 | fprintf(out, "%u,%u,%u,%u,{\"int32\":%d},", |
| 1425 | REX[regno], 0x89, MODRM_32[regno], 0x24, offset); |
| 1426 | } |
| 1427 | |
| 1428 | /* |
| 1429 | * Send a `movzwl %ax,%r32' instruction. |
no test coverage detected