Skip to content

Commit

Permalink
wip: support array iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
fkokosinski committed Jun 8, 2024
1 parent f732099 commit 18511de
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion c-print-array/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion pdp1-binutils
2 changes: 1 addition & 1 deletion tests/test.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 18511de

Please sign in to comment.