Author Topic: Are XMM registers always automatically initialized to 0?  (Read 617 times)

Rav

  • Regular Member
  • *
  • Posts: 36
Are XMM registers always automatically initialized to 0?
« 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

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Are XMM registeres always automatically initialized to 0?
« Reply #1 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Are XMM registers always automatically initialized to 0?
« Reply #2 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.

Rav

  • Regular Member
  • *
  • Posts: 36
Re: Are XMM registers always automatically initialized to 0?
« Reply #3 on: June 07, 2022, 09:27:40 AM »
Thanks, hutch and jj2007.  I'll go with safety and initialize it.