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.
Hi all
I have a normal 8051's code ,but i want insert NOP instruction in the specified address without modify the original code (it meaning I didn't need to check LST file to find the address and then insert a nop )
for example The code before insert NOP:
02FF F1EA 4147 CALL A_FUNC 0301 22 4148 RET
The code after insert NOP:
02FF 00 XXXX NOP 0300 F1EB 4147 CALL A_FUNC 0302 22 4148 RET
I try to put
ORG 2FFh NOP
in the top or bottom of the code ,
In the top ,It will be overwritten , there is nothing change, In the bottom , It will insert a NOP instruction, but destroyed the original instructions format
Does the compiler or linker can help to do this work ?? it also can say I want retain the specified location for NOP, so compiler will skip it but still compiled correctly
Thanks a lot for you read this post , and please forgive my poor English
"Does the compiler or linker can help to do this work ??"
No - because they all work from the original code!
Please explain why you want to do this: ie, what do you want to achieve by it?
People can't offer appropriate suggestions if they don't know what the actual goal is!
www.catb.org/.../smart-questions.html
I want to cross the road.
I can't offer appropriate suggestions if I don't know what the actual goal is!
What is your actual goal?
I want to go to the supermarket and buy some milk.
Oh, that's easy. There's a pedestrian crossing a little further along, use that.
Thank you. Why didn't you just say that in the first place?
That supermarket doesn't sell milk - you need to stay on this side of the road, and go to that corner store over there...
Thank you. I'm glad you made the effort to understand my real need, so that I didn't waste my time on what would have turned out to be a fruitless exercise, and would have left me further from my goal!
Yes it does. I know. I used to live right beside it. Now I have just moved here and have never needed to cross this road before. This is why I ask the simple question. Besides which, I've never heard of a supermarket that doesn't sell milk. I don't think I can trust any advice you give. You've failed the interview. Goodbye.
Just as well I saved you a wasted trip across the road, then!
Huh? I've just been across the road to the supermarket and got my milk. Fresh and cold and not that horrible soya stuff. Just what I wanted. Will go nicely with my tea and biscuits.
Anyway, what are you still doing here by the side of the road? Loitering? Out of work? Bored? There's a nice wall around here you could go and paint some fresh graffiti on. Now where did I see it? Oh yes, by the supermarket. You know where it is? Just across the road.
If you are able to add that ORG statement, then you are obviously modifying source code. So don't waste more time - add that nop where it should be - on the line before the call.
You can't have a nop unless there is a free space for it. Placing the nop on the line before the call, the assembler+linker will reserve space for it. Trying to play with ORG will not reserve any space. The memory cell can either store a nop, or the first part of that call instruction.
An alternative is that you, as hinted at by previous posters, tells us exactly why you feel there is a need for a nop before that call. And why you see it so problematical to just insert it on the proper line of the source file.
So why did you ask??
Because I didn't previously know how to cross this road.
You can stay standing by the side of the road if you want.
I'm going to my new home on this side of the road after asking you how to get across the road with which I was not previously familiar, to the neighbourhood where I used to live, to go to the supermarket to get real cow milk, which I knew they stocked because I'd been there before, for my tea. Whew!
I have a normal 8051's code ,but i want insert NOP instruction in the specified address without modify the original code
That wish is self-contradictory. Inserting a NOP is a modification of the original code.
So now we know there's absolutely way you can have what you think you want, how about we find out what you actually want? You'll have to start by telling why it is you think you want what you said.