diff --git a/gen/gen_code.cpp b/gen/gen_code.cpp index f638016..c62fa35 100644 --- a/gen/gen_code.cpp +++ b/gen/gen_code.cpp @@ -720,6 +720,7 @@ void put() { "wbinvd", 0x0F, 0x09 }, { "wrmsr", 0x0F, 0x30 }, { "xlatb", 0xD7 }, + { "xend", 0x0f, 0x01, 0xd5 }, { "popf", 0x9D }, { "pushf", 0x9C }, @@ -1113,6 +1114,8 @@ void put() puts("void umwait(const Reg32& r) { int idx = r.getIdx(); if (idx > 7) XBYAK_THROW(ERR_BAD_PARAMETER) db(0xF2); db(0x0F); db(0xAE); setModRM(3, 6, idx); }"); puts("void clwb(const Address& addr) { db(0x66); opMIB(addr, esi, 0x0F, 0xAE); }"); puts("void cldemote(const Address& addr) { opMIB(addr, eax, 0x0F, 0x1C); }"); + puts("void xabort(uint8_t imm) { db(0xC6); db(0xF8); db(imm); }"); + puts("void xbegin(uint32_t rel) { db(0xC7); db(0xF8); dd(rel); }"); } { const struct Tbl { diff --git a/test/Makefile b/test/Makefile index 6a68dfc..28d8e6f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -115,3 +115,4 @@ lib_run: lib_test.cpp lib_run.cpp lib.h $(CXX) $(CFLAGS) lib_run.cpp lib_test.cpp -o lib_run make_nm: make_nm.cpp $(XBYAK_INC) +.PHONY: test diff --git a/test/make_nm.cpp b/test/make_nm.cpp index f54fade..b257dcd 100644 --- a/test/make_nm.cpp +++ b/test/make_nm.cpp @@ -558,6 +558,7 @@ class Test { "wbinvd", "wrmsr", "xlatb", + "xend", "popf", "pushf", @@ -1333,6 +1334,7 @@ class Test { #ifdef XBYAK64 put("cmpxchg16b", MEM); put("fxrstor64", MEM); + put("xbegin", "0x12345678"); #endif { const char tbl[][8] = { @@ -1355,6 +1357,7 @@ class Test { put("xchg", EAX|REG32, EAX|REG32|MEM); put("xchg", MEM, EAX|REG32); put("xchg", REG64, REG64|MEM); + put("xabort", IMM8); } void putShift() const { diff --git a/test/normalize_prefix.cpp b/test/normalize_prefix.cpp index 889d925..f85a341 100644 --- a/test/normalize_prefix.cpp +++ b/test/normalize_prefix.cpp @@ -8,14 +8,25 @@ typedef unsigned char uint8_t; -std::string normalize(const std::string& line) +std::string normalize(std::string line) { + size_t pos = line.find('('); + /* nasm generates byte codes containing () for xbegin, so remove it. */ + if (pos != std::string::npos) { + line.erase(pos, 1); + pos = line.find(')'); + if (pos == std::string::npos) { + fprintf(stderr, "line error {%s}\n", line.c_str()); + return ""; + } + line.erase(pos, 1); + } static const char tbl[][3] = { "66", "67", "F2", "F3" }; size_t tblNum = sizeof(tbl) / sizeof(tbl[0]); typedef std::set StringSet; StringSet suf; - size_t pos = 0; + pos = 0; for (; pos < line.size(); pos += 2) { bool found = false; for (size_t i = 0; i < tblNum; i++) { diff --git a/xbyak/xbyak_mnemonic.h b/xbyak/xbyak_mnemonic.h index c98f837..b2129e4 100644 --- a/xbyak/xbyak_mnemonic.h +++ b/xbyak/xbyak_mnemonic.h @@ -1374,7 +1374,10 @@ void vzeroupper() { db(0xC5); db(0xF8); db(0x77); } void wait() { db(0x9B); } void wbinvd() { db(0x0F); db(0x09); } void wrmsr() { db(0x0F); db(0x30); } +void xabort(uint8_t imm) { db(0xC6); db(0xF8); db(imm); } void xadd(const Operand& op, const Reg& reg) { opModRM(reg, op, (op.isREG() && reg.isREG() && op.getBit() == reg.getBit()), op.isMEM(), 0x0F, 0xC0 | (reg.isBit(8) ? 0 : 1)); } +void xbegin(uint32_t rel) { db(0xC7); db(0xF8); dd(rel); } +void xend() { db(0x0F); db(0x01); db(0xD5); } void xgetbv() { db(0x0F); db(0x01); db(0xD0); } void xlatb() { db(0xD7); } void xor_(const Operand& op, uint32_t imm) { opRM_I(op, imm, 0x30, 6); }