-1

which c code will gets changed to rlwinm power PC assembly instruciton??

This is the snapshot of objdump..

   if(!pool || pool->maxPoolSize > SEQ_MODULUS ) /* Invalid mask or pointer is null */

   29ccc:       41 82 00 dc     beq-    29da8 <asGetSdBuf+0x108>
   29cd0:       80 c3 00 08     lwz     r6,8(r3)
   29cd4:       3c 00 00 ff     lis     r0,255
   29cd8:       60 00 ff ff     ori     r0,r0,65535
   29cdc:       7f 86 00 40     cmplw   cr7,r6,r0
   29ce0:       41 9d 00 78     bgt-    cr7,29d58 <asGetSdBuf+0xb8>

   ind = pool->maxPoolSize & idx;

   /* there are free sdBufs, get one */

   sdBuf = pool->sdBufs + ind;

   29ce4:       81 63 00 10     lwz     r11,16(r3)
   29ce8:       7c 80 30 38     and     r0,r4,r6
   29cec:       54 04 20 36     **rlwinm  r4,r0,4,0,27**

   if(!sdBuf) /* check if sdBuf pointer is null */

   29cf0:       7f eb 22 15     add.    r31,r11,r4
   29cf4:       41 82 00 fc     beq-    29df0 <asGetSdBuf+0x150>
   }

Thanks,

wallyk
  • 56,922
  • 16
  • 83
  • 148
user2185454
  • 27
  • 1
  • 1
  • 5

2 Answers2

2

rlwinm r4,r0,4,0,27

means

r4 = (r0 << 4) & 0xFFFFFFF0

(actually it's a rotate and not a shift, but it doesn't matter here because of the mask).

So it's multiplying something by 16, which on the next line is added to r11. My guess is that this corresponds to

pool->sdBufs + ind

I.e. ind is scaled to match the element size of the data pool->sdBufs points to.

Michael
  • 57,169
  • 9
  • 80
  • 125
1

It appears to me that you already know, for the most part. However:

lwz    r11,16(r3)   // tmp1 = pool->sdBufs
and    r0,r4,r6     // ind  = pool->maxPoolSize & idx
rlwinm r4,r0,4,0,27 // tmp2 = ind*sizeof(*pool->sdBufs)
add.   r31,r11,r4   // sdBuf = tmp1 + tmp2;
Stephen Canon
  • 103,815
  • 19
  • 183
  • 269