diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-09-29 12:06:28 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-09-29 17:44:50 -0700 |
commit | ef79039287b7a76f4fcb0628a6295582d8caf768 (patch) | |
tree | 15cccf34d0a8a451c95e16bb8ae05e2e389d4fd1 /subx/035labels.cc | |
parent | 8fb01417031f2c6eaa8af505112ed1bb1a51ea21 (diff) | |
download | mu-ef79039287b7a76f4fcb0628a6295582d8caf768.tar.gz |
4616 - fix subx/examples/ex7
It was broken since I added support for global variables, back on Sep 1. One other subtle thing I've improved is the name `looks_like_hex_int`. We can now distinguish in the pack-operands transform between ignoring 'foo' because it doesn't look like a number, and immediately flagging '0xfoo' as an error because it *should* be a number.
Diffstat (limited to 'subx/035labels.cc')
-rw-r--r-- | subx/035labels.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/subx/035labels.cc b/subx/035labels.cc index 96668075..ddaeabad 100644 --- a/subx/035labels.cc +++ b/subx/035labels.cc @@ -18,6 +18,34 @@ //: be a single character long. 'a' is not a hex number, it's a variable. //: Later layers may add more conventions partitioning the space of names. But //: the above rules will remain inviolate. + +:(before "End looks_like_hex_int(s) Detectors") +if (SIZE(s) == 2) return true; + +:(scenarios transform) +:(scenario pack_immediate_ignores_single_byte_nondigit_operand) +== 0x1 +b9/copy a/imm32 # copy to ECX ++transform: packing instruction 'b9/copy a/imm32' +# no change (we're just not printing metadata to the trace) ++transform: instruction after packing: 'b9 a' + +:(scenario pack_immediate_ignores_3_hex_digit_operand) +== 0x1 +b9/copy aaa/imm32 # copy to ECX ++transform: packing instruction 'b9/copy aaa/imm32' +# no change (we're just not printing metadata to the trace) ++transform: instruction after packing: 'b9 aaa' + +:(scenario pack_immediate_ignores_non_hex_operand) +== 0x1 +b9/copy xxx/imm32 # copy to ECX ++transform: packing instruction 'b9/copy xxx/imm32' +# no change (we're just not printing metadata to the trace) ++transform: instruction after packing: 'b9 xx' + +//: a helper we'll find handy later +:(code) void check_valid_name(const string& s) { if (s.empty()) { raise << "empty name!\n" << end(); @@ -35,7 +63,8 @@ void check_valid_name(const string& s) { raise << "'" << s << "' is two characters long which can look like raw hex bytes at a glance; use a different name\n" << end(); } -:(scenarios transform) +//: Now that that's done, let's start using names as labels. + :(scenario map_label) == 0x1 # instruction effective address operand displacement immediate |