Fix compiler warning about unused variable set by getch()
[emu8051.git] / src / opcode2c.pl
index 9fcca45..a80f651 100755 (executable)
@@ -116,7 +116,7 @@ while($ligne=<OPCODELST>) {
            $instargs[($instnumb << 2) + $i + 1]=$argstypes{$argslist[$i]};
        }
     }
-       
+
     if (not exists $insttext{$wordlist[2]}) {
        $insttext[$nbinst]=$wordlist[2];
        $insttext{$wordlist[2]}=$nbinst++;
@@ -215,8 +215,6 @@ for ($i=0 ; $i< 256; $i++) {
     print INST_IMP " ","*"x76,"/\n";
     print INST_IMP "int\n";
     print INST_IMP "cpu8051_OP_$a_opcodehex[$i](void)\n";
-# TEST hugo new...
-#    print INST_DEF "int OP_$a_opcodehex[$i]( );\n";
     print INST_IMP "{\n";
 
     if( $i == 0x85 ) {
@@ -251,7 +249,7 @@ for ($i=0 ; $i< 256; $i++) {
            if ($op_destination == 5) { # @R1
                print INST_IMP "unsigned char destination = cpu8051_ReadI ( cpu8051_ReadD( BANKPSW + _R1_ ) );\n";
            }
-           
+
            if ($op_destination == 6) { # R0
                print INST_IMP "unsigned char destination = cpu8051_ReadD( BANKPSW + _R0_ );\n";
            }
@@ -282,7 +280,7 @@ for ($i=0 ; $i< 256; $i++) {
            }
            if ($op_destination == 15) { # reladdr
                print INST_IMP "cpu8051.pc++;\n";
-               print INST_IMP "unsigned int destination = ( ( memory_read8( PGM_MEM_ID, cpu8051.pc - 1 ) + cpu8051.pc ) & 0xFF ) + ( cpu8051.pc & 0xFF00 );\n";
+               print INST_IMP "unsigned int destination = ((char) memory_read8(PGM_MEM_ID, cpu8051.pc - 1)) + cpu8051.pc;\n";
            }
            if ($op_destination == 16) { # #data
                print INST_IMP "unsigned char destination = memory_read8( PGM_MEM_ID, cpu8051.pc++ );\n";
@@ -367,7 +365,7 @@ for ($i=0 ; $i< 256; $i++) {
            }
            if ($op_source == 15) { # reladdr
                print INST_IMP "(cpu8051.pc)++;\n";
-               print INST_IMP "unsigned int source = ( ( memory_read8( PGM_MEM_ID, cpu8051.pc - 1 ) + cpu8051.pc ) & 0xFF ) + ( cpu8051.pc & 0xFF00 );\n";
+               print INST_IMP "unsigned int source = ((char) memory_read8(PGM_MEM_ID, cpu8051.pc - 1)) + cpu8051.pc;\n";
            }
            if ($op_source == 16) { # #data
                print INST_IMP "unsigned char source = memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\n";
@@ -609,10 +607,10 @@ for ($i=0 ; $i< 256; $i++) {
 
        # CJNE
        if ($insttype[$i] == 34) {
-           print INST_IMP "unsigned int reladdr = ( ( memory_read8( PGM_MEM_ID, cpu8051.pc ) + ( ( cpu8051.pc + 1 ) & 0x00FF ) ) & 0x00FF ) + ( ( cpu8051.pc + 1 ) & 0xFF00 );\n";
+           print INST_IMP "unsigned int reladdr = ((char) memory_read8(PGM_MEM_ID, cpu8051.pc)) + (cpu8051.pc + 1);\n";
            print INST_IMP "cpu8051_WriteD( _PSW_, ( cpu8051_ReadD( _PSW_ ) & 0x7F ) );\n";
            print INST_IMP "if ( destination < source ) cpu8051_WriteD( _PSW_, ( cpu8051_ReadD( _PSW_ ) | 0x80 ) );\n";
-           print INST_IMP "if ( destination != source ) cpu8051.pc = reladdr;\n";
+           print INST_IMP "if ( destination != source ) cpu8051.pc = reladdr; else cpu8051.pc++; \n";
        }
 
        # PUSH