X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fcommon%2Fopcode2c.pl;h=d79dc6d0bf07af6e5495cd0d0286cc3efeb5104d;hb=5419d1bd9d2faae98c78da740634b972e8f5aac1;hp=8b90af8737c4ba52826c6bf28c4ac2677fc5d0a0;hpb=1590b0711fd7136cf7dc87f571557647c00ae189;p=emu8051.git diff --git a/src/common/opcode2c.pl b/src/common/opcode2c.pl index 8b90af8..d79dc6d 100755 --- a/src/common/opcode2c.pl +++ b/src/common/opcode2c.pl @@ -3,19 +3,7 @@ # Copyright (C) 1999 Jonathan St-André # Copyright (C) 1999 Hugo Villeneuve # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +# This file is released under the GPLv2 open INST_DEF, ">instructions_8051.h" or die "Error creating : $!\n"; open INST_IMP, ">instructions_8051.c" or die "Error creating : $!\n"; @@ -35,19 +23,7 @@ sub write_header print $fd " * Copyright (C) 1999 Jonathan St-André\n"; print $fd " * Copyright (C) 1999 Hugo Villeneuve \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 " * This file is released under the GPLv2\n"; print $fd " */\n\n"; } @@ -68,6 +44,7 @@ print INST_IMP "#include \"reg8051.h\"\n"; print INST_IMP "#include \"cpu8051.h\"\n"; print INST_IMP "#include \"memory.h\"\n"; print INST_IMP "#include \"psw.h\"\n"; +print INST_IMP "#include \"operations.h\"\n"; print INST_IMP "#include \"instructions_8051.h\"\n\n\n"; # Header for disasm.h @@ -444,25 +421,7 @@ for ($i=0 ; $i< 256; $i++) { # ADD if ($insttype[$i] == 13) { - cfw("psw_clr_cy();"); - cfw("psw_clr_ac();"); - cfw("psw_clr_ov();"); - # The Overflow (OV) bit is set if there is a carry-out of bit 6 or - # out of bit 7, but not both. In other words, if the addition of the - # Accumulator, operand and (in the case of ADDC) the Carry flag - # treated as signed values results in a value that is out of the - # range of a signed byte (-128 through +127) the Overflow flag is - # set. Otherwise, the Overflow flag is cleared. - cfw("if ( destination + source > 0xFF ) {"); - # Carry from bit 7 - cfw(" psw_set_cy();"); - # If no carry from bit 6, set OV - cfw(" if (((destination & 0x7F) + (source & 0x7F)) < 0x80)"); - cfw(" psw_set_ov();"); - # If no carry from bit 7, but caary from bit 6, set OV - cfw("} else if (((destination & 0x7F) + (source & 0x7F)) > 0x7F ) psw_set_ov();"); - cfw("if (((destination & 0x0F) + (source & 0x0F)) > 0x0F) psw_set_ac();"); - cfw("destination += source;"); + cfw("destination = addition(destination, source, 0);"); } # JNB @@ -484,18 +443,12 @@ for ($i=0 ; $i< 256; $i++) { } # ADDC + # ADD and ADDC function identically except that ADDC adds the value of + # operand as well as the value of the Carry flag whereas ADD does not + # add the Carry flag to the result. if ($insttype[$i] == 17) { cfw("unsigned char carryflag = psw_read_cy();"); - cfw("psw_clr_cy();"); - cfw("psw_clr_ac();"); - cfw("psw_clr_ov();"); - cfw("if ( destination + source + carryflag > 0xFF ) {"); - cfw(" psw_set_cy();"); - cfw(" if (((destination & 0x7F) + (source & 0x7F) + carryflag) < 0x80)"); - cfw(" psw_set_ov();"); - cfw("} else if (((destination & 0x7F) + (source & 0x7F) + carryflag) > 0x7F) psw_set_ov();"); - cfw("if (((destination & 0x0F) + (source & 0x0F) + carryflag) > 0x0F) psw_set_ac();"); - cfw("destination += source;"); + cfw("destination = addition(destination, source, carryflag);"); } # JC