add a #define to id_regs.py which indicates name of the instruction
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 30 Sep 2018 12:33:07 +0000 (13:33 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 30 Sep 2018 12:33:07 +0000 (13:33 +0100)
the c preprocessor cannot cope with detecting what the name of the
instruction is (and when it does, if it is "and" that throws a
compile-error), so as a workaround have id_regs.py create a
#define INSN_ADD, #define INSN_ADD_I etc.

id_regs.py

index b705ec7210e6c71969ef79eeb1331666c8162de3..0d732b355cae9124e993763061bf827086d85a06 100644 (file)
@@ -105,4 +105,6 @@ if __name__ == '__main__':
         regsname = "regs_%s.h" % insn
         regsname = os.path.join(insns_dir, regsname)
         with open(regsname, "w") as f:
-            f.write(find_registers(fname))
+            txt = find_registers(fname)
+            txt += "\n#define INSN_%s\n" % insn.upper()
+            f.write(txt)