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 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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-12-07
Thank you for reporting this; This will be fixed with the next release.
Patrick
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 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
Thank you for reporting this; This will be fixed with the next release.
Patrick