C test case convert to hex file

I have tried to run the C test case in gcc compiler. In this test case the loop condition is not working. The c code is below.
The C code is compiled output hex file is connect to the UVM testbench.

int main() {
  unsigned int volatile *ptr,rdata;
  unsigned  int i=0;
  for( i = 0; i <= 31; i++)
   {
//this loop execute only once not perform 32 times
  ptr = (unsigned int*) (SPI_BASE_ADDRESS + 0x24u);
       rdata = *ptr;
   }

In reply to r.srikrishnan:

Can’t possibly help you with this little amount of information. Please provide a minimal example.