about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subx/014jump_relative.cc252
-rw-r--r--subx/015jump_relative.cc238
-rw-r--r--subx/016jump_relative.cc258
-rw-r--r--subx/017functions.cc (renamed from subx/016functions.cc)0
4 files changed, 374 insertions, 374 deletions
diff --git a/subx/014jump_relative.cc b/subx/014jump_relative.cc
deleted file mode 100644
index c9cdcd1b..00000000
--- a/subx/014jump_relative.cc
+++ /dev/null
@@ -1,252 +0,0 @@
-//: jump to 8-bit offset
-
-//:: jump
-
-:(scenario jump_rel8)
-# op  ModRM   SIB   displacement  immediate
-  eb                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: jump 5
-+run: inst: 0x00000008
--run: inst: 0x00000003
-
-:(before "End Single-Byte Opcodes")
-case 0xeb: {  // jump rel8
-  int8_t offset = static_cast<int>(next());
-  trace(2, "run") << "jump " << NUM(offset) << end();
-  EIP += offset;
-  break;
-}
-
-//:: jump if equal/zero
-
-:(scenario je_rel8_success)
-% ZF = true;
-# op  ModRM   SIB   displacement  immediate
-  74                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: jump 5
-+run: inst: 0x00000008
--run: inst: 0x00000003
-
-:(before "End Single-Byte Opcodes")
-case 0x74: {  // jump rel8 if ZF
-  int8_t offset = static_cast<int>(next());
-  if (ZF) {
-    trace(2, "run") << "jump " << NUM(offset) << end();
-    EIP += offset;
-  }
-  break;
-}
-
-:(scenario je_rel8_fail)
-% ZF = false;
-# op  ModRM   SIB   displacement  immediate
-  74                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: inst: 0x00000003
-+run: inst: 0x00000008
--run: jump 5
-
-//:: jump if not equal/not zero
-
-:(scenario jne_rel8_success)
-% ZF = false;
-# op  ModRM   SIB   displacement  immediate
-  75                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: jump 5
-+run: inst: 0x00000008
--run: inst: 0x00000003
-
-:(before "End Single-Byte Opcodes")
-case 0x75: {  // jump rel8 unless ZF
-  int8_t offset = static_cast<int>(next());
-  if (!ZF) {
-    trace(2, "run") << "jump " << NUM(offset) << end();
-    EIP += offset;
-  }
-  break;
-}
-
-:(scenario jne_rel8_fail)
-% ZF = true;
-# op  ModRM   SIB   displacement  immediate
-  75                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: inst: 0x00000003
-+run: inst: 0x00000008
--run: jump 5
-
-//:: jump if greater
-
-:(scenario jg_rel8_success)
-% ZF = false;
-% SF = false;
-% OF = false;
-# op  ModRM   SIB   displacement  immediate
-  7f                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: jump 5
-+run: inst: 0x00000008
--run: inst: 0x00000003
-
-:(before "End Single-Byte Opcodes")
-case 0x7f: {  // jump rel8 if !SF and !ZF
-  int8_t offset = static_cast<int>(next());
-  if (!ZF && SF == OF) {
-    trace(2, "run") << "jump " << NUM(offset) << end();
-    EIP += offset;
-  }
-  break;
-}
-
-:(scenario jg_rel8_fail)
-% ZF = false;
-% SF = true;
-% OF = false;
-# op  ModRM   SIB   displacement  immediate
-  7f                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: inst: 0x00000003
-+run: inst: 0x00000008
--run: jump 5
-
-//:: jump if greater or equal
-
-:(scenario jge_rel8_success)
-% SF = false;
-% OF = false;
-# op  ModRM   SIB   displacement  immediate
-  7d                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: jump 5
-+run: inst: 0x00000008
--run: inst: 0x00000003
-
-:(before "End Single-Byte Opcodes")
-case 0x7d: {  // jump rel8 if !SF
-  int8_t offset = static_cast<int>(next());
-  if (SF == OF) {
-    trace(2, "run") << "jump " << NUM(offset) << end();
-    EIP += offset;
-  }
-  break;
-}
-
-:(scenario jge_rel8_fail)
-% SF = true;
-% OF = false;
-# op  ModRM   SIB   displacement  immediate
-  7d                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: inst: 0x00000003
-+run: inst: 0x00000008
--run: jump 5
-
-//:: jump if lesser
-
-:(scenario jl_rel8_success)
-% ZF = false;
-% SF = true;
-% OF = false;
-# op  ModRM   SIB   displacement  immediate
-  7c                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: jump 5
-+run: inst: 0x00000008
--run: inst: 0x00000003
-
-:(before "End Single-Byte Opcodes")
-case 0x7c: {  // jump rel8 if SF and !ZF
-  int8_t offset = static_cast<int>(next());
-  if (SF != OF) {
-    trace(2, "run") << "jump " << NUM(offset) << end();
-    EIP += offset;
-  }
-  break;
-}
-
-:(scenario jl_rel8_fail)
-% ZF = false;
-% SF = false;
-% OF = false;
-# op  ModRM   SIB   displacement  immediate
-  7c                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: inst: 0x00000003
-+run: inst: 0x00000008
--run: jump 5
-
-//:: jump if lesser or equal
-
-:(scenario jle_rel8_equal)
-% ZF = true;
-% SF = false;
-% OF = false;
-# op  ModRM   SIB   displacement  immediate
-  7e                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: jump 5
-+run: inst: 0x00000008
--run: inst: 0x00000003
-
-:(scenario jle_rel8_lesser)
-% ZF = false;
-% SF = true;
-% OF = false;
-# op  ModRM   SIB   displacement  immediate
-  7e                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: jump 5
-+run: inst: 0x00000008
--run: inst: 0x00000003
-
-:(before "End Single-Byte Opcodes")
-case 0x7e: {  // jump rel8 if SF or ZF
-  int8_t offset = static_cast<int>(next());
-  if (ZF || SF != OF) {
-    trace(2, "run") << "jump " << NUM(offset) << end();
-    EIP += offset;
-  }
-  break;
-}
-
-:(scenario jle_rel8_greater)
-% ZF = false;
-% SF = false;
-% OF = false;
-# op  ModRM   SIB   displacement  immediate
-  7e                05                        # skip 1 instruction
-  05                              00 00 00 01
-  05                              00 00 00 02
-+run: inst: 0x00000001
-+run: inst: 0x00000003
-+run: inst: 0x00000008
--run: jump 5
diff --git a/subx/015jump_relative.cc b/subx/015jump_relative.cc
index c4d92030..c9cdcd1b 100644
--- a/subx/015jump_relative.cc
+++ b/subx/015jump_relative.cc
@@ -1,47 +1,41 @@
-//: jump to 16-bit offset
+//: jump to 8-bit offset
 
 //:: jump
 
-:(scenario jump_rel16)
+:(scenario jump_rel8)
 # op  ModRM   SIB   displacement  immediate
-  e9                05 00                     # skip 1 instruction
+  eb                05                        # skip 1 instruction
   05                              00 00 00 01
   05                              00 00 00 02
 +run: inst: 0x00000001
 +run: jump 5
-+run: inst: 0x00000009
++run: inst: 0x00000008
 -run: inst: 0x00000003
 
 :(before "End Single-Byte Opcodes")
-case 0xe9: {  // jump rel8
-  int16_t offset = imm16();
-  trace(2, "run") << "jump " << offset << end();
+case 0xeb: {  // jump rel8
+  int8_t offset = static_cast<int>(next());
+  trace(2, "run") << "jump " << NUM(offset) << end();
   EIP += offset;
   break;
 }
-:(code)
-int16_t imm16() {
-  int16_t result = next();
-  result |= (next()<<8);
-  return result;
-}
 
 //:: jump if equal/zero
 
-:(scenario je_rel16_success)
+:(scenario je_rel8_success)
 % ZF = true;
-# op      ModRM   SIB   displacement  immediate
-  0f 84                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  74                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
 +run: jump 5
-+run: inst: 0x0000000a
--run: inst: 0x00000005
++run: inst: 0x00000008
+-run: inst: 0x00000003
 
-:(before "End Two-Byte Opcodes Starting With 0f")
-case 0x84: {  // jump rel16 if ZF
-  int8_t offset = imm16();
+:(before "End Single-Byte Opcodes")
+case 0x74: {  // jump rel8 if ZF
+  int8_t offset = static_cast<int>(next());
   if (ZF) {
     trace(2, "run") << "jump " << NUM(offset) << end();
     EIP += offset;
@@ -49,33 +43,33 @@ case 0x84: {  // jump rel16 if ZF
   break;
 }
 
-:(scenario je_rel16_fail)
+:(scenario je_rel8_fail)
 % ZF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 84                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  74                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
-+run: inst: 0x00000005
-+run: inst: 0x0000000a
++run: inst: 0x00000003
++run: inst: 0x00000008
 -run: jump 5
 
 //:: jump if not equal/not zero
 
-:(scenario jne_rel16_success)
+:(scenario jne_rel8_success)
 % ZF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 85                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  75                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
 +run: jump 5
-+run: inst: 0x0000000a
--run: inst: 0x00000005
++run: inst: 0x00000008
+-run: inst: 0x00000003
 
-:(before "End Two-Byte Opcodes Starting With 0f")
-case 0x85: {  // jump rel16 unless ZF
-  int8_t offset = imm16();
+:(before "End Single-Byte Opcodes")
+case 0x75: {  // jump rel8 unless ZF
+  int8_t offset = static_cast<int>(next());
   if (!ZF) {
     trace(2, "run") << "jump " << NUM(offset) << end();
     EIP += offset;
@@ -83,35 +77,35 @@ case 0x85: {  // jump rel16 unless ZF
   break;
 }
 
-:(scenario jne_rel16_fail)
+:(scenario jne_rel8_fail)
 % ZF = true;
-# op      ModRM   SIB   displacement  immediate
-  0f 85                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  75                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
-+run: inst: 0x00000005
-+run: inst: 0x0000000a
++run: inst: 0x00000003
++run: inst: 0x00000008
 -run: jump 5
 
 //:: jump if greater
 
-:(scenario jg_rel16_success)
+:(scenario jg_rel8_success)
 % ZF = false;
 % SF = false;
 % OF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 8f                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  7f                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
 +run: jump 5
-+run: inst: 0x0000000a
--run: inst: 0x00000005
++run: inst: 0x00000008
+-run: inst: 0x00000003
 
-:(before "End Two-Byte Opcodes Starting With 0f")
-case 0x8f: {  // jump rel16 if !SF and !ZF
-  int8_t offset = imm16();
+:(before "End Single-Byte Opcodes")
+case 0x7f: {  // jump rel8 if !SF and !ZF
+  int8_t offset = static_cast<int>(next());
   if (!ZF && SF == OF) {
     trace(2, "run") << "jump " << NUM(offset) << end();
     EIP += offset;
@@ -119,36 +113,36 @@ case 0x8f: {  // jump rel16 if !SF and !ZF
   break;
 }
 
-:(scenario jg_rel16_fail)
+:(scenario jg_rel8_fail)
 % ZF = false;
 % SF = true;
 % OF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 8f                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  7f                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
-+run: inst: 0x00000005
-+run: inst: 0x0000000a
++run: inst: 0x00000003
++run: inst: 0x00000008
 -run: jump 5
 
 //:: jump if greater or equal
 
-:(scenario jge_rel16_success)
+:(scenario jge_rel8_success)
 % SF = false;
 % OF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 8d                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  7d                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
 +run: jump 5
-+run: inst: 0x0000000a
--run: inst: 0x00000005
++run: inst: 0x00000008
+-run: inst: 0x00000003
 
-:(before "End Two-Byte Opcodes Starting With 0f")
-case 0x8d: {  // jump rel16 if !SF
-  int8_t offset = imm16();
+:(before "End Single-Byte Opcodes")
+case 0x7d: {  // jump rel8 if !SF
+  int8_t offset = static_cast<int>(next());
   if (SF == OF) {
     trace(2, "run") << "jump " << NUM(offset) << end();
     EIP += offset;
@@ -156,36 +150,36 @@ case 0x8d: {  // jump rel16 if !SF
   break;
 }
 
-:(scenario jge_rel16_fail)
+:(scenario jge_rel8_fail)
 % SF = true;
 % OF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 8d                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  7d                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
-+run: inst: 0x00000005
-+run: inst: 0x0000000a
++run: inst: 0x00000003
++run: inst: 0x00000008
 -run: jump 5
 
 //:: jump if lesser
 
-:(scenario jl_rel16_success)
+:(scenario jl_rel8_success)
 % ZF = false;
 % SF = true;
 % OF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 8c                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  7c                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
 +run: jump 5
-+run: inst: 0x0000000a
--run: inst: 0x00000005
++run: inst: 0x00000008
+-run: inst: 0x00000003
 
-:(before "End Two-Byte Opcodes Starting With 0f")
-case 0x8c: {  // jump rel16 if SF and !ZF
-  int8_t offset = imm16();
+:(before "End Single-Byte Opcodes")
+case 0x7c: {  // jump rel8 if SF and !ZF
+  int8_t offset = static_cast<int>(next());
   if (SF != OF) {
     trace(2, "run") << "jump " << NUM(offset) << end();
     EIP += offset;
@@ -193,50 +187,50 @@ case 0x8c: {  // jump rel16 if SF and !ZF
   break;
 }
 
-:(scenario jl_rel16_fail)
+:(scenario jl_rel8_fail)
 % ZF = false;
 % SF = false;
 % OF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 8c                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  7c                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
-+run: inst: 0x00000005
-+run: inst: 0x0000000a
++run: inst: 0x00000003
++run: inst: 0x00000008
 -run: jump 5
 
 //:: jump if lesser or equal
 
-:(scenario jle_rel16_equal)
+:(scenario jle_rel8_equal)
 % ZF = true;
 % SF = false;
 % OF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 8e                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  7e                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
 +run: jump 5
-+run: inst: 0x0000000a
--run: inst: 0x00000005
++run: inst: 0x00000008
+-run: inst: 0x00000003
 
-:(scenario jle_rel16_lesser)
+:(scenario jle_rel8_lesser)
 % ZF = false;
 % SF = true;
 % OF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 8e                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  7e                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
 +run: jump 5
-+run: inst: 0x0000000a
--run: inst: 0x00000005
++run: inst: 0x00000008
+-run: inst: 0x00000003
 
-:(before "End Two-Byte Opcodes Starting With 0f")
-case 0x8e: {  // jump rel16 if SF or ZF
-  int8_t offset = imm16();
+:(before "End Single-Byte Opcodes")
+case 0x7e: {  // jump rel8 if SF or ZF
+  int8_t offset = static_cast<int>(next());
   if (ZF || SF != OF) {
     trace(2, "run") << "jump " << NUM(offset) << end();
     EIP += offset;
@@ -244,15 +238,15 @@ case 0x8e: {  // jump rel16 if SF or ZF
   break;
 }
 
-:(scenario jle_rel16_greater)
+:(scenario jle_rel8_greater)
 % ZF = false;
 % SF = false;
 % OF = false;
-# op      ModRM   SIB   displacement  immediate
-  0f 8e                 05 00                     # skip 1 instruction
-  05                                  00 00 00 01
-  05                                  00 00 00 02
+# op  ModRM   SIB   displacement  immediate
+  7e                05                        # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
 +run: inst: 0x00000001
-+run: inst: 0x00000005
-+run: inst: 0x0000000a
++run: inst: 0x00000003
++run: inst: 0x00000008
 -run: jump 5
diff --git a/subx/016jump_relative.cc b/subx/016jump_relative.cc
new file mode 100644
index 00000000..c4d92030
--- /dev/null
+++ b/subx/016jump_relative.cc
@@ -0,0 +1,258 @@
+//: jump to 16-bit offset
+
+//:: jump
+
+:(scenario jump_rel16)
+# op  ModRM   SIB   displacement  immediate
+  e9                05 00                     # skip 1 instruction
+  05                              00 00 00 01
+  05                              00 00 00 02
++run: inst: 0x00000001
++run: jump 5
++run: inst: 0x00000009
+-run: inst: 0x00000003
+
+:(before "End Single-Byte Opcodes")
+case 0xe9: {  // jump rel8
+  int16_t offset = imm16();
+  trace(2, "run") << "jump " << offset << end();
+  EIP += offset;
+  break;
+}
+:(code)
+int16_t imm16() {
+  int16_t result = next();
+  result |= (next()<<8);
+  return result;
+}
+
+//:: jump if equal/zero
+
+:(scenario je_rel16_success)
+% ZF = true;
+# op      ModRM   SIB   displacement  immediate
+  0f 84                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: jump 5
++run: inst: 0x0000000a
+-run: inst: 0x00000005
+
+:(before "End Two-Byte Opcodes Starting With 0f")
+case 0x84: {  // jump rel16 if ZF
+  int8_t offset = imm16();
+  if (ZF) {
+    trace(2, "run") << "jump " << NUM(offset) << end();
+    EIP += offset;
+  }
+  break;
+}
+
+:(scenario je_rel16_fail)
+% ZF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 84                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: inst: 0x00000005
++run: inst: 0x0000000a
+-run: jump 5
+
+//:: jump if not equal/not zero
+
+:(scenario jne_rel16_success)
+% ZF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 85                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: jump 5
++run: inst: 0x0000000a
+-run: inst: 0x00000005
+
+:(before "End Two-Byte Opcodes Starting With 0f")
+case 0x85: {  // jump rel16 unless ZF
+  int8_t offset = imm16();
+  if (!ZF) {
+    trace(2, "run") << "jump " << NUM(offset) << end();
+    EIP += offset;
+  }
+  break;
+}
+
+:(scenario jne_rel16_fail)
+% ZF = true;
+# op      ModRM   SIB   displacement  immediate
+  0f 85                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: inst: 0x00000005
++run: inst: 0x0000000a
+-run: jump 5
+
+//:: jump if greater
+
+:(scenario jg_rel16_success)
+% ZF = false;
+% SF = false;
+% OF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 8f                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: jump 5
++run: inst: 0x0000000a
+-run: inst: 0x00000005
+
+:(before "End Two-Byte Opcodes Starting With 0f")
+case 0x8f: {  // jump rel16 if !SF and !ZF
+  int8_t offset = imm16();
+  if (!ZF && SF == OF) {
+    trace(2, "run") << "jump " << NUM(offset) << end();
+    EIP += offset;
+  }
+  break;
+}
+
+:(scenario jg_rel16_fail)
+% ZF = false;
+% SF = true;
+% OF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 8f                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: inst: 0x00000005
++run: inst: 0x0000000a
+-run: jump 5
+
+//:: jump if greater or equal
+
+:(scenario jge_rel16_success)
+% SF = false;
+% OF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 8d                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: jump 5
++run: inst: 0x0000000a
+-run: inst: 0x00000005
+
+:(before "End Two-Byte Opcodes Starting With 0f")
+case 0x8d: {  // jump rel16 if !SF
+  int8_t offset = imm16();
+  if (SF == OF) {
+    trace(2, "run") << "jump " << NUM(offset) << end();
+    EIP += offset;
+  }
+  break;
+}
+
+:(scenario jge_rel16_fail)
+% SF = true;
+% OF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 8d                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: inst: 0x00000005
++run: inst: 0x0000000a
+-run: jump 5
+
+//:: jump if lesser
+
+:(scenario jl_rel16_success)
+% ZF = false;
+% SF = true;
+% OF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 8c                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: jump 5
++run: inst: 0x0000000a
+-run: inst: 0x00000005
+
+:(before "End Two-Byte Opcodes Starting With 0f")
+case 0x8c: {  // jump rel16 if SF and !ZF
+  int8_t offset = imm16();
+  if (SF != OF) {
+    trace(2, "run") << "jump " << NUM(offset) << end();
+    EIP += offset;
+  }
+  break;
+}
+
+:(scenario jl_rel16_fail)
+% ZF = false;
+% SF = false;
+% OF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 8c                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: inst: 0x00000005
++run: inst: 0x0000000a
+-run: jump 5
+
+//:: jump if lesser or equal
+
+:(scenario jle_rel16_equal)
+% ZF = true;
+% SF = false;
+% OF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 8e                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: jump 5
++run: inst: 0x0000000a
+-run: inst: 0x00000005
+
+:(scenario jle_rel16_lesser)
+% ZF = false;
+% SF = true;
+% OF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 8e                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: jump 5
++run: inst: 0x0000000a
+-run: inst: 0x00000005
+
+:(before "End Two-Byte Opcodes Starting With 0f")
+case 0x8e: {  // jump rel16 if SF or ZF
+  int8_t offset = imm16();
+  if (ZF || SF != OF) {
+    trace(2, "run") << "jump " << NUM(offset) << end();
+    EIP += offset;
+  }
+  break;
+}
+
+:(scenario jle_rel16_greater)
+% ZF = false;
+% SF = false;
+% OF = false;
+# op      ModRM   SIB   displacement  immediate
+  0f 8e                 05 00                     # skip 1 instruction
+  05                                  00 00 00 01
+  05                                  00 00 00 02
++run: inst: 0x00000001
++run: inst: 0x00000005
++run: inst: 0x0000000a
+-run: jump 5
diff --git a/subx/016functions.cc b/subx/017functions.cc
index 7837f080..7837f080 100644
--- a/subx/016functions.cc
+++ b/subx/017functions.cc
='n1531' href='#n1531'>1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847