open OPCODELST, "opcodes.lst" or die "Error opening <opcodes.lst> : $!\n";
open DISASM_H, ">disasm.h" or die "Error creating <disasm.h> : $!\n";
+# Write GPL license
+# Argument 0 is file descriptor
+sub write_header
+{
+ my $fd = $_[0];
+
+ print $fd " *\n";
+ print $fd " * Do not modify this file directly, as it was created by opcode2c.pl\n";
+ print $fd " * Any modifications made directly to this file will be lost.\n";
+ print $fd " *\n";
+ print $fd " * Copyright (C) 1999 Jonathan St-André\n";
+ print $fd " * Copyright (C) 1999 Hugo Villeneuve <hugo@hugovil.com>\n";
+ print $fd " *\n";
+ print $fd " * This program is free software; you can redistribute it and/or modify\n";
+ print $fd " * it under the terms of the GNU General Public License as published by\n";
+ print $fd " * the Free Software Foundation; either version 2 of the License, or\n";
+ print $fd " * (at your option) any later version.\n";
+ print $fd " *\n";
+ print $fd " * This program is distributed in the hope that it will be useful,\n";
+ print $fd " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
+ print $fd " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n";
+ print $fd " * GNU General Public License for more details.\n";
+ print $fd " *\n";
+ print $fd " * You should have received a copy of the GNU General Public License\n";
+ print $fd " * along with this program; if not, write to the Free Software\n";
+ print $fd " * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.\n";
+ print $fd " */\n\n";
+}
+
# Header for instructions_8051.c
print INST_IMP "/*\n";
print INST_IMP " * instructions_8051.c\n";
-print INST_IMP " *\n";
-print INST_IMP " * Do not modify this file directly, as it was created by opcode2c.pl\n";
-print INST_IMP " * Any modifications made directly to this file will be lost.\n";
-print INST_IMP " *\n";
-print INST_IMP " * Copyright (C) 1999 Jonathan St-André\n";
-print INST_IMP " * Copyright (C) 1999 Hugo Villeneuve <hugo@hugovil.com>\n";
-print INST_IMP " *\n";
-print INST_IMP " * This program is free software; you can redistribute it and/or modify\n";
-print INST_IMP " * it under the terms of the GNU General Public License as published by\n";
-print INST_IMP " * the Free Software Foundation; either version 2 of the License, or\n";
-print INST_IMP " * (at your option) any later version.\n";
-print INST_IMP " *\n";
-print INST_IMP " * This program is distributed in the hope that it will be useful,\n";
-print INST_IMP " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
-print INST_IMP " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n";
-print INST_IMP " * GNU General Public License for more details.\n";
-print INST_IMP " *\n";
-print INST_IMP " * You should have received a copy of the GNU General Public License\n";
-print INST_IMP " * along with this program; if not, write to the Free Software\n";
-print INST_IMP " * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.\n";
-print INST_IMP "*/\n\n";
+write_header(INST_IMP);
print INST_IMP "/* Define only here, for not having extern scope on local variables. */\n";
print INST_IMP "#define INSTRUCTIONS_8051_M 1\n\n\n";
print INST_IMP "#include \"reg8051.h\"\n";
# Header for disasm.h
print DISASM_H "/*\n";
print DISASM_H " * disasm.h\n";
-print DISASM_H " *\n";
-print DISASM_H " * Do not modify this file directly, as it was created by opcode2c.pl\n";
-print DISASM_H " * Any modifications made directly to this file will be lost.\n";
-print DISASM_H " *\n";
-print DISASM_H " * Copyright (C) 1999 Jonathan St-André\n";
-print DISASM_H " * Copyright (C) 1999 Hugo Villeneuve <hugo@hugovil.com>\n";
-print DISASM_H " *\n";
-print DISASM_H " * This program is free software; you can redistribute it and/or modify\n";
-print DISASM_H " * it under the terms of the GNU General Public License as published by\n";
-print DISASM_H " * the Free Software Foundation; either version 2 of the License, or\n";
-print DISASM_H " * (at your option) any later version.\n";
-print DISASM_H " *\n";
-print DISASM_H " * This program is distributed in the hope that it will be useful,\n";
-print DISASM_H " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
-print DISASM_H " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n";
-print DISASM_H " * GNU General Public License for more details.\n";
-print DISASM_H " *\n";
-print DISASM_H " * You should have received a copy of the GNU General Public License\n";
-print DISASM_H " * along with this program; if not, write to the Free Software\n";
-print DISASM_H " * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.\n";
-print DISASM_H "*/\n\n";
+write_header(DISASM_H);
print DISASM_H "#ifndef DISASM_H\n";
print DISASM_H "#define DISASM_H 1\n\n";
# Header for instructions_8051.h
print INST_DEF "/*\n";
print INST_DEF " * instructions_8051.h\n";
-print INST_DEF " *\n";
-print INST_DEF " * Do not modify this file directly, as it was created by opcode2c.pl\n";
-print INST_DEF " * Any modifications made directly to this file will be lost.\n";
-print INST_DEF " *\n";
-print INST_DEF " * Copyright (C) 1999 Jonathan St-André\n";
-print INST_DEF " * Copyright (C) 1999 Hugo Villeneuve <hugo@hugovil.com>\n";
-print INST_DEF " *\n";
-print INST_DEF " * This program is free software; you can redistribute it and/or modify\n";
-print INST_DEF " * it under the terms of the GNU General Public License as published by\n";
-print INST_DEF " * the Free Software Foundation; either version 2 of the License, or\n";
-print INST_DEF " * (at your option) any later version.\n";
-print INST_DEF " *\n";
-print INST_DEF " * This program is distributed in the hope that it will be useful,\n";
-print INST_DEF " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
-print INST_DEF " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n";
-print INST_DEF " * GNU General Public License for more details.\n";
-print INST_DEF " *\n";
-print INST_DEF " * You should have received a copy of the GNU General Public License\n";
-print INST_DEF " * along with this program; if not, write to the Free Software\n";
-print INST_DEF " * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.\n";
-print INST_DEF "*/\n\n";
-
+write_header(INST_DEF);
print INST_DEF "#ifndef INSTRUCTIONS_8051_H\n";
print INST_DEF "#define INSTRUCTIONS_8051_H 1\n\n\n";
print INST_DEF "#define BANKPSW (cpu8051_ReadD(_PSW_) & 0x18)\n\n";