about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
Diffstat (limited to 'subx')
-rw-r--r--subx/031check_operands.cc2
-rw-r--r--subx/032check_operand_bounds.cc4
-rw-r--r--subx/033non_code_segment.cc2
-rw-r--r--subx/034discourage_raw_hex.cc11
-rw-r--r--subx/100index2
5 files changed, 11 insertions, 10 deletions
diff --git a/subx/031check_operands.cc b/subx/031check_operands.cc
index 882a91db..73a6e3d3 100644
--- a/subx/031check_operands.cc
+++ b/subx/031check_operands.cc
@@ -10,7 +10,7 @@
   cd                                                                                                                                                # int ??
 +error: 'cd' (software interrupt): missing imm8 operand
 
-:(after "Pack Operands")
+:(before "Pack Operands(segment code)")
 check_operands(code);
 if (trace_contains_errors()) return;
 
diff --git a/subx/032check_operand_bounds.cc b/subx/032check_operand_bounds.cc
index 7ed2732b..9a810453 100644
--- a/subx/032check_operand_bounds.cc
+++ b/subx/032check_operand_bounds.cc
@@ -3,7 +3,7 @@
 :(scenario check_bitfield_sizes)
 % Hide_errors = true;
 == 0x1
-01/add 4/mod
+01/add 4/mod 3/rm32 1/r32  # add ECX to EBX
 +error: '4/mod' too large to fit in bitfield mod
 
 :(before "End Globals")
@@ -22,7 +22,7 @@ put(Operand_bound, "disp16", 1<<16);
 put(Operand_bound, "imm8", 1<<8);
 // no bound needed for imm32
 
-:(after "Pack Operands")
+:(before "Pack Operands(segment code)")
 check_operand_bounds(code);
 if (trace_contains_errors()) return;
 :(code)
diff --git a/subx/033non_code_segment.cc b/subx/033non_code_segment.cc
index 829a61ca..c0549023 100644
--- a/subx/033non_code_segment.cc
+++ b/subx/033non_code_segment.cc
@@ -8,7 +8,7 @@ cd 0x80/imm8
 cd 12/imm8
 +error: 12/imm8: metadata imm8 is only allowed in the (first) code segment
 
-:(after "Pack Operands")
+:(before "Pack Operands(segment code)")
 ensure_operands_only_in_code_segments(p);
 if (trace_contains_errors()) return;
 :(code)
diff --git a/subx/034discourage_raw_hex.cc b/subx/034discourage_raw_hex.cc
index 8d5eac7d..2b2e2675 100644
--- a/subx/034discourage_raw_hex.cc
+++ b/subx/034discourage_raw_hex.cc
@@ -4,15 +4,14 @@
 //: While SubX will let you write raw machine code, don't do that unless you
 //: have a very good reason.
 
-:(after "Begin Level-2 Transforms")
-Transform.push_back(warn_on_raw_jumps);
+:(before "Pack Operands(segment code)")
+warn_on_raw_hex(code);
+if (trace_contains_errors()) return;
 :(code)
-void warn_on_raw_jumps(/*const*/ program& p) {
-  if (p.segments.empty()) return;
-  segment& code = p.segments.at(0);
+void warn_on_raw_hex(const segment& code) {
   trace(99, "transform") << "-- warn on raw hex instructions" << end();
   for (int i = 0;  i < SIZE(code.lines);  ++i) {
-    line& inst = code.lines.at(i);
+    const line& inst = code.lines.at(i);
     if (all_hex_bytes(inst) && has_operands(inst)) {
       warn << "'" << to_string(inst) << "': using raw hex is not recommended\n" << end();
       break;
diff --git a/subx/100index b/subx/100index
index db6f4cdd..355b43d3 100644
--- a/subx/100index
+++ b/subx/100index
@@ -3,6 +3,8 @@
 10-29: level 1, the SubX subset of the 32-bit x86 ISA
 30-39: level 2, moving past counting bytes with operands and labels
 
+See layer 29 for the description of 'level'.
+
 --- Overview of tracing depths
 0: errors
 1-98: app level traces for different SubX programs