??? 11/05/08 07:09 Read: times |
#159692 - My view point on ASM in C Responding to: ???'s previous message |
Neil Kurzman said:
ASM files get handled by the Assembler. C Files by the Compiler. Both make Object files that go to the linker. the Linker makes a Hex file. Done.
Start putting ASM code in the C files what happens? First the optimizer now has to dance around your ASM code. I may see a way to optimize but it is not allowed. It may decide not to optimize the entire function. Or may not be able to because your code is in the way. Aggrreed, the optimiser may fail to optimise. But can be done if you are ready to take it. Neil Kurzman said:
Do a full ASM function with a C function definition. Now the compiler is pushing everything because it is not sure what you are using or jumping to. Call a properly formatted ASM function from C. The Optimizer does not care. Only the minimum amount is pushed, since it is your job now. OR, nothing because you ASM did not bother anything. The point is if you don not pick fights with the tools you can spend less time fighting with them. Note that this will vary by chip, compiler, and Version. Not Quite conviencing, as 1. When you are writing in asm you know which registors & memory locations you are going to use, you can only push & pop them. 2. As far as compiler pushing a lot of jerk when whole funcion is in asm in c body is concerned; There are compilers where you can intruct compiler not to do any push / pop for this funciton (of course it is programmers responisibility now). Regards, Mahesh |