|Question about MS C code generation firstname.lastname@example.org (2003-11-21)|
|Re: Question about MS C code generation email@example.com (Joachim Durchholz) (2003-12-03)|
|Re: Question about MS C code generation firstname.lastname@example.org (2003-12-03)|
|Re: Question about MS C code generation email@example.com (2003-12-03)|
|Re: Question about MS C code generation firstname.lastname@example.org (2003-12-03)|
|Date:||3 Dec 2003 20:27:43 -0500|
|Organization:||AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com|
|Posted-Date:||03 Dec 2003 20:27:43 EST|
Im Artikel 03-11-090, email@example.com (sugaray) schreibt:
> if(a<0) b=-5;
> else if(a>=0) b=5;
> else b=0;
Obviously this could be rewritten as:
b = (a<0) ? -5 : 5;
>my question is: 1) refer to the comment parts
No comment, for now.
> 2) was it any good, probably for the optimization purpose ?
IMO it was good for proving that every transformation of some given code can
> 3) what kinda logic style would you prefer ?
A clear one, so that logic and transformation errors can be avoided easily.
> 4) if asked, how would you write this program in assembly ?
Why should one do so? Why this program, and which version? Optimized for size
If ever, I would:
Step 1: use an good compiler, possibly for a different langugage.
Step 2: switch on all available optimizations.
Step 3: disassemble the compiler output, if no assembler listing is available.
In no case would I write x86 assembly code myself, even not for money. If you
want to learn writing machine code, then I'd suggest that you choose a
different CPU, perhaps with an emulator. If you want to learn how to write
efficient programs, then read more about algorithms and proof of correctness.
If you want to learn how to efficiently write programs, have a look at software
design and project management. Otherwise you should explain what you really
have in mind.
Return to the
Search the comp.compilers archives again.