mem_store_narrow.c (688B)
1 /* mem: store narrow values into an array of bytes and shorts, then read them 2 * back. Forces strb/strh (the store side of the narrow forms) distinct from the 3 * load-side cases, plus ldrb/ldrh on read-back. Exit: 42. */ 4 int test_main(void) { 5 unsigned char bytes[4]; 6 unsigned short halves[3]; 7 bytes[0] = 1; 8 bytes[1] = 2; 9 bytes[2] = 3; 10 bytes[3] = 4; /* strb: sum 10 */ 11 halves[0] = 100; 12 halves[1] = 200; 13 halves[2] = 300; /* strh */ 14 volatile int k = 1; 15 unsigned int bsum = (unsigned int)bytes[0] + bytes[1] + bytes[2] + bytes[3]; 16 unsigned int hsel = halves[k]; /* ldrh -> 200 */ 17 /* bsum=10, hsel=200; 10 + (200 - 168) = 42 */ 18 return (int)(bsum + (hsel - 168)); 19 }