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 "extern int ActivePriority;\n";
-print INST_IMP "extern unsigned int PC;\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";
if( $i == 0x85 ) {
# Cas particulier pour MOV direct,direct -> src et dest sont inverses dans la memoire
- print INST_IMP " unsigned char srcaddr = memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP " unsigned char srcaddr = memory_read8( PGM_MEM_ID, cpu8051.pc++ );\n";
print INST_IMP " unsigned char source = cpu8051_ReadD( srcaddr );\n";
- print INST_IMP " unsigned char destaddr = memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP " unsigned char destaddr = memory_read8( PGM_MEM_ID, cpu8051.pc++ );\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
- 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";
}
if ($op_destination == 1) { # addr16
- 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
- print INST_IMP "unsigned char destaddr = memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned char destaddr = memory_read8( PGM_MEM_ID, cpu8051.pc++ );\n";
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, 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 );\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 == 16) { # #data
- print INST_IMP "unsigned char destination = memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned char destination = memory_read8( PGM_MEM_ID, cpu8051.pc++ );\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 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";
}
if ($op_destination == 23) { # /bitaddr
- 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
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";
}
if ($op_source == 1) { # addr16
- 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
- print INST_IMP "unsigned char srcaddr = memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned char srcaddr = memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\n";
print INST_IMP "unsigned char source = cpu8051_ReadD( srcaddr );\n";
}
if ($op_source == 4) { # @R0
}
if ($op_source == 14) { # bitaddr
- print INST_IMP "unsigned char source, srcbitaddr = memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned char source, srcbitaddr = memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\n";
print INST_IMP "source = cpu8051_ReadB( srcbitaddr );\n";
}
if ($op_source == 15) { # reladdr
- 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 == 16) { # #data
- print INST_IMP "unsigned char source = memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned char source = memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\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_ ) + ( ++PC ) );\n";
+ print INST_IMP "unsigned char source = memory_read8( PGM_MEM_ID, cpu8051_ReadD( _ACC_ ) + ( ++cpu8051.pc ) );\n";
}
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";
}
if ($op_source == 23) { # /bitaddr
- print INST_IMP "unsigned char source, srcbitaddr = memory_read8( PGM_MEM_ID, PC++ );\n";
+ print INST_IMP "unsigned char source, srcbitaddr = memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );\n";
print INST_IMP "source = ( cpu8051_ReadB( srcbitaddr ) ^ 1 );\n";
}
if ($op_source == 24) { # @DPTR
# JBC
if ($insttype[$i] == 5) {
- print INST_IMP "if ( destination == 1 ) { PC = source; destination = 0; }\n";
+ print INST_IMP "if ( destination == 1 ) { cpu8051.pc = source; destination = 0; }\n";
}
# ACALL
if ($insttype[$i] == 6) {
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 "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 "cpu8051_WriteD( _SP_, SP );\n";
}
# JB
if ($insttype[$i] == 10) {
- print INST_IMP "if ( destination == 1 ) { PC = source; }\n";
+ print INST_IMP "if ( destination == 1 ) { cpu8051.pc = source; }\n";
}
# RET
if ($insttype[$i] == 11) {
print INST_IMP "unsigned char SP = cpu8051_ReadD( _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( _SP_, SP );\n";
}
# JNB
if ($insttype[$i] == 14) {
- print INST_IMP "if ( destination == 0 ) { PC = source; }\n";
+ print INST_IMP "if ( destination == 0 ) { cpu8051.pc = source; }\n";
}
# RETI
if ($insttype[$i] == 15) {
- print INST_IMP "ActivePriority = -1;\n";
+ print INST_IMP "cpu8051.active_priority = -1;\n";
print INST_IMP "unsigned char SP = cpu8051_ReadD( _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";
}
# RLC
# JC
if ($insttype[$i] == 18) {
- print INST_IMP "if ( cpu8051_ReadD( _PSW_ ) > 0x7F) { PC = destination; }\n";
+ print INST_IMP "if ( cpu8051_ReadD( _PSW_ ) > 0x7F) { cpu8051.pc = destination; }\n";
}
# ORL
# JNC
if ($insttype[$i] == 20) {
- print INST_IMP "if ( cpu8051_ReadD( _PSW_ ) < 0x80 ) { PC = destination; }\n";
+ print INST_IMP "if ( cpu8051_ReadD( _PSW_ ) < 0x80 ) { cpu8051.pc = destination; }\n";
}
# ANL
# JZ
if ($insttype[$i] == 22) {
- print INST_IMP "if ( cpu8051_ReadD( _ACC_ ) == 0 ) { PC = destination; }\n";
+ print INST_IMP "if ( cpu8051_ReadD( _ACC_ ) == 0 ) { cpu8051.pc = destination; }\n";
}
# XRL
# JNZ
if ($insttype[$i] == 24) {
- print INST_IMP "if ( cpu8051_ReadD( _ACC_ ) != 0 ) { PC = destination; }\n";
+ print INST_IMP "if ( cpu8051_ReadD( _ACC_ ) != 0 ) { cpu8051.pc = destination; }\n";
}
# JMP
if ($insttype[$i] == 25) {
- print INST_IMP "PC = destination;\n";
+ print INST_IMP "cpu8051.pc = destination;\n";
}
# MOV
# SJMP
if ($insttype[$i] == 27) {
- print INST_IMP "PC = destination;\n";
+ print INST_IMP "cpu8051.pc = destination;\n";
}
# MOVC
# CJNE
if ($insttype[$i] == 34) {
- print INST_IMP "unsigned int reladdr = ( ( memory_read8( PGM_MEM_ID, PC ) + ( ( PC + 1 ) & 0x00FF ) ) & 0x00FF ) + ( ( PC + 1 ) & 0xFF00 );\n";
+ 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 "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 ) PC = reladdr;\n";
+ print INST_IMP "if ( destination != source ) cpu8051.pc = reladdr;\n";
}
# PUSH
# DJNZ
if ($insttype[$i] == 42) {
print INST_IMP "destination--;\n";
- print INST_IMP "if ( destination != 0 ) PC = source;\n";
+ print INST_IMP "if ( destination != 0 ) cpu8051.pc = source;\n";
}
# XCHD
if ($instargs[$i*4] > 0) {
$op_destination=$instargs[$i*4+1];
if ($op_destination == 0) { # addr11
- print INST_IMP "PC = ( PC & 0xF800 ) | addr11;\n";
+ print INST_IMP "cpu8051.pc = ( cpu8051.pc & 0xF800 ) | addr11;\n";
}
if ($op_destination == 1) { # addr16
- print INST_IMP "PC = addr16;\n";
+ print INST_IMP "cpu8051.pc = addr16;\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
- print INST_IMP "PC = ( PC & 0xF800 ) | addr11;\n";
+ print INST_IMP "cpu8051.pc = ( cpu8051.pc & 0xF800 ) | addr11;\n";
}
if ($op_source == 1) { # addr16
- print INST_IMP "PC = addr16;\n";
+ print INST_IMP "cpu8051.pc = addr16;\n";
}
if ($op_source == 2) { # A
print INST_IMP "cpu8051_WriteD( _ACC_, source );\n";