print INST_IMP "#include \"cpu8051.h\"\n";
print INST_IMP "#include \"memory.h\"\n";
print INST_IMP "#include \"instructions_8051.h\"\n\n\n";
print INST_IMP "#include \"cpu8051.h\"\n";
print INST_IMP "#include \"memory.h\"\n";
print INST_IMP "#include \"instructions_8051.h\"\n\n\n";
print DISASM_H "/* disasm.h */\n\n\n";
print DISASM_H "/* Do not modify this file directly, as it was created by opcode2c.pl\n";
print DISASM_H "/* disasm.h */\n\n\n";
print DISASM_H "/* Do not modify this file directly, as it was created by opcode2c.pl\n";
print INST_IMP " unsigned char destination = cpu8051_ReadD( destaddr );\n";
print INST_IMP " destination = source;\n";
print INST_IMP " cpu8051_WriteD( destaddr, destination );\n";
print INST_IMP " unsigned char destination = cpu8051_ReadD( destaddr );\n";
print INST_IMP " destination = source;\n";
print INST_IMP " cpu8051_WriteD( destaddr, destination );\n";
if ($instargs[$i*4] > 0) {
$op_destination=$instargs[$i*4+1];
if ($op_destination == 0) { # addr11
if ($instargs[$i*4] > 0) {
$op_destination=$instargs[$i*4+1];
if ($op_destination == 0) { # addr11
- print INST_IMP " unsigned int addr11 = ( ( memory_read8( PGM_MEM_ID, PC - 1 ) << 3 ) & 0xF00 ) + memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP " unsigned int addr11 = ( ( memory_read8( PGM_MEM_ID, cpu8051.pc - 1 ) << 3 ) & 0xF00 ) + memory_read8( PGM_MEM_ID, cpu8051.pc++ );\n";
- print INST_IMP "unsigned int addr16 = ( memory_read8( PGM_MEM_ID, PC++ ) << 8 );\n";
- print INST_IMP "addr16 += memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned int addr16 = ( memory_read8( PGM_MEM_ID, cpu8051.pc++ ) << 8 );\n";
+ print INST_IMP "addr16 += memory_read8( PGM_MEM_ID, cpu8051.pc++ );\n";
}
if ($op_destination == 2) { # A
print INST_IMP "unsigned char destination = cpu8051_ReadD( _ACC_ );\n";
}
if ($op_destination == 3) { # direct
}
if ($op_destination == 2) { # A
print INST_IMP "unsigned char destination = cpu8051_ReadD( _ACC_ );\n";
}
if ($op_destination == 3) { # direct
print INST_IMP "unsigned char destination = cpu8051_ReadD( destaddr );\n";
}
if ($op_destination == 4) { # @R0
print INST_IMP "unsigned char destination = cpu8051_ReadD( destaddr );\n";
}
if ($op_destination == 4) { # @R0
print INST_IMP "unsigned char destination = cpu8051_ReadD( BANKPSW + _R7_ );\n";
}
if ($op_destination == 14) { # bitaddr
print INST_IMP "unsigned char destination = cpu8051_ReadD( BANKPSW + _R7_ );\n";
}
if ($op_destination == 14) { # bitaddr
print INST_IMP "destination = cpu8051_ReadB( dstbitaddr );\n";
}
if ($op_destination == 15) { # reladdr
print INST_IMP "destination = cpu8051_ReadB( dstbitaddr );\n";
}
if ($op_destination == 15) { # reladdr
- print INST_IMP "PC++;\n";
- print INST_IMP "unsigned int destination = ( ( memory_read8( PGM_MEM_ID, PC - 1 ) + PC ) & 0xFF ) + ( PC & 0xFF00 );\n";
+ 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";
}
if ($op_destination == 17) { # C
print INST_IMP "unsigned char destination = ( cpu8051_ReadD( _PSW_ ) >> 7 );\n";
}
if ($op_destination == 17) { # C
print INST_IMP "unsigned char destination = ( cpu8051_ReadD( _PSW_ ) >> 7 );\n";
print INST_IMP "unsigned int destination = ( cpu8051_ReadD( _DPTRHIGH_ ) << 8 ) + cpu8051_ReadD( _DPTRLOW_ );\n";
}
if ($op_destination == 22) { # #data16
print INST_IMP "unsigned int destination = ( cpu8051_ReadD( _DPTRHIGH_ ) << 8 ) + cpu8051_ReadD( _DPTRLOW_ );\n";
}
if ($op_destination == 22) { # #data16
- print INST_IMP "unsigned char destination = ( memory_read8( PGM_MEM_ID, PC++ ) << 8 );\n";
- print INST_IMP "destination += memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned char destination = ( memory_read8( PGM_MEM_ID, (cpu8051.pc)++ ) << 8 );\n";
+ print INST_IMP "destination += memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\n";
- print INST_IMP "unsigned char destination, dstbitaddr = memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned char destination, dstbitaddr = memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\n";
print INST_IMP "destination = ( cpu8051_ReadB( dstbitaddr ) ^ 1 );\n";
}
if ($op_destination == 24) { # @DPTR
print INST_IMP "destination = ( cpu8051_ReadB( dstbitaddr ) ^ 1 );\n";
}
if ($op_destination == 24) { # @DPTR
if ($instargs[$i*4] > 1) {
$op_source=$instargs[$i*4+2];
if ($op_source == 0) { # addr11
if ($instargs[$i*4] > 1) {
$op_source=$instargs[$i*4+2];
if ($op_source == 0) { # addr11
- print INST_IMP "unsigned int addr11 = ( ( memory_read8( PGM_MEM_ID, PC - 1 ) << 3 ) & 0xF00 ) + memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned int addr11 = ( ( memory_read8( PGM_MEM_ID, cpu8051.pc - 1 ) << 3 ) & 0xF00 ) + memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\n";
- print INST_IMP "unsigned int addr16 = ( memory_read8( PGM_MEM_ID, PC++ ) << 8 );\n";
- print INST_IMP "addr16 += memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned int addr16 = ( memory_read8( PGM_MEM_ID, (cpu8051.pc)++ ) << 8 );\n";
+ print INST_IMP "addr16 += memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\n";
}
if ($op_source == 2) { # A
print INST_IMP "unsigned char source = cpu8051_ReadD( _ACC_ );\n";
}
if ($op_source == 3) { # direct
}
if ($op_source == 2) { # A
print INST_IMP "unsigned char source = cpu8051_ReadD( _ACC_ );\n";
}
if ($op_source == 3) { # direct
- print INST_IMP "PC++;\n";
- print INST_IMP "unsigned int source = ( ( memory_read8( PGM_MEM_ID, PC - 1 ) + PC ) & 0xFF ) + ( PC & 0xFF00 );\n";
+ 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";
}
if ($op_source == 17) { # C
print INST_IMP "unsigned char source = ( cpu8051_ReadD( _PSW_ ) >> 7 );\n";
}
if ($op_source == 17) { # C
print INST_IMP "unsigned char source = ( cpu8051_ReadD( _PSW_ ) >> 7 );\n";
print INST_IMP "unsigned char source = memory_read8( PGM_MEM_ID, cpu8051_ReadD( _ACC_ ) + cpu8051_ReadD( _DPTRLOW_ ) + ( cpu8051_ReadD( _DPTRHIGH_ ) << 8 ) );\n";
}
if ($op_source == 19) { # @A+PC
print INST_IMP "unsigned char source = memory_read8( PGM_MEM_ID, cpu8051_ReadD( _ACC_ ) + cpu8051_ReadD( _DPTRLOW_ ) + ( cpu8051_ReadD( _DPTRHIGH_ ) << 8 ) );\n";
}
if ($op_source == 19) { # @A+PC
}
if ($op_source == 21) { # DPTR
print INST_IMP "unsigned int source = ( cpu8051_ReadD( _DPTRHIGH_ ) << 8 ) + cpu8051_ReadD( _DPTRLOW_ );\n";
}
if ($op_source == 22) { # #data16
}
if ($op_source == 21) { # DPTR
print INST_IMP "unsigned int source = ( cpu8051_ReadD( _DPTRHIGH_ ) << 8 ) + cpu8051_ReadD( _DPTRLOW_ );\n";
}
if ($op_source == 22) { # #data16
- print INST_IMP "unsigned char source = ( memory_read8( PGM_MEM_ID, PC++ ) << 8 );\n";
- print INST_IMP "source += memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned char source = ( memory_read8( PGM_MEM_ID, (cpu8051.pc)++ ) << 8 );\n";
+ print INST_IMP "source += memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\n";
- print INST_IMP "cpu8051_WriteI( ++SP, ( PC & 0x00FF ) );\n";
- print INST_IMP "cpu8051_WriteI( ++SP, ( PC >> 8 ) );\n";
+ print INST_IMP "cpu8051_WriteI( ++SP, ( cpu8051.pc & 0x00FF ) );\n";
+ print INST_IMP "cpu8051_WriteI( ++SP, ( cpu8051.pc >> 8 ) );\n";
print INST_IMP "cpu8051_WriteD( _SP_, SP );\n";
}
# LCALL
if ($insttype[$i] == 7) {
print INST_IMP "unsigned char SP = cpu8051_ReadD( _SP_ );\n";
print INST_IMP "cpu8051_WriteD( _SP_, SP );\n";
}
# LCALL
if ($insttype[$i] == 7) {
print INST_IMP "unsigned char SP = cpu8051_ReadD( _SP_ );\n";
- print INST_IMP "cpu8051_WriteI( ++SP, ( PC & 0x00FF ) );\n";
- print INST_IMP "cpu8051_WriteI( ++SP, ( PC >> 8 ) );\n";
+ print INST_IMP "cpu8051_WriteI( ++SP, ( cpu8051.pc & 0x00FF ) );\n";
+ print INST_IMP "cpu8051_WriteI( ++SP, ( cpu8051.pc >> 8 ) );\n";
- print INST_IMP "PC = ( cpu8051_ReadI( SP-- ) << 8 );\n";
- print INST_IMP "PC += cpu8051_ReadI ( SP-- );\n";
+ print INST_IMP "cpu8051.pc = ( cpu8051_ReadI( SP-- ) << 8 );\n";
+ print INST_IMP "cpu8051.pc += cpu8051_ReadI ( SP-- );\n";
- print INST_IMP "PC = ( cpu8051_ReadI( SP-- ) << 8 );\n";
- print INST_IMP "PC += cpu8051_ReadI( SP-- );\n";
+ print INST_IMP "cpu8051.pc = ( cpu8051_ReadI( SP-- ) << 8 );\n";
+ print INST_IMP "cpu8051.pc += cpu8051_ReadI( SP-- );\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 "cpu8051_WriteD( _PSW_, ( cpu8051_ReadD( _PSW_ ) & 0x7F ) );\n";
print INST_IMP "if ( destination < source ) cpu8051_WriteD( _PSW_, ( cpu8051_ReadD( _PSW_ ) | 0x80 ) );\n";
if ($instargs[$i*4] > 0) {
$op_destination=$instargs[$i*4+1];
if ($op_destination == 0) { # addr11
if ($instargs[$i*4] > 0) {
$op_destination=$instargs[$i*4+1];
if ($op_destination == 0) { # addr11
}
if ($op_destination == 2) { # A
print INST_IMP "cpu8051_WriteD( _ACC_, destination );\n";
}
if ($op_destination == 2) { # A
print INST_IMP "cpu8051_WriteD( _ACC_, destination );\n";
if ($instargs[$i*4] > 1) {
$op_source=$instargs[$i*4+2];
if ($op_source == 0) { # addr11
if ($instargs[$i*4] > 1) {
$op_source=$instargs[$i*4+2];
if ($op_source == 0) { # addr11
}
if ($op_source == 2) { # A
print INST_IMP "cpu8051_WriteD( _ACC_, source );\n";
}
if ($op_source == 2) { # A
print INST_IMP "cpu8051_WriteD( _ACC_, source );\n";