1#include "test.h" 2char buffer[24] ="0123456789abcdefghijklmn"; 3char *buflong = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.,}[]" 4 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.,}[]" 5 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.,}[]" 6 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.,}[]" 7 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.,}[]" 8 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.,}[]" 9 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS%UVWXYZ0123456789_.,}[]"; 10 11static char * srst3(char *__next, char *__start, char __what, int *__cc) 12{ 13 register unsigned long what asm ("0") = __what; 14 register char *next asm ("2") = __next; 15 register char *start asm ("4") = __start; 16 int cc; 17 18 asm volatile( "0: srst 2,4\n" 19 "jo 0b\n" 20 "ipm %2\n" 21 "srl %2,28\n" 22 :"+d" (start), "+d" (next), "=d" (cc) :"d" (what): "cc"); 23 *__cc = cc; 24 return next; 25} 26 27static char * srst2(char *__start, char __what, int *__cc) 28{ 29 register unsigned long what asm ("0") = __what; 30 register char *start asm ("4") = __start; 31 int cc; 32 33 asm volatile( "0: srst 0,4\n" 34 "jo 0b\n" 35 "ipm %2\n" 36 "srl %2,28\n" 37 :"+d" (start), "+d" (what), "=d" (cc) :: "cc"); 38 *__cc = cc; 39 return (char *) what; 40} 41 42int main() 43{ 44 char *buf; 45 int cc; 46 47 48 /* len=0 and start== next should not fault */ 49 srst3((char *)0x12345678,(char *)0x12345678,'0', &cc); 50 printf("(cc=%d)\n", cc); 51 52 buf = srst3(&buffer[23], &buffer[23], '0', &cc); 53 dump_field(buf, 1); 54 printf("(cc=%d)\n", cc); 55 56 buf = srst3(&buffer[23], &buffer[0], '0', &cc); 57 dump_field(buf, 1); 58 printf("(cc=%d)\n", cc); 59 60 buf = srst3(&buffer[23], &buffer[0], 'a', &cc); 61 dump_field(buf, 1); 62 printf("(cc=%d)\n", cc); 63 64 buf = srst3(&buffer[23], &buffer[0], 'm', &cc); 65 dump_field(buf, 1); 66 printf("(cc=%d)\n", cc); 67 68 buf = srst3(&buffer[23], &buffer[0], 'n', &cc); 69 dump_field(buf, 1); 70 printf("(cc=%d)\n", cc); 71 72 buf = srst2(&buffer[0], '0', &cc); 73 dump_field(buf, 1); 74 printf("(cc=%d)\n", cc); 75 76 buf = srst2(&buffer[0], 'a', &cc); 77 dump_field(buf, 1); 78 printf("(cc=%d)\n", cc); 79 80 buf = srst2(&buffer[0], 'm', &cc); 81 dump_field(buf, 1); 82 printf("(cc=%d)\n", cc); 83 84 buf = srst2(&buffer[0], 'n', &cc); 85 dump_field(buf, 1); 86 printf("(cc=%d)\n", cc); 87 88 buf = srst3(buflong + 469, buflong, '%', &cc); 89 dump_field(buf, 1); 90 printf("(cc=%d)\n", cc); 91 return 0; 92} 93 94