diff --git a/c-print-array/main.c b/c-print-array/main.c index 50ce282..023adca 100644 --- a/c-print-array/main.c +++ b/c-print-array/main.c @@ -18,17 +18,17 @@ void _start(void) putc(x[2]); /* check with global iterator */ - for (i = 0; i != 3; i++) + for (i = 0; i < 3; i++) putc(x[i]); /* check with local iterator w/o func call */ - for (int j = 0; j != 3; j++) { + for (int j = 0; j < 3; j++) { asm ("lio %0" : : "r"(x[j])); asm ("tyo"); } /* check with local iterator w/ func call */ - for (int j = 0; j != 3; j++) + for (int j = 0; j < 3; j++) putc(x[j]); asm ("hlt"); diff --git a/c-test-comparison/Makefile b/c-test-comparison/Makefile new file mode 100644 index 0000000..49d1aab --- /dev/null +++ b/c-test-comparison/Makefile @@ -0,0 +1 @@ +include ../common/common.mk diff --git a/c-test-comparison/main.c b/c-test-comparison/main.c new file mode 100644 index 0000000..f72170c --- /dev/null +++ b/c-test-comparison/main.c @@ -0,0 +1,54 @@ +static void putc(int); + +void _start(void) +{ + /* TODO: handle sp/fp init better -- separate crt0.S? */ + asm ("law 03000"); + asm ("dac 209"); + asm ("law 04000"); + asm ("dac 208"); + + int x = 30; + int y = 30; + + /* test if `==` works */ + if (x == y) + putc(061); // a + if (x != y) + putc(062); // b + + /* test if `!=` works */ + x = 21; + y = 37; + if (x != y) + putc(063); // c + if (x == y) + putc(064); // d + + /* test if `<` works */ + if (x < y) + putc(065); // e + y = 21; + if (x < y) + putc(066); // f + + /* test if `>` works */ + x = 41; + y = 37; + if (x > y) + putc(067); // g + x = 37; + if (x > y) + putc(070); // h + x = 21; + if (x > y) + putc(071); // i + + asm ("hlt"); + __builtin_unreachable(); +} + +static void putc(int c) { + asm ("lio %0" : : "r"(c)); + asm ("tyo"); +} diff --git a/pdp1-binutils b/pdp1-binutils index e3bae5b..5baae65 160000 --- a/pdp1-binutils +++ b/pdp1-binutils @@ -1 +1 @@ -Subproject commit e3bae5bcbce9aa9e82bd2915985cfb7fca0b4066 +Subproject commit 5baae650c91509be6a417d0a0ccee547a4354640 diff --git a/pdp1-gcc b/pdp1-gcc index 6e88e45..0be8d83 160000 --- a/pdp1-gcc +++ b/pdp1-gcc @@ -1 +1 @@ -Subproject commit 6e88e45863a08ddb13022b23568bb250705f44da +Subproject commit 0be8d834a47ef2b399cdb453a68e6134b4fa2637 diff --git a/tests/test.exp b/tests/test.exp index 304d72f..2eaddc4 100644 --- a/tests/test.exp +++ b/tests/test.exp @@ -28,3 +28,4 @@ run_test "c-print-x" "xx" run_test "c-print-struct" "xyz" run_test "c-print-array" "xyzxyzxyzxyz" run_test "c-print-for-loop" "xxxxyxxx" +run_test "c-test-comparison" "aceg"