From 6515c93ecf61e79c48d56a662bc894f6881ede9f Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Mon, 16 Nov 2009 21:32:48 +0000 Subject: [PATCH] New instructions in gas2ack pause mfence rdtsc rdpmc --- commands/i386/gas2ack/asm86.h | 6 +++++- commands/i386/gas2ack/emit_ack.c | 16 ++++++---------- commands/i386/gas2ack/parse_gnu.c | 6 +++++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/commands/i386/gas2ack/asm86.h b/commands/i386/gas2ack/asm86.h index 499413312..52afc6917 100644 --- a/commands/i386/gas2ack/asm86.h +++ b/commands/i386/gas2ack/asm86.h @@ -129,6 +129,7 @@ typedef enum opcode { /* 80486 opcodes, from the i486 reference manual. LOOP, LOOPE, LOOPNE, LSL, LTR, + MFENCE, MOV, MOVS, MOVSX, @@ -142,6 +143,7 @@ typedef enum opcode { /* 80486 opcodes, from the i486 reference manual. OR, OUT, OUTS, + PAUSE, POP, POPA, POPAD, @@ -151,8 +153,10 @@ typedef enum opcode { /* 80486 opcodes, from the i486 reference manual. PUSHAD, PUSHF, RCL, RCR, ROL, ROR, - RET, RETF, /* RETF added */ RDMSR, + RDPMC, + RDTSC, + RET, RETF, /* RETF added */ SAHF, SAL, SAR, SHL, SHR, SBB, diff --git a/commands/i386/gas2ack/emit_ack.c b/commands/i386/gas2ack/emit_ack.c index 8b97d66c1..3082cc789 100644 --- a/commands/i386/gas2ack/emit_ack.c +++ b/commands/i386/gas2ack/emit_ack.c @@ -224,6 +224,7 @@ static mnemonic_t mnemtab[] = { { LSL, "lsl" }, { LSS, "lss" }, { LTR, "ltr" }, + { MFENCE, ".data1 0x0f, 0xae, 0x0f"}, { MOV, "mov%" }, { MOVS, "movs%" }, { MOVSX, "movsx" }, @@ -237,6 +238,7 @@ static mnemonic_t mnemtab[] = { { OR, "or%" }, { OUT, "out%" }, { OUTS, "outs%" }, + { PAUSE, ".data1 0xf3, 0x90"}, { POP, "pop" }, { POPA, "popa" }, { POPAD, "popad" }, @@ -249,7 +251,9 @@ static mnemonic_t mnemtab[] = { { RCR, "rcr%" }, { RET, "ret" }, { RETF, "retf" }, - { RDMSR, "rdmsr" }, + { RDMSR, ".data1 0x0f, 0x32"}, + { RDPMC, ".data1 0x0f, 0x33"}, + { RDTSC, ".data1 0x0f, 0x31"}, { ROL, "rol%" }, { ROR, "ror%" }, { SAHF, "sahf" }, @@ -292,7 +296,7 @@ static mnemonic_t mnemtab[] = { { VERW, "verw" }, { WAIT, "wait" }, { WBINVD, "wbinvd" }, - { WRMSR, "wrmsr" }, + { WRMSR, ".data1 0x0f, 0x30"}, { XADD, "xadd" }, { XCHG, "xchg%" }, { XLAT, "xlat" }, @@ -607,14 +611,6 @@ void ack_emit_instruction(asm86_t *a) return; } } - if (a->opcode == RDMSR) { - ack_printf(".data1 0x0f, 0x32\n"); - return; - } - if (a->opcode == WRMSR) { - ack_printf(".data1 0x0f, 0x30\n"); - return; - } /* we are translating from GNU */ if (a->args && a->args->operator == ',' /* don't swap ljmp prefixed with segment */ diff --git a/commands/i386/gas2ack/parse_gnu.c b/commands/i386/gas2ack/parse_gnu.c index 3c2674265..295cf9cb5 100644 --- a/commands/i386/gas2ack/parse_gnu.c +++ b/commands/i386/gas2ack/parse_gnu.c @@ -282,6 +282,7 @@ static mnemonic_t mnemtab[] = { /* This array is sorted. */ { "lsl", LSL, WORD }, { "lss", LSS, WORD }, { "ltr", LTR, WORD }, + { "mfence", MFENCE, WORD }, { "movb", MOV, BYTE }, { "movl", MOV, WORD }, { "movsb", MOVS, BYTE }, @@ -313,6 +314,7 @@ static mnemonic_t mnemtab[] = { /* This array is sorted. */ { "outsl", OUTS, WORD }, { "outsw", OUTS, OWORD }, { "outw", OUT, OWORD }, + { "pause", PAUSE, WORD }, { "pop", POP, WORD }, { "popa", POPA, WORD }, { "popal", POPAD, WORD }, @@ -332,9 +334,11 @@ static mnemonic_t mnemtab[] = { /* This array is sorted. */ { "rcrb", RCR, BYTE }, { "rcrl", RCR, WORD }, { "rcrw", RCR, OWORD }, + { "rdmsr", RDMSR, WORD }, + { "rdpmc", RDPMC, WORD }, + { "rdtsc", RDTSC, WORD }, { "ret", RET, JUMP }, { "retf", RETF, JUMP }, - { "rdmsr", RDMSR, WORD }, { "rolb", ROL, BYTE }, { "roll", ROL, WORD }, { "rolw", ROL, OWORD },