How compiler implements static variables are initialized only once

The amount of static local
xor eax, eax // clears the eax
mov al, mem // mem used to mark whether static variables are initialized, the initialization of an uninitialized is 0
and eax, and an operation // 1
Test eax, EAX
JNZ XXXX where XXXX represents skip // initialize
MOV Cl, MEM
or Cl, or 1 // 1 operation, is first initialized to set a 
MOV MEM, Cl
initialize static variable
XXXX:
other codes
. . . .
ret

Guess you like

Origin www.cnblogs.com/xiangtingshen/p/11371599.html