commit fbee480f2ed31616583cef5735df07e694ff9c5c parent 31b19a21b8ac2a8ce67864794af88241df7674a6 Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu> Date: Mon, 12 Oct 2015 14:32:48 -0400 add one small test Diffstat:
| A | minic/mcc | | | 12 | ++++++++++++ |
| A | minic/test/prime.c | | | 27 | +++++++++++++++++++++++++++ |
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/minic/mcc b/minic/mcc @@ -0,0 +1,12 @@ +#!/bin/sh + +SRC=$1 + +if [ -z "$SRC" ]; then + echo "usage: ./mcc file.c" 1>&2 + exit 1 +fi + +rm -f /tmp/minic.s +./minic < $SRC | ../lisc/lisc - > /tmp/minic.s +[ -f /tmp/minic.s ] && cc /tmp/minic.s diff --git a/minic/test/prime.c b/minic/test/prime.c @@ -0,0 +1,27 @@ +main() { + int n; + int t; + int c; + int p; + + c = 0; + n = 2; + while (n < 1000) { + if (c % 10 == 0) + if (c != 0) + printf("\n"); + t = 2; + p = 1; + while (t*t <= n) { + if (n % t == 0) + p = 0; + t = t + 2; + } + if (p) { + printf("%4d ", n); + c++; + } + n = n + 2; + } + printf("\n"); +}