The MASM Forum

General => The Campus => Topic started by: Rav on June 07, 2022, 07:45:57 AM

Title: Are XMM registers always automatically initialized to 0?
Post by: Rav on June 07, 2022, 07:45:57 AM
I'm writing assembly routines in 32-bit CPU mode, using directives .686 and .XMM so that I can utilize SSE instructions.  I needed to start with register XMM1 as all-0, so I have been using PXOR xmm1,xmm1 to set it to 0.  But when assembling with MASM, I noticed that in the Register window that while the general purpose registers all started with various values in them (as expected), the XMM registers  (XMM0-XMM7) all started as all-0.  They appear to be automatically initialized to 0.  So it made me wonder if I actually need to use PXOR to set it to 0.  Is this a known "feature" of the XMM registers, and if so, is it documented anywhere?  I Googled but didn't find anything about it.
Thanks.  / Rav
Title: Re: Are XMM registeres always automatically initialized to 0?
Post by: hutch-- on June 07, 2022, 08:36:14 AM
Rav,

You would have to determine that from the Intel manuals and then check if its a characteristic of the operating system. Safety says do it yourself, then you know its done.
Title: Re: Are XMM registers always automatically initialized to 0?
Post by: jj2007 on June 07, 2022, 09:08:39 AM
On my machine, even ecx, esi, edi and the whole FPU are zero at the entry point. Will I rely on that? Never.

Hutch is right, if it's not explicitly documented, don't use it. There are some badly documented grey areas; for example, variables in the .DATA? section are initialised to zero, but you will have a problem finding a Micros*t doc which says so.
Title: Re: Are XMM registers always automatically initialized to 0?
Post by: Rav on June 07, 2022, 09:27:40 AM
Thanks, hutch and jj2007.  I'll go with safety and initialize it.