probably it is a stupid question: i'm using tasm 5.0. I'm wondering if is there any difference in final exe speed if i use .if, .else instructions in the code or if i use cmp je jne instructions to do the same things. Thanks Angelo This message was edited by Hiroshimator, on 3/20/2001 2:21:11 PM
i think thats the same, maybe the ".if .else" is faster if you don't otimize things like "cmp reg,0". i use the ".if .else" method only for dialog handling but why should i use this for normal purposes - are we coding in ASSEMBLER or in hll? This message was edited by Hiroshimator, on 3/20/2001 2:21:25 PM
No, it's not a stupid question, (I use Masm32 V6.15) and there is a few days, I denug a prog I made with SoftIce and I saw that when there is a .if .else, it uses more cmp than if you use manually cmp. But I don't think it makes the prog very slower. To see the differences between .if .else & cmp, you should debug a prog with SoftIce (or another debugger if you know another one)
So to conclude 1.Free to use .if .endif in logical/gui stuff, where speed dosent matter that much, but clarity of proramming does a lot (however you can do without i you so like, just make it as clear as possible) 2.Never use if in highly optimised loops (like inner grafix loops in Games :) ) for that area you have a better compiler between your ears :D
Nah, you don't need a debugger, you just have to tell the compiler to make a listing (.lst) filr for you, and see how your .IF's were translated. Generally, MASM does an excellent job. I'd never give up the readability for the very occasional speed increase. -------------------------------- "I think Smithers picked me because of my motivational skills. Everyone says they have to work a lot harder when I'm around."
BogdanOntanu is right, 90% of the time, using high(er) level flow control loops does not affect the speed of your app at all. In certain cases eliminating the jxx instructions with other methods can improve speed (This is speed 'calculated', not detectible) in certain situations, such as inner game loops etc. Also, in most situations, code in your exe will maybe only be run several times, so optimizing your code for speed in such a case is a complete waste of effort and time, the extra gain will be somewhere in the microseconds! In other cases, such as code run in a loop or .WHILE or .REPEAT block could be run thousands of times, and just general code organisation and maximim register use can be noticible. In a game, for say the drawing loop, the code will get executed millions of times, and for such you would want maximim possible gain. So really, optimization, is in a ratio of how small, how fast and how much effot you want to stick into doing something that could be next to pointless.
I guess its all been said but I am of the view that clean logic is more use than "faster" blunders. Both MASM & TASM support the .if block syntax which can be nested in the normal manner which produces absolute nightmares in manual CMP/JMP style code. Where you need to write truly speed critical code, you will not use it or simplistic replacements but optimise the code by benchmarking it to get the maximum speed. As far as the notion of "HLL", assembler IS a HLL, you can write true low level code in HEX which is a good way to write DOS stubs but writing an application in HEX is nonsense, it would end up finished in time for the release of win3000. A lot of the strength of MACRO assemblers is there capacity to write HLL style code where speed does not really matter but good clean logic does. Regards, firstname.lastname@example.org