kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

mem_u32_zext.c (576B)


      1 /* mem: an unsigned 32-bit load that feeds a 64-bit computation. `ldr w`
      2  * zero-extends the upper 32 bits implicitly, so no separate uxtw is needed; the
      3  * round-trip must keep the 32-bit (w) form rather than promoting to `ldr x`.
      4  * The stored value has its top bit set to make the zero-extension observable.
      5  *   v = 0x8000000B (2147483659u); v & 0xFF = 0x0B = 11 ; 11 + 31 = 42 */
      6 int test_main(void) {
      7   volatile unsigned int v = 0x8000000Bu;
      8   unsigned long w = v;           /* ldr w zero-extends */
      9   unsigned long low = w & 0xFFu; /* 11 */
     10   return (int)(low + 31);
     11 }