summaryrefslogtreecommitdiff
path: root/gen_x86.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2014-12-22 20:55:10 -0800
committerMichael Pavone <pavone@retrodev.com>2014-12-22 20:55:10 -0800
commit12c73dc400c1b6b61531df4ff0fd1efe4ef7ae12 (patch)
tree12f0b6e224aac2cadc0199e040a9f4dc579d920d /gen_x86.c
parent4cad512b6d7ac0f7042b90e1029626fb14788bf0 (diff)
Z80 core is sort of working again
Diffstat (limited to 'gen_x86.c')
-rw-r--r--gen_x86.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gen_x86.c b/gen_x86.c
index ccc03eb..b1b48d4 100644
--- a/gen_x86.c
+++ b/gen_x86.c
@@ -33,6 +33,7 @@
#define OP_TEST 0x84
#define OP_XCHG 0x86
#define OP_MOV 0x88
+#define PRE_XOP 0x8F
#define OP_XCHG_AX 0x90
#define OP_CDQ 0x99
#define OP_PUSHF 0x9C
@@ -1516,6 +1517,13 @@ void push_r(code_info *code, uint8_t reg)
code->cur = out;
}
+void push_rdisp(code_info *code, uint8_t base, int32_t disp)
+{
+ //This instruction has no explicit size, so we pass SZ_B
+ //to avoid any prefixes or bits being set
+ x86_rdisp_size(code, OP_SINGLE_EA, OP_EX_PUSH_EA, base, disp, SZ_B);
+}
+
void pop_r(code_info *code, uint8_t reg)
{
check_alloc_code(code, 2);
@@ -1528,6 +1536,19 @@ void pop_r(code_info *code, uint8_t reg)
code->cur = out;
}
+void pop_rind(code_info *code, uint8_t reg)
+{
+ check_alloc_code(code, 3);
+ code_ptr out = code->cur;
+ if (reg >= R8) {
+ *(out++) = PRE_REX | REX_RM_FIELD;
+ reg -= R8 - X86_R8;
+ }
+ *(out++) = PRE_XOP;
+ *(out++) = MODE_REG_INDIRECT | reg;
+ code->cur = out;
+}
+
void setcc_r(code_info *code, uint8_t cc, uint8_t dst)
{
check_alloc_code(code, 4);
@@ -1855,6 +1876,19 @@ void jmp_r(code_info *code, uint8_t dst)
code->cur = out;
}
+void jmp_rind(code_info *code, uint8_t dst)
+{
+ check_alloc_code(code, 3);
+ code_ptr out = code->cur;
+ if (dst >= R8) {
+ dst -= R8 - X86_R8;
+ *(out++) = PRE_REX | REX_RM_FIELD;
+ }
+ *(out++) = OP_SINGLE_EA;
+ *(out++) = MODE_REG_INDIRECT | dst | (OP_EX_JMP_EA << 3);
+ code->cur = out;
+}
+
void call(code_info *code, code_ptr fun)
{
check_alloc_code(code, 5);