We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am working on project with AT8052 with keil While doing C coding i have created many functions at certain situation multiple nesting of functions occur which may be avoided with some effort. Since 8051 stack is inside the internal RAM itself and i am not using any external data memory, should i avoid multiple nesting of function as it may occupy more RAM area. Regards Nitin
Erik, I did not intend that post as criticism, but rather an examination of some of the issues surrounding such choices. as long as it does not interfere with the most effective code "Effective" is measured in multiple dimensions, which is more or less the point of my earlier post. In my opinion, the best engineering tradeoff isn't necessarily the minimum on the code size or speed axis, but that's certainly a major factor that has to be taken into account for each case. And limited environments such as a typical 8051 project place even more of a premium on performance. I belong to the "less is more" school myself, particular since my current project is pushing 64,000 bytes of object code ;) It even has a global variable not all that different from the hypothetical mainState (though I might have talked myself into wrapping it with an access function with my own post!)
Drew, I think we agree that coding is not pantyhose (one size does not fit all) and while some may lean one way and some may lean another way the truth is that in all cases "you shall not" should be replaced by "you shall only if good". My reaction on global variables is strongly flovored by exposure to some programmers that would rather screw up a program structure than use a global variable. I have also seen programmers coming from assembly using global variables where a local would be the better choice. So let's agree that the right choice is not what some "guru" stated a a "rule" but what is best for functionality and mainatainability (the ability to maintain it - not killing the code to protect it aginst you). Where functionality should take priority over mainatainability will always be a judgement call and I know that you can prioritize functionality without losing more than a few percent of maintainability if you keep thinking maintainability while coding functionality. Erik