Global asm variables

Global asm variables

Hi,

I have the following piece of code:

  register int* glob asm("bx");
  int main() {
    glob = (int*) malloc(2*sizeof(int));
    printf("%p
",glob);
    glob += 1;
    printf("%p
",glob);
    return 0;
  } 

When compiling with GCC, this gives me the expected resulting output:

  0x8049608
  0x804960c 

However, with ICC (7.0), i get:

  0x804b848
  0x804b848

Looking at the assembly code generated by ICC, i notice that ebx is first moved to eax, and eax is incremented. Nothing is done further, so the contents of eax gets lost. Is this a bug in ICC ?

thanks,
Remko

1 envío / 0 nuevos
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.