1 #include <stdlib.h> 2 #include <assert.h> 3 #include <stdint.h> 4 5 static void test_chrl(void) 6 { 7 uint32_t program_mask, cc; 8 9 asm volatile ( 10 ".pushsection .rodata\n" 11 "0:\n\t" 12 ".short 1, 0x8000\n\t" 13 ".popsection\n\t" 14 15 "chrl %[r], 0b\n\t" 16 "ipm %[program_mask]\n" 17 : [program_mask] "=r" (program_mask) 18 : [r] "r" (1) 19 ); 20 21 cc = program_mask >> 28; 22 assert(!cc); 23 24 asm volatile ( 25 ".pushsection .rodata\n" 26 "0:\n\t" 27 ".short -1, 0x8000\n\t" 28 ".popsection\n\t" 29 30 "chrl %[r], 0b\n\t" 31 "ipm %[program_mask]\n" 32 : [program_mask] "=r" (program_mask) 33 : [r] "r" (-1) 34 ); 35 36 cc = program_mask >> 28; 37 assert(!cc); 38 } 39 40 static void test_cghrl(void) 41 { 42 uint32_t program_mask, cc; 43 44 asm volatile ( 45 ".pushsection .rodata\n" 46 "0:\n\t" 47 ".short 1, 0x8000, 0, 0\n\t" 48 ".popsection\n\t" 49 50 "cghrl %[r], 0b\n\t" 51 "ipm %[program_mask]\n" 52 : [program_mask] "=r" (program_mask) 53 : [r] "r" (1L) 54 ); 55 56 cc = program_mask >> 28; 57 assert(!cc); 58 59 asm volatile ( 60 ".pushsection .rodata\n" 61 "0:\n\t" 62 ".short -1, 0x8000, 0, 0\n\t" 63 ".popsection\n\t" 64 65 "cghrl %[r], 0b\n\t" 66 "ipm %[program_mask]\n" 67 : [program_mask] "=r" (program_mask) 68 : [r] "r" (-1L) 69 ); 70 71 cc = program_mask >> 28; 72 assert(!cc); 73 } 74 75 int main(void) 76 { 77 test_chrl(); 78 test_cghrl(); 79 return EXIT_SUCCESS; 80 } 81