diff options
author | Kartik Agaram <github@akkartik.com> | 2018-07-26 11:15:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-26 11:15:44 -0700 |
commit | 7da8da495fbe9422f13198a83193d4b5477bf8f6 (patch) | |
tree | 308a9a53656aecdaa991b62af1801c09f7f3cff5 | |
parent | d2571b69b17c65380347d4b669ab51ff0ea6eebc (diff) | |
parent | fd06455396f5acb9f43b703652eaff904913db87 (diff) | |
download | mu-7da8da495fbe9422f13198a83193d4b5477bf8f6.tar.gz |
Merge pull request #17 from tekknolagi/master
Use semicolons instead of commas for sequencing
-rw-r--r-- | subx/024pack_instructions.cc | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/subx/024pack_instructions.cc b/subx/024pack_instructions.cc index 92e557ae..bb63cb00 100644 --- a/subx/024pack_instructions.cc +++ b/subx/024pack_instructions.cc @@ -80,14 +80,22 @@ void add_modrm_byte(const line& in, line& out) { bool emit = false; for (int i = 0; i < SIZE(in.words); ++i) { const word& curr = in.words.at(i); - if (has_metadata(curr, "mod")) - mod = hex_byte(curr.data), emit = true; - else if (has_metadata(curr, "rm32")) - rm32 = hex_byte(curr.data), emit = true; - else if (has_metadata(curr, "r32")) - reg_subop = hex_byte(curr.data), emit = true; - else if (has_metadata(curr, "subop")) - reg_subop = hex_byte(curr.data), emit = true; + if (has_metadata(curr, "mod")) { + mod = hex_byte(curr.data); + emit = true; + } + else if (has_metadata(curr, "rm32")) { + rm32 = hex_byte(curr.data); + emit = true; + } + else if (has_metadata(curr, "r32")) { + reg_subop = hex_byte(curr.data); + emit = true; + } + else if (has_metadata(curr, "subop")) { + reg_subop = hex_byte(curr.data); + emit = true; + } } if (emit) out.words.push_back(hex_byte_text((mod << 6) | (reg_subop << 3) | rm32)); @@ -98,12 +106,18 @@ void add_sib_byte(const line& in, line& out) { bool emit = false; for (int i = 0; i < SIZE(in.words); ++i) { const word& curr = in.words.at(i); - if (has_metadata(curr, "scale")) - scale = hex_byte(curr.data), emit = true; - else if (has_metadata(curr, "index")) - index = hex_byte(curr.data), emit = true; - else if (has_metadata(curr, "base")) - base = hex_byte(curr.data), emit = true; + if (has_metadata(curr, "scale")) { + scale = hex_byte(curr.data); + emit = true; + } + else if (has_metadata(curr, "index")) { + index = hex_byte(curr.data); + emit = true; + } + else if (has_metadata(curr, "base")) { + base = hex_byte(curr.data); + emit = true; + } } if (emit) out.words.push_back(hex_byte_text((scale << 6) | (index << 3) | base)); |