--- nono/m88xx0/gentable.php 2026/04/29 17:04:31 1.1 +++ nono/m88xx0/gentable.php 2026/04/29 17:05:47 1.1.1.4 @@ -1,7 +1,8 @@ &$inst0, // 1 => &$inst1, // : -// 命令の存在するところだけ埋められます。 +// 命令の存在するところだけ埋められる。 // ) function makeop12($insttable) { @@ -188,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) { @@ -240,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); } @@ -333,6 +312,7 @@ function output_header() // ファイルに出力 write_file("ops.h.new", $out); } + // ファイル出力 function write_file($filename, $str) { @@ -342,3 +322,4 @@ function write_file($filename, $str) print "Output: {$filename}\n"; } +?>