News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

??? design code to max after Agner fog manual?

Started by daydreamer, February 16, 2006, 06:08:27 PM

Previous topic - Next topic

daydreamer

 jmps and calls isnt good and should be avoided

does that mean I should avoid place code in winmain, after checking with peekmessage, but maybe put all code in workerthread instead?
workerthread is just another thread in the OS that gets interrupted the same amount as winmain anyway, so apicalls peekmessage, sendmessage etc isnt transferring control

a workerthread gets its own setup with regs, so keep all nesserary api calls in winmain, while having no proc calls at all in the workerthread code and I can use all regs, including esp,ebp

replace conditional jmps with unconditional and AND on pointers to make a kinda rollaround effect in that thread?
startthread and stopthread from main thread stops controls execution? well you could add control to add counters in loops from a constant in memory and main thread zeroes it+stopthread to control it

could I get some feedback on these Ideas?
another question: if I should make an recursive algo that each step deeper level use /2 on all variables and each step back up shouldnt it be faster with several add all regs doing x2 to restore them all, than to pop/push them on stack? they are all independent from each others

in loops that are not too small, could I gain speed by freeing up ecx todo other things and use a memory counter instead?, well in local memoryarea, yes even if I have to use a slow inc @@memory / jne loop, instead of add ecx /jne loop, how many cycles do I need to win by use ecx to make it worth?

back to hard innerloop that is aligned , should I make it more customizable by have it all controlled by local memoryconstants, not immediates for loop controls etc and just after it have code that changes all those to customize it for a different task by change those and call the innerloop to start again, instead of having a second loop longer down in the code?
the first loop is already branch predicted, which it isnt the case if I have two loops doing similar things, must be an advantage to reuse same loop over and over again?




Tedd

My (half-baked) thoughts..

jmp and call are fine. The problem comes from conditional jumps - since you don't know which way they will go in advance (if you did they could just be direct jumps.)
In-lining the code for some functions (to remove calls) can be a benefit if the code is small and fairly flat.
I see no benefit from moving code to another thread just for the sake of it. Winmain will still loop, so you may as well do something in there if it's convenient.

Freeing up ecx is as easy as "push ecx" ...do stuff.... "pop ecx" ...check and loop ?
With few registers to spare, one more should give you chance to work a little more effectively - and so you should be able to get gains from that (speed or otherwise.)

There are benefits to using the same loop over again, but it depends on the slow-down caused by your generalisations. It's a case of test-it-and-see (as with most things.)
No snowflake in an avalanche feels responsible.