From 1fae63de23320a1663b7c591e247ad81852ab6dc Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 22 Nov 2020 13:00:06 +0100 Subject: Support 16-bit short --- asm/parse.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'asm/parse.cpp') diff --git a/asm/parse.cpp b/asm/parse.cpp index 28e79f3..a3156c2 100644 --- a/asm/parse.cpp +++ b/asm/parse.cpp @@ -106,6 +106,25 @@ namespace { return false; } + bool parseRegister16(const std::string& asm_code, size_t& pos, std::any& result, size_t& size_hint) { + parseWhitespace(asm_code, pos); + + std::regex re_name(reg_re, std::regex_constants::ECMAScript); + + std::smatch match; + if (std::regex_search(asm_code.cbegin() + pos, asm_code.cend(), match, re_name, std::regex_constants::match_continuous)) { + std::string name {boost::algorithm::to_lower_copy(match[0].str())}; + if (reg16.contains(name)) { + pos += name.size(); + result = Asm::Args::Register16(name); + size_hint = 16; + return true; + } + } + + return false; + } + bool parseRegister32(const std::string& asm_code, size_t& pos, std::any& result, size_t& size_hint) { parseWhitespace(asm_code, pos); @@ -163,6 +182,25 @@ namespace { return false; } + bool parseMem16Ptr64(const std::string& asm_code, size_t& pos, std::any& result, size_t& size_hint) { + parseWhitespace(asm_code, pos); + + std::regex re_name("(word ptr *)?\\[("s + reg_re + ")\\]"s, std::regex_constants::ECMAScript); + + std::smatch match; + if (std::regex_search(asm_code.cbegin() + pos, asm_code.cend(), match, re_name, std::regex_constants::match_continuous)) { + std::string name {boost::algorithm::to_lower_copy(match[2].str())}; + if (reg16.contains(name)) { + pos += match[0].length(); + result = Asm::Args::Mem16Ptr64(name); + size_hint = 16; + return true; + } + } + + return false; + } + bool parseMem32Ptr64(const std::string& asm_code, size_t& pos, std::any& result, size_t& size_hint) { parseWhitespace(asm_code, pos); @@ -283,6 +321,8 @@ namespace { if (parseRegister8(asm_code, pos, result, size_hint)) return true; + if (parseRegister16(asm_code, pos, result, size_hint)) + return true; if (parseRegister32(asm_code, pos, result, size_hint)) return true; if (parseRegister64(asm_code, pos, result, size_hint)) @@ -290,6 +330,8 @@ namespace { if (parseMem8Ptr64(asm_code, pos, result, size_hint)) return true; + if (parseMem16Ptr64(asm_code, pos, result, size_hint)) + return true; if (parseMem32Ptr64(asm_code, pos, result, size_hint)) return true; if (parseMem64Ptr64(asm_code, pos, result, size_hint)) -- cgit v1.2.3