This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Movx command in Keil

Hello all,
I'm using Keil uVision2 Version 7.05, and everything seems to be OK. However, there is one thing I don't quite understand, thus I'm posting here asking for your ideas/opinions.
When I run "Hello" example in Keil\Example directory and I found something that puzzled me. The assembly code Keil generated in Disamsembly window as well as in list file always have MOVX command eventhough I don't use external ram at all. I did set memory model to small and I only use IDATA but it still does the same. I even use disamsembler to translate the hex file Keil generated back to assembly source and still get the same result. Can someone spend some times explain this for me? Any inputs would be greatly appreciated. Have a nice weekend.

Best Regards,
T.L

Parents
  • Are there anyways to tell compiler not generate code that access all the memory areas if it's not needed?

    What you failed to understand so far is that the movx'es you found are not actually generated by the compiler. They're found in generic routines pulled in from the run-time library, by the linker.

    Nor does this code necessarily access unused memory classes --- it just has the potential to do so, in case that you did have stuff stored there. I.e. your code will only ever reach any of those movx instructions by exercising undefined behaviour.

    If you insist on doing so, the way to tell the tools not to link in these functions is to not call any library functions that operate on generic pointers (in the case at hand, printf()).

Reply
  • Are there anyways to tell compiler not generate code that access all the memory areas if it's not needed?

    What you failed to understand so far is that the movx'es you found are not actually generated by the compiler. They're found in generic routines pulled in from the run-time library, by the linker.

    Nor does this code necessarily access unused memory classes --- it just has the potential to do so, in case that you did have stuff stored there. I.e. your code will only ever reach any of those movx instructions by exercising undefined behaviour.

    If you insist on doing so, the way to tell the tools not to link in these functions is to not call any library functions that operate on generic pointers (in the case at hand, printf()).

Children
No data