cfw("cpu8051.pc++;");
}
if ($op_destination == 1) { # addr16
- cfw("unsigned int addr16 = ( memory_read8( PGM_MEM_ID, cpu8051.pc++ ) << 8 );");
- cfw("addr16 += memory_read8( PGM_MEM_ID, cpu8051.pc++ );");
+ cfw("uint16_t addr16 = pgm_read_addr16(cpu8051.pc);");
+ cfw("cpu8051.pc += 2;");
}
if ($op_destination == 2) { # A
cfw("unsigned char destination = cpu8051_ReadD( _ACC_ );");
if ($op_destination == 5) { # @R1
cfw("unsigned char destination = cpu8051_ReadI ( cpu8051_ReadD( BANKPSW + _R1_ ) );");
}
-
if ($op_destination == 6) { # R0
cfw("unsigned char destination = cpu8051_ReadD( BANKPSW + _R0_ );");
}
if ($op_destination == 18) { # @A+DPTR
cfw("unsigned int destination = cpu8051_ReadD( _ACC_ ) + memory_sfr_read_dptr();");
}
-# Mis en commentaire car donnait un warning (destination et source unused variables...)
-# if ($op_destination == 20) { # AB
-# cfw("unsigned char destination = cpu8051_ReadD( _ACC_ );");
-# cfw("unsigned char source = cpu8051_ReadD( _B_ );");
-# }
+ if ($op_destination == 20) { # AB
+ cfw("unsigned char destination = cpu8051_ReadD( _ACC_ );");
+ cfw("unsigned char source = cpu8051_ReadD( _B_ );");
+ }
if ($op_destination == 21) { # DPTR
cfw("unsigned int destination = memory_sfr_read_dptr();");
}
- if ($op_destination == 22) { # #data16
- cfw("unsigned char destination = ( memory_read8( PGM_MEM_ID, (cpu8051.pc)++ ) << 8 );");
- cfw("destination += memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );");
- }
if ($op_destination == 23) { # /bitaddr
cfw("unsigned char destination, dstbitaddr = memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );");
cfw("destination = ( cpu8051_ReadB( dstbitaddr ) ^ 1 );");
cfw("unsigned int addr11 = ( ( memory_read8( PGM_MEM_ID, cpu8051.pc - 1 ) << 3 ) & 0xF00 ) + memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );");
}
if ($op_source == 1) { # addr16
- cfw("unsigned int addr16 = ( memory_read8( PGM_MEM_ID, (cpu8051.pc)++ ) << 8 );");
- cfw("addr16 += memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );");
+ cfw("uint16_t addr16 = pgm_read_addr16(cpu8051.pc);");
+ cfw("cpu8051.pc += 2;");
}
if ($op_source == 2) { # A
cfw("unsigned char source = cpu8051_ReadD( _ACC_ );");
cfw("unsigned int source = memory_sfr_read_dptr();");
}
if ($op_source == 22) { # #data16
- cfw("unsigned char source = ( memory_read8( PGM_MEM_ID, (cpu8051.pc)++ ) << 8 );");
- cfw("source += memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );");
+ cfw("uint16_t source = pgm_read_addr16(cpu8051.pc);");
+ cfw("cpu8051.pc += 2;");
}
if ($op_source == 23) { # /bitaddr
cfw("unsigned char source, srcbitaddr = memory_read8( PGM_MEM_ID, (cpu8051.pc)++ );");
##############################################################################
$modifysrc=0;
-# cfw("\n// Inserer le code ici\n\n";
# RR
if ($insttype[$i] == 3) {
# DIV
if ($insttype[$i] == 29) {
- cfw("unsigned char A = cpu8051_ReadD( _ACC_ ), B = cpu8051_ReadD( _B_ );");
+ # A = destination
+ # B = source
cfw("psw_clr_cy();");
# If B is zero, the OV flag will be set indicating a
# division-by-zero error
- cfw("if ( B != 0 ) {");
- cfw(" cpu8051_WriteD( _ACC_, A/B ); cpu8051_WriteD( _B_, A%B );");
+ cfw("if (source != 0) {");
+ cfw(" cpu8051_WriteD(_ACC_, destination/source);");
+ cfw(" cpu8051_WriteD( _B_, destination%source);");
cfw(" psw_clr_ov();");
cfw("} else {");
cfw(" psw_set_ov();");
# MUL
if ($insttype[$i] == 31) {
- cfw("unsigned char A = cpu8051_ReadD( _ACC_ ), B = cpu8051_ReadD( _B_ );");
+ # A = destination
+ # B = source
cfw("psw_clr_cy();");
- cfw("psw_clr_ov();");
- cfw("cpu8051_WriteD( _ACC_ , ( ( A * B ) & 0x00FF ) ); cpu8051_WriteD( _B_, ( A * B ) / 0x100 );");
+ cfw("cpu8051_WriteD(_ACC_, destination * source);");
+ cfw("cpu8051_WriteD(_B_, (destination * source) / 0x100);");
cfw("if (cpu8051_ReadD(_B_) > 0)");
cfw(" psw_set_ov();");
cfw("else");