strcmp.ssa (1173B)
1 # the C strcmp function generated by scc 2 3 export function w $strcmp(l %s1.3.val,l %s2.5.val) 4 { 5 @.37 6 %s1.3 =l alloc8 8 7 %s2.5 =l alloc8 8 8 storel %s1.3.val,%s1.3 9 storel %s2.5.val,%s2.5 10 jmp @.5 11 @.6 12 %.9 =l loadl %s1.3 13 %.10 =l add %.9,1 14 storel %.10,%s1.3 15 %.11 =l loadl %s2.5 16 %.12 =l add %.11,1 17 storel %.12,%s2.5 18 @.5 19 %.15 =l loadl %s1.3 20 %.16 =w loadsb %.15 21 %.17 =w extsb %.16 22 %.18 =w cnew %.17,0 23 jnz %.18,@.14,@.8 24 @.14 25 %.19 =l loadl %s2.5 26 %.20 =w loadsb %.19 27 %.21 =w extsb %.20 28 %.22 =w cnew %.21,0 29 jnz %.22,@.13,@.8 30 @.13 31 %.23 =l loadl %s1.3 32 %.24 =w loadsb %.23 33 %.25 =w extsb %.24 34 %.26 =l loadl %s2.5 35 %.27 =w loadsb %.26 36 %.28 =w extsb %.27 37 %.29 =w ceqw %.25,%.28 38 jnz %.29,@.6,@.8 39 @.8 40 @.7 41 %.30 =l loadl %s1.3 42 %.31 =w loadub %.30 43 %.32 =w extub %.31 44 %.33 =l loadl %s2.5 45 %.34 =w loadub %.33 46 %.35 =w extub %.34 47 %.36 =w sub %.32,%.35 48 ret %.36 49 } 50 51 # >>> driver 52 # extern int strcmp(const char *, const char *); 53 # int main() { 54 # char a[] = "Hello world"; 55 # return !( 56 # strcmp(a, a) == 0 && 57 # strcmp("aaa", "aab") < 0 && 58 # strcmp("..cnn", "..bbc") > 0 && 59 # strcmp(a, "Hellp ...") < 0 && 60 # strcmp(a, "Hello vorld") > 0 61 # ); 62 # } 63 # <<<