V
V
Vusal Guseynov2015-11-12 17:37:24
assembler
Vusal Guseynov, 2015-11-12 17:37:24

What does this function do?

Hello, what is the purpose of this function? Thank you!

int asmFunction(void)
{
  static int internalValue = 1;

#ifdef __GNUC__
  __asm__("movl %0, %%eax\n\t"
    "add %%eax, %0"
    : "=r" (internalValue)
    : "r" (internalValue));
#elif _MSC_VER
  _asm {
    mov eax, internalValue
      add internalValue, eax
  };
#endif

  return internalValue;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Korotkiy, 2015-11-12
@vusalg

Returns powers of two (stateful):
2, 4, 8, 16, 32, 64, ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question