mem_signed.c (727B)
1 /* mem: signed narrow values stored to and reloaded from volatile stack slots, 2 * then sign-extended into a 64-bit chain. The narrow stores use the unscaled 3 * forms `sturb`/`sturh`/`stur w`; the reloads use `ldurb`/`ldurh`/`ldur` and 4 * the cast to long sign-extends the loaded value in-register. The negative 5 * magnitudes must survive sign extension; a lost sign would change the exit. 6 * c = -3 (sturb/ldurb) 7 * s = -7 (sturh/ldurh) 8 * i = -8 (stur w/ldur w, widened to long) 9 * sum = -3 + -7 + -8 = -18 ; 60 + (-18) = 42 */ 10 int test_main(void) { 11 volatile signed char c = -3; 12 volatile short s = -7; 13 volatile int i = -8; 14 long sum = (long)c + (long)s + (long)i; /* -18 */ 15 return (int)(sum + 60); 16 }