diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-11-22 13:00:06 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-11-22 13:00:06 +0100 |
commit | 1fae63de23320a1663b7c591e247ad81852ab6dc (patch) | |
tree | bfe539b7eeb5a4d7b68aa1bf853898d60e34f784 /asm/parse.cpp | |
parent | 739297d8895b08a9ecd8e81b01b7ba8e8dc4a8ae (diff) |
Support 16-bit short
Diffstat (limited to 'asm/parse.cpp')
-rw-r--r-- | asm/parse.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
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)) |