diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2017-02-23 11:37:26 -0500 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2017-02-23 11:37:26 -0500 |
commit | 5c35f60732a90c412a9bbec0a50d5b28763c0132 (patch) | |
tree | 1c347b219c46bd6403e435913531c6e6c283fea3 /test | |
parent | 06899861874b50f9abb3a59ed5b56af98f451111 (diff) | |
download | roux-5c35f60732a90c412a9bbec0a50d5b28763c0132.tar.gz |
add simple idiomatic c test
Diffstat (limited to 'test')
-rw-r--r-- | test/strcmp.ssa | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/strcmp.ssa b/test/strcmp.ssa new file mode 100644 index 0000000..4956871 --- /dev/null +++ b/test/strcmp.ssa @@ -0,0 +1,63 @@ +# the C strcmp function generated by scc + +export function w $strcmp(l %s1.3.val,l %s2.5.val) +{ +@.37 + %s1.3 =l alloc8 8 + %s2.5 =l alloc8 8 + storel %s1.3.val,%s1.3 + storel %s2.5.val,%s2.5 + jmp @.5 +@.6 + %.9 =l loadl %s1.3 + %.10 =l add %.9,1 + storel %.10,%s1.3 + %.11 =l loadl %s2.5 + %.12 =l add %.11,1 + storel %.12,%s2.5 +@.5 + %.15 =l loadl %s1.3 + %.16 =w loadsb %.15 + %.17 =w extsb %.16 + %.18 =w cnew %.17,0 + jnz %.18,@.14,@.8 +@.14 + %.19 =l loadl %s2.5 + %.20 =w loadsb %.19 + %.21 =w extsb %.20 + %.22 =w cnew %.21,0 + jnz %.22,@.13,@.8 +@.13 + %.23 =l loadl %s1.3 + %.24 =w loadsb %.23 + %.25 =w extsb %.24 + %.26 =l loadl %s2.5 + %.27 =w loadsb %.26 + %.28 =w extsb %.27 + %.29 =w ceqw %.25,%.28 + jnz %.29,@.6,@.8 +@.8 +@.7 + %.30 =l loadl %s1.3 + %.31 =w loadub %.30 + %.32 =w extub %.31 + %.33 =l loadl %s2.5 + %.34 =w loadub %.33 + %.35 =w extub %.34 + %.36 =w sub %.32,%.35 + ret %.36 +} + +# >>> driver +# extern int strcmp(const char *, const char *); +# int main() { +# char a[] = "Hello world"; +# return !( +# strcmp(a, a) == 0 && +# strcmp("aaa", "aab") < 0 && +# strcmp("..cnn", "..bbc") > 0 && +# strcmp(a, "Hellp ...") < 0 && +# strcmp(a, "Hello vorld") > 0 +# ); +# } +# <<< |