From 67a0a710e077d824e90681614e867d0b78e26520 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sat, 7 Sep 2013 18:10:27 -0400 Subject: [PATCH] Fix error with CJNE instruction When the comparison was true, the PC was advanced by 2 instead of 3 bytes. Error reported and fixed by Tobias Diedrich (ranma at tdiedrich.de). --- src/opcode2c.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opcode2c.pl b/src/opcode2c.pl index 4741f07..a80f651 100755 --- a/src/opcode2c.pl +++ b/src/opcode2c.pl @@ -610,7 +610,7 @@ for ($i=0 ; $i< 256; $i++) { 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 -- 2.20.1