When running a program in the mcs51 simulator the return value of that program is lost (hardcoded to 0). This makes it difficult to use for running tests on the host and catching EXIT_SUCCESS/ EXIT_FAILURE
The attached patch allows the return value to be passed through.
[r16441]
Related
Commit: [r16441]
I've applied uCsim part only! Code generator is not touched.
I think that selfjump after the main is not a good solution, as selfjump detection is not used in mcs51 regtests, becouse it is valid in normal code.
Thanks for looking into it.
I've been trying to update my SDCC from 4.2 to 4.5 and had this patch has been sitting in my tree. Apparently using selfjump was the old way of doing it. In fact, it's even still described in the 4.5 manual:
It's just that the documentation doesn't match the actual implementation.
I've also tried using simif 's' command and the execution path is different of course and the return value not forward. So I'm attaching another patch to fix this. It's adding a new function
cl_uc::sim_stop_result. Please have a look again.By trying very hard, it seems the main function can be tricked into returning to a controlled exit function by overriding
__sdcc_external_startupand re-implementing the static initialization.But perhaps it's better to add a way to allow users to implement/override their own exit function.
What about using a label on the seljump which is after main?
uCsim can get address of the label from the cdb (or map) file and automatically break at that address and pass out return value produced by sim_stop_result().
[r16444]
Related
Commit: [r16444]
Thanks!
Yes, that sounds good!
Please see the attached patch.