From 18511de66c8b3f5e674bd10a0c9e036119f3e538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Kokosi=C5=84ski?= Date: Sat, 8 Jun 2024 17:16:39 +0200 Subject: [PATCH] wip: support array iterators --- c-print-array/main.c | 16 +++++++++++++++- pdp1-binutils | 2 +- tests/test.exp | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/c-print-array/main.c b/c-print-array/main.c index 6f95439..cbab525 100644 --- a/c-print-array/main.c +++ b/c-print-array/main.c @@ -2,17 +2,31 @@ static void putc(int); static int get_char(int); static int x[] = {027, 030, 031}; +static int i = 0; void _start(void) { - asm ("law 04000"); + /* TODO: handle sp/fp init better -- separate crt0.S? */ + asm ("law 03000"); asm ("dac 209"); + asm ("law 04000"); asm ("dac 208"); + /* check with no iterators */ putc(x[0]); putc(x[1]); putc(x[2]); + /* check with global iterator */ + for (i = 0; i != 3; i++) + putc(x[i]); + + /* check with local iterator w/ func call */ + for (int j = 0; j != 3; j++) + putc(x[j]); + + /* TODO: check with local iterator w/o func call */ + asm ("hlt"); __builtin_unreachable(); } diff --git a/pdp1-binutils b/pdp1-binutils index a6982b8..af1918e 160000 --- a/pdp1-binutils +++ b/pdp1-binutils @@ -1 +1 @@ -Subproject commit a6982b84374a15d1273871f0dc21007a5c77d251 +Subproject commit af1918eda2d5d0660b362ea6e45f31f1dba441b5 diff --git a/tests/test.exp b/tests/test.exp index e8caf86..6758759 100644 --- a/tests/test.exp +++ b/tests/test.exp @@ -26,5 +26,5 @@ run_test "asm-print-x" "x" run_test "asm-hello-world" "hello, world" run_test "c-print-x" "xx" run_test "c-print-struct" "xyz" -run_test "c-print-array" "xyz" +run_test "c-print-array" "xyzxyzxyz" run_test "c-print-for-loop" "xxxxyxxx"