An assembly question here. Whenever we want to invoke a function, say "TESTING", we would have to use the commands like CALL, JMP ...ETC.. TESTING: MOV R0,#33 ; ; ; Is it possible that a function is invoked without using any of the instruction sets like CALL, JMP...etc The problem i'm facing is, as i'm looking through the code written by my senior, i found some functions that isnt invoked by any instruction sets. I've confirmed this because i've search thru the code using search function and the result that contain the function's name is only in the function itself.
"I've confirmed this because i've search thru the code using search function and the result that contain the function's name is only in the function itself." Are you sure that you've searched the whole code? Maybe you've missed a file or two? Maybe the functions are called via something like function pointers, or vector tables? Maybe your senior has just set you a test - how long will you waste on this before just asking him/her direct?
When this comes up, I simply comment the "unused" routine out with a "marker" (e.g. //test41--) and link, If the linker fin no error, then it is not called. Erik
thank you all for the replies..they have been useful... erik: Your suggestion is simple and useful but i've not thought of it =P many thanks!
When this comes up, I simply comment the "unused" routine out with a "marker" (e.g. //test41--) and link, If the linker fin no error, then it is not called. Unless, as I mentioned before, the code was obfuscated on purpose. A sufficiently nasty bugger could call that function with a computed goto and never mention its name in the process. Or the function could have been locate to a specific address through some linker hackery, and called at that numerical address. If the function was stored in a different place than the one it's supposed to be executed from, that might even be necessary.
Hans-Bernhard, you are, of course right. However, I suggest to all: if you get exposed to such code THROW IT AWAY. I have seen respossible programmers trying to add to/modify code like you refer to and always spending a lot of time attempting to "work with the code" before taking the unavoidable decision to throw it away. BTW for such code having the source often is not enough, you need the linker script or "surprises" is going to hit you again and again. Oh I have heard the "defenses" for writing as you state "avoid code thievery" and so on, but once I had to "rescue" a company where the "safe" programmer was no more available. This process cost the company more than the cost of someone getting hold of the object code. The problem i'm facing is, as i'm looking through the code written by my senior I REALLY wonder why this question is here in the forum, why does Tan not ask his "senior" Erik
hi all, jus to clarify things. I'm currently handling a project passed down to me from students who have graduated from my university. Hence i don't have their contacts. Thanks for all the help. Appreciate it. Tan
I think you need to take this up with your supervisors. If your predecessors have left incomplete code, or have deliberately obfuscated the code, you could waste a load of time and lose marks for your project...
Hey Neil, Thanks for ya advice. Tan