Menu

Bug in 8051 cosimulation.

Help
2011-12-07
2013-04-17
  • Bertold Van den Bergh

    Hello,

    I was getting segmentation faults / wrong results when cosimulating a gezel platform using a 8051 mcu for a university project. I traced this back to several instances of the following problem in i8051sim.cxx:

    RAM[ACC] &= RAM[(unsigned) RAM[GetRegisterBank()+regNum]];
    

    RAM is defined as a signed char, so it can be negative, if it is then cast to (unsigned), which makes it an unsigned integer, the MSB's will be set. As the RAM array is only 384 chars long this will access it outside its bounds resulting most of the time in a segmentation fault.

    Replacing all RAM[(unsigned)… with RAM[(unsigned char) fixed the problem.

    Sincerely,
    Bertold Van den Bergh

     
  • Anonymous

    Anonymous - 2011-12-07

    Thank you for reporting this; This will be fixed with the next release.
    Patrick

     

Log in to post a comment.