News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

HeapAlloc alignment

Started by xanatose, January 31, 2015, 06:49:28 PM

Previous topic - Next topic

jj2007

Quote from: rrr314159 on February 08, 2015, 09:19:06 AMjust a casual aside in a tutorial for XP. Doesn't apply to modern OS's. U can't trust such a ref.

It's a Microsoft KB, so you are saying "you can't trust Microsoft". I agree :biggrin:

So it implies you have to roll your own alloc if you want to use XMM regs in 32-bit code. Which is a bad idea anyway because xmm regs are being merciless destroyed by Win32 API calls such as HeapAlloc/ReAlloc/Free and MessageBox. And don't tell me "but that's documented in the ABI" unless you are able to provide a link to an official Microsoft page with the x86 ABI mentioning XMM regs ;-)

hutch--

Maybe I suffer from a simple mind (KISS principle) but if you allocate and align memory then plonk it into a pointer, who cares what happens to XMM registers after that. If you start passing around XMM registers as parameters you risk running into Microsoft not caring what happens to them. Much the same with FP registers, they get trashed routinely. I tend to use registers in a temporary manner wich avoids such problems.

jj2007

Steve,

The only people who care for 16-bit alignment of buffers are those who use SIMD regularly. One can assume they don't like their active xmm regs being trashed by a bloody MessageBox. And saving 5 xmm regs is an issue, performance-wise; not for the MessageBox, of course, but there are also fast APIS. I remember we argued about uses esi edi ebx in WndProc ;-)

hutch--

 :biggrin:

Well, the simple answer is DON'T save them, abuse them like Microsoft do.  :P