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
Posted on 2001-03-20 12:56:00 by angelo
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
Posted on 2001-03-20 13:18:00 by drcmda
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)
Posted on 2001-03-20 16:48:00 by Vom-bonjour:-()
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
Posted on 2001-03-20 18:19:00 by BogdanOntanu
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."
Posted on 2001-03-20 18:21:00 by Ernie
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.
Posted on 2001-03-20 23:37:00 by George
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,
Posted on 2001-03-21 02:30:00 by hutch--