<div class="gmail_quote">On 6 January 2012 08:22, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com">newshound2@digitalmars.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 1/5/2012 7:42 PM, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Perhaps I misunderstand, I can't see the problem?<br>
In the function preamble, you just align it... something like:<br>
   mov reg, esp ; take a backup of the stack pointer<br>
   and esp, -16 ; align it<br>
<br>
... function<br>
<br>
   mov esp, reg ; restore the stack pointer<br>
   ret 0<br>
</blockquote>
<br></div>
And now you cannot access the function's parameters anymore, because the stack offset for them is now variable rather than fixed.<br>
</blockquote></div><br><div>Hehe, true, but not insurmountable. Scheduling of parameter pops before you perform the alignment may solve that straight up, or else don't align esp its self; store the vector to the stack through some other aligned reg copied from esp...</div>
<div><br></div><div>I just wrote some test functions using __m128 in VisualC, it seems to do something in between the simplicity of my initial suggestion, and my refined ideas one above :)</div><div>If you have VisualC, check out what it does, it's very simple, looks pretty good, and I'm sure it's optimal (MS have enough R&D money to assure this)</div>
<div><br></div><div>I can paste some disassemblies if you don't have VC...</div>