--- nono/m88xx0/gentable.php 2026/04/29 17:05:15 1.1.1.3 +++ nono/m88xx0/gentable.php 2026/04/29 17:05:47 1.1.1.4 @@ -13,7 +13,7 @@ $insttable = expand($insttable); makeop12($insttable); makeop12hash(); - output_goto(); + output_cpp(); output_switch(); output_header(); exit(0); @@ -189,32 +189,16 @@ function makeop12hash() } } -// ディスパッチャ用の computed-goto 本体とソースの元を出力 -function output_goto() +// ソースの雛形を出力 +function output_cpp() { global $insttable; global $op12table; global $op12hash; - $out = ""; $cpp = ""; - // ジャンプテーブルを作成 - $out = "\t\tstatic const void *jumptable[] = {\n"; - for ($i = 0; $i < 4096; $i++) { - $bits12 = str_repeat("0", 11) . decbin($i); - $bits12 = preg_replace("/.*(......)(......)/", "$1_$2", $bits12); - $name = isset($op12table[$i]) ? $op12table[$i]["name"] : "illegal"; - $out .= sprintf("\t\t\t/* %%%s */ &&label_goto_%s,\n", - $bits12, $name); - } - $out .= "\t\t};\n"; - $out .= "\t\tJUMP;\n"; foreach ($op12hash as $name) { - $out .= "\t label_goto_{$name}:\n"; - $out .= "\t\tOP_FUNC({$name});\n"; - $out .= "\t\tCHECK_AND_JUMP;\n"; - // name から $inst を引く。うーん。 $inst = array(); foreach ($insttable as $i) { @@ -241,13 +225,7 @@ OP_DEF({$name}) __EOM__; } - // 不当命令ブロックを出力 - $out .= "\t label_goto_illegal:\n"; - $out .= "\t\tOP_FUNC(illegal);\n"; - $out .= "\t\tCHECK_AND_JUMP;\n"; - // ファイルに出力 - write_file("goto.inc.new", $out); write_file("ops.cpp.new", $cpp); }