Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Global asm variables

remko
Beginner
344 Views
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
0 Kudos
0 Replies
Reply