|Pushes, Pops, NOPS firstname.lastname@example.org (2003-12-03)|
|Re: Pushes, Pops, NOPS Barak.Zalstein@ParthusCeva.com (Barak Zalstein) (2003-12-08)|
|Re: Pushes, Pops, NOPS email@example.com (2003-12-08)|
|Re: Pushes, Pops, NOPS firstname.lastname@example.org (Nick Roberts) (2003-12-08)|
|Re: Pushes, Pops, NOPS email@example.com (Ken Rose) (2003-12-08)|
|Re: Pushes, Pops, NOPS firstname.lastname@example.org (2003-12-08)|
|Re: Pushes, Pops, NOPS email@example.com (Lex Spoon) (2003-12-13)|
|From:||firstname.lastname@example.org (Michael Tiomkin)|
|Date:||8 Dec 2003 00:22:44 -0500|
|Posted-Date:||08 Dec 2003 00:22:44 EST|
email@example.com (Kalyan) wrote in message news:03-12-032...
> I have a question regarding assembly language. Suppose we have a 10
> to 12 line code in assembly language(The purpose of the code is not
> important here, because i have a different objective explained
> below).It is as follows:
... some inlined assembly omitted
> If I added some "NOPS" in between each of the instructions above just
> to make the code look bigger, is there any option while compiling with
> GCC which would eliminate all those unnecessary "NOPS" and then
> convert the remaining code to binary?
I hope it wouldn't. The purpose of inlined assembly is to translate
the lines as given by the programmer. What whould happen if your code
contains relative jumps wih numbers instead of labels?
> Also are there any open source assemblers which would convert the
> above assembly program to binary by eliminating unnecessary NOPS? My
> objective is to eliminate unnecessary "NOPS" wherever they are and
> also unnecessary pushes and pops, for eg., we hav push eax and
> immediately following that a pop eax. I want to eliminate such
> instructions. Could anyone please tell me if there are any freeware
> or shareware assembler or compiler tools that would eliminate these
> unnecessary instructions?
If you know that the jump targets wouldn't be corrupt by deleting
instructions, you can remove nops using a simple script/editor macro.
BTW, for many i86 processors one of the jump optimizations is to align
jump targets, and this is done with inserting nops into the code.
For eliminating the "push eax; pop eax" you should be sure that
1. the code never jumps directly to the 2nd statement
2. the code doesn't depend on the explicit size of the original version
3. the code isn't self-modifying
4. you don't care about stack overflow
Unfortunately, there is a small differnence between "cc -O2" and
"asm -O2". Assembly optimization creates code that is not always
equivalent to the original code. The optimized code will be
equivalent to the original only if the assembly program is "well
Return to the
Search the comp.compilers archives again.