From bd56a93df44a213da9d82d6d2a775c8931874765 Mon Sep 17 00:00:00 2001
From: Recolic Keghart <root@recolic.net>
Date: Fri, 27 Dec 2019 15:50:51 +0800
Subject: [PATCH] move dhelper/ehelpers to namespace

---
 nemu/include/cpu/decode.h     |  81 +++++++-------
 nemu/include/cpu/exec.h       |   3 +-
 nemu/src/cpu/exec/all-instr.h |   6 ++
 nemu/src/cpu/exec/arith.cc    |   3 +
 nemu/src/cpu/exec/exec.cc     | 195 +++-------------------------------
 nemu/src/cpu/exec/logic.cc    |   5 +
 nemu/src/cpu/exec/prefix.cc   |  14 +--
 7 files changed, 78 insertions(+), 229 deletions(-)

diff --git a/nemu/include/cpu/decode.h b/nemu/include/cpu/decode.h
index df6a347..720c93f 100644
--- a/nemu/include/cpu/decode.h
+++ b/nemu/include/cpu/decode.h
@@ -75,47 +75,48 @@ extern DecodeInfo decoding;
 #define id_src2 (&decoding.src2)
 #define id_dest (&decoding.dest)
 
-#define make_DHelper_funcname(name) concat(decode_, name)
-#define make_DHelper(name) void make_DHelper_funcname(name) (vaddr_t *eip)
+#define make_DHelper(name) void name (vaddr_t *eip)
 typedef void (*DHelper) (vaddr_t *);
 
-make_DHelper(I2E);
-make_DHelper(I2a);
-make_DHelper(I2r);
-make_DHelper(SI2E);
-make_DHelper(SI_E2G);
-make_DHelper(I_E2G);
-make_DHelper(I_G2E);
-make_DHelper(I);
-make_DHelper(r);
-make_DHelper(E);
-make_DHelper(setcc_E);
-make_DHelper(gp7_E);
-make_DHelper(test_I);
-make_DHelper(SI);
-make_DHelper(G2E);
-make_DHelper(E2G);
-
-make_DHelper(mov_I2r);
-make_DHelper(mov_I2E);
-make_DHelper(mov_G2E);
-make_DHelper(mov_E2G);
-make_DHelper(lea_M2G);
-
-make_DHelper(gp2_1_E);
-make_DHelper(gp2_cl2E);
-make_DHelper(gp2_Ib2E);
-
-make_DHelper(O2a);
-make_DHelper(a2O);
-
-make_DHelper(J);
-
-make_DHelper(push_SI);
-
-make_DHelper(in_I2a);
-make_DHelper(in_dx2a);
-make_DHelper(out_a2I);
-make_DHelper(out_a2dx);
+namespace DHelperImpl {
+  make_DHelper(I2E);
+  make_DHelper(I2a);
+  make_DHelper(I2r);
+  make_DHelper(SI2E);
+  make_DHelper(SI_E2G);
+  make_DHelper(I_E2G);
+  make_DHelper(I_G2E);
+  make_DHelper(I);
+  make_DHelper(r);
+  make_DHelper(E);
+  make_DHelper(setcc_E);
+  make_DHelper(gp7_E);
+  make_DHelper(test_I);
+  make_DHelper(SI);
+  make_DHelper(G2E);
+  make_DHelper(E2G);
+
+  make_DHelper(mov_I2r);
+  make_DHelper(mov_I2E);
+  make_DHelper(mov_G2E);
+  make_DHelper(mov_E2G);
+  make_DHelper(lea_M2G);
+
+  make_DHelper(gp2_1_E);
+  make_DHelper(gp2_cl2E);
+  make_DHelper(gp2_Ib2E);
+
+  make_DHelper(O2a);
+  make_DHelper(a2O);
+
+  make_DHelper(J);
+
+  make_DHelper(push_SI);
+
+  make_DHelper(in_I2a);
+  make_DHelper(in_dx2a);
+  make_DHelper(out_a2I);
+  make_DHelper(out_a2dx);
+}
 
 #endif
diff --git a/nemu/include/cpu/exec.h b/nemu/include/cpu/exec.h
index a11fff1..363039e 100644
--- a/nemu/include/cpu/exec.h
+++ b/nemu/include/cpu/exec.h
@@ -3,8 +3,7 @@
 
 #include "nemu.h"
 
-#define make_EHelper_funcname(name) concat(exec_, name)
-#define make_EHelper(name) void make_EHelper_funcname(name) (vaddr_t *eip)
+#define make_EHelper(name) void name (vaddr_t *eip)
 typedef void (*EHelper) (vaddr_t *);
 
 #include "cpu/decode.h"
diff --git a/nemu/src/cpu/exec/all-instr.h b/nemu/src/cpu/exec/all-instr.h
index 617030f..31cb2fa 100644
--- a/nemu/src/cpu/exec/all-instr.h
+++ b/nemu/src/cpu/exec/all-instr.h
@@ -1,5 +1,9 @@
 #include "cpu/exec.h"
 
+namespace EHelperImpl {
+
+make_EHelper(_2byte_esc);
+
 make_EHelper(mov);
 make_EHelper(push);
 make_EHelper(pop);
@@ -54,3 +58,5 @@ make_EHelper(operand_size);
 
 make_EHelper(inv);
 make_EHelper(nemu_trap);
+
+}
\ No newline at end of file
diff --git a/nemu/src/cpu/exec/arith.cc b/nemu/src/cpu/exec/arith.cc
index 3ecaa30..409c19f 100644
--- a/nemu/src/cpu/exec/arith.cc
+++ b/nemu/src/cpu/exec/arith.cc
@@ -2,6 +2,7 @@
 
 #include <util/util.h>
 
+namespace EHelperImpl {
 make_EHelper(add) {
 	rtl_sext(&t1, &id_dest->val, id_dest->width);
 	rtl_sext(&t2, &id_src->val, id_src->width);
@@ -261,3 +262,5 @@ make_EHelper(idiv) {
 
   print_asm_template1(idiv);
 }
+
+} // end namespace
\ No newline at end of file
diff --git a/nemu/src/cpu/exec/exec.cc b/nemu/src/cpu/exec/exec.cc
index a211be9..6698332 100644
--- a/nemu/src/cpu/exec/exec.cc
+++ b/nemu/src/cpu/exec/exec.cc
@@ -7,9 +7,9 @@ typedef struct {
   int width; // ByteWidth. If width is 0, using its default value: OperandSize (2Byte or 4Byte)
 } opcode_entry;
 
-#define IDEXW(id, ex, w)   {make_DHelper_funcname(id), make_EHelper_funcname(ex), w}
+#define IDEXW(id, ex, w)   {DHelperImpl::id, EHelperImpl::ex, w}
 #define IDEX(id, ex)       IDEXW(id, ex, 0)
-#define EXW(ex, w)         {NULL, make_EHelper_funcname(ex), w}
+#define EXW(ex, w)         {NULL, EHelperImpl::ex, w}
 #define EX(ex)             EXW(ex, 0)
 #define EMPTY              EX(inv)
 
@@ -28,16 +28,15 @@ static inline void idex(vaddr_t *eip, opcode_entry *e) {
   e->execute(eip);
 }
 
-static make_EHelper(2byte_esc);
 
 #define make_group(name, item0, item1, item2, item3, item4, item5, item6, item7) \
   static opcode_entry concat(opcode_table_, name) [8] = { \
     /* 0x00 */	item0, item1, item2, item3, \
     /* 0x04 */	item4, item5, item6, item7  \
   }; \
-static make_EHelper(name) { \
+namespace EHelperImpl {static name { \
   idex(eip, &concat(opcode_table_, name)[decoding.ext_opcode]); \
-}
+}}
 
 /* 0x80, 0x81, 0x83 */
 make_group(gp1,
@@ -73,7 +72,7 @@ opcode_entry opcode_table [512] = {
   /* 0x00 */	IDEXW(G2E,add,1),IDEX(G2E,add), IDEXW(E2G,add,1), IDEX(E2G,add),
   /* 0x04 */	IDEXW(I2a,add,1), IDEX(I2a,add), EMPTY, EMPTY,
   /* 0x08 */  IDEXW(G2E,or,1), IDEX(G2E,or), IDEXW(E2G,or,1), IDEX(E2G,or),
-  /* 0x0c */	IDEXW(I2a,or,1), IDEX(I2a,or), EMPTY, EX(2byte_esc),
+  /* 0x0c */	IDEXW(I2a,or,1), IDEX(I2a,or), EMPTY, EX(_2byte_esc),
   /* 0x10 */	IDEXW(G2E,adc,1), IDEX(G2E,adc), IDEXW(E2G,adc,1), IDEX(E2G,adc),
   /* 0x14 */	IDEXW(I2a,adc,1), IDEX(I2a,adc), EMPTY, EMPTY,
   /* 0x18 */	IDEXW(G2E,sbb,1), IDEX(G2E,sbb), IDEXW(E2G,sbb,1), IDEX(E2G,sbb),
@@ -203,186 +202,20 @@ opcode_entry opcode_table [512] = {
   /* 0xfc */	EMPTY, EMPTY, EMPTY, EMPTY
 };
 
-///* 
-///* 0x80, 0x81, 0x83 */
-//make_group(gp1,
-//    EMPTY, EMPTY, EMPTY, EMPTY,
-//    EMPTY, EMPTY, EMPTY, EMPTY)
-//
-//  /* 0xc0, 0xc1, 0xd0, 0xd1, 0xd2, 0xd3 */
-//make_group(gp2,
-//    EMPTY, EMPTY, EMPTY, EMPTY,
-//    EMPTY, EMPTY, EMPTY, EMPTY)
-//
-//  /* 0xf6, 0xf7 */
-//make_group(gp3,
-//    EMPTY, EMPTY, EMPTY, EMPTY,
-//    EMPTY, EMPTY, EMPTY, EMPTY)
-//
-//  /* 0xfe */
-//make_group(gp4,
-//    EMPTY, EMPTY, EMPTY, EMPTY,
-//    EMPTY, EMPTY, EMPTY, EMPTY)
-//
-//  /* 0xff */
-//make_group(gp5,
-//    EMPTY, EMPTY, EMPTY, EMPTY,
-//    EMPTY, EMPTY, EMPTY, EMPTY)
-//
-//  /* 0x0f 0x01*/
-//make_group(gp7,
-//    EMPTY, EMPTY, EMPTY, EMPTY,
-//    EMPTY, EMPTY, EMPTY, EMPTY)
-//
-///* TODO: Add more instructions!!! */
-//
-//opcode_entry opcode_table [512] = {
-//  /* 0x00 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x04 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x08 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x0c */	EMPTY, EMPTY, EMPTY, EX(2byte_esc),
-//  /* 0x10 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x14 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x18 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x1c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x20 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x24 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x28 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x2c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x30 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x34 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x38 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x3c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x40 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x44 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x48 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x4c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x50 */  IDEX(r, push), IDEX(r, push), IDEX(r, push), IDEX(r, push),
-//  /* 0x54 */	IDEX(r, push), IDEX(r, push), IDEX(r, push), IDEX(r, push),
-//  /* 0x58 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x5c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x60 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x64 */	EMPTY, EMPTY, EX(operand_size), EMPTY,
-//  /* 0x68 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x6c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x70 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x74 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x78 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x7c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x80 */	IDEXW(I2E, gp1, 1), IDEX(I2E, gp1), EMPTY, IDEX(SI2E, gp1),
-//  /* 0x84 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x88 */	IDEXW(mov_G2E, mov, 1), IDEX(mov_G2E, mov), IDEXW(mov_E2G, mov, 1), IDEX(mov_E2G, mov),
-//  /* 0x8c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x90 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x94 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x98 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x9c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xa0 */	IDEXW(O2a, mov, 1), IDEX(O2a, mov), IDEXW(a2O, mov, 1), IDEX(a2O, mov),
-//  /* 0xa4 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xa8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xac */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xb0 */	IDEXW(mov_I2r, mov, 1), IDEXW(mov_I2r, mov, 1), IDEXW(mov_I2r, mov, 1), IDEXW(mov_I2r, mov, 1),
-//  /* 0xb4 */	IDEXW(mov_I2r, mov, 1), IDEXW(mov_I2r, mov, 1), IDEXW(mov_I2r, mov, 1), IDEXW(mov_I2r, mov, 1),
-//  /* 0xb8 */	IDEX(mov_I2r, mov), IDEX(mov_I2r, mov), IDEX(mov_I2r, mov), IDEX(mov_I2r, mov),
-//  /* 0xbc */	IDEX(mov_I2r, mov), IDEX(mov_I2r, mov), IDEX(mov_I2r, mov), IDEX(mov_I2r, mov),
-//  /* 0xc0 */	IDEXW(gp2_Ib2E, gp2, 1), IDEX(gp2_Ib2E, gp2), IDEX(I, ret), EX(ret),
-//  /* 0xc4 */	EMPTY, EMPTY, IDEXW(mov_I2E, mov, 1), IDEX(mov_I2E, mov),
-//  /* 0xc8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xcc */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xd0 */	IDEXW(gp2_1_E, gp2, 1), IDEX(gp2_1_E, gp2), IDEXW(gp2_cl2E, gp2, 1), IDEX(gp2_cl2E, gp2),
-//  /* 0xd4 */	EMPTY, EMPTY, EX(nemu_trap), EMPTY,
-//  /* 0xd8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xdc */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xe0 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xe4 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xe8 */  IDEX(J, call), EMPTY, EMPTY, EMPTY,
-//  /* 0xec */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xf0 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xf4 */	EMPTY, EMPTY, IDEXW(E, gp3, 1), IDEX(E, gp3),
-//  /* 0xf8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xfc */	EMPTY, EMPTY, IDEXW(E, gp4, 1), IDEX(E, gp5),
-//
-//  /*2 byte_opcode_table */
-//
-//  /* 0x00 */	EMPTY, IDEX(gp7_E, gp7), EMPTY, EMPTY,
-//  /* 0x04 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x08 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x0c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x10 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x14 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x18 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x1c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x20 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x24 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x28 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x2c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x30 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x34 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x38 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x3c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x40 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x44 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x48 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x4c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x50 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x54 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x58 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x5c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x60 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x64 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x68 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x6c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x70 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x74 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x78 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x7c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x80 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x84 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x88 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x8c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x90 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x94 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x98 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0x9c */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xa0 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xa4 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xa8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xac */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xb0 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xb4 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xb8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xbc */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xc0 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xc4 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xc8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xcc */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xd0 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xd4 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xd8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xdc */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xe0 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xe4 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xe8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xec */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xf0 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xf4 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xf8 */	EMPTY, EMPTY, EMPTY, EMPTY,
-//  /* 0xfc */	EMPTY, EMPTY, EMPTY, EMPTY
-//};
-
-
-static make_EHelper(2byte_esc) {
+static make_EHelper(_2byte_esc) {
   uint32_t opcode = instr_fetch(eip, 1) | 0x100;
   decoding.opcode = opcode;
   set_width(opcode_table[opcode].width);
   idex(eip, &opcode_table[opcode]);
 }
 
-make_EHelper(real) {
-  uint32_t opcode = instr_fetch(eip, 1);
-  decoding.opcode = opcode;
-  set_width(opcode_table[opcode].width);
-  idex(eip, &opcode_table[opcode]);
+namespace EHelperImpl {
+  make_EHelper(real) {
+    uint32_t opcode = instr_fetch(eip, 1);
+    decoding.opcode = opcode;
+    set_width(opcode_table[opcode].width);
+    idex(eip, &opcode_table[opcode]);
+  }
 }
 
 static inline void update_eip(void) {
@@ -399,7 +232,7 @@ void exec_wrapper(bool print_flag) {
 #endif
 
   decoding.seq_eip = ori_eip;
-  make_EHelper_funcname(real)(&decoding.seq_eip);
+  EHelperImpl::real(&decoding.seq_eip);
 
 #ifdef DEBUG
   int instr_len = decoding.seq_eip - ori_eip;
diff --git a/nemu/src/cpu/exec/logic.cc b/nemu/src/cpu/exec/logic.cc
index 70add1b..6f0d429 100644
--- a/nemu/src/cpu/exec/logic.cc
+++ b/nemu/src/cpu/exec/logic.cc
@@ -9,6 +9,9 @@ void sign_extend_if_required(const Operand &dest, Operand &src) {
   }
 }
 
+namespace EHelperImpl {
+  using vaddr_t = uint32_t;
+
 make_EHelper(test) {
   // `and` without write_back.
   sign_extend_if_required(*id_dest, *id_src);
@@ -93,3 +96,5 @@ make_EHelper(rol) {
 
   print_asm_template1(rol);
 }
+
+} // end namespace ehelperimpl
\ No newline at end of file
diff --git a/nemu/src/cpu/exec/prefix.cc b/nemu/src/cpu/exec/prefix.cc
index 4e8898b..a1be99d 100644
--- a/nemu/src/cpu/exec/prefix.cc
+++ b/nemu/src/cpu/exec/prefix.cc
@@ -1,9 +1,11 @@
 #include "cpu/exec.h"
 
-make_EHelper(real);
+namespace EHelperImpl {
+  make_EHelper(real);
 
-make_EHelper(operand_size) {
-  decoding.is_operand_size_16 = true;
-  make_EHelper_funcname(real)(eip);
-  decoding.is_operand_size_16 = false;
-}
+  make_EHelper(operand_size) {
+    decoding.is_operand_size_16 = true;
+    EHelperImpl::real(eip);
+    decoding.is_operand_size_16 = false;
+  }
+}
\ No newline at end of file
-- 
GitLab