Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Kokosiński <filip.kokosinski@gmail.com>
  • Loading branch information
fkokosinski committed Jun 14, 2024
1 parent e1ed6df commit bb84cb1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
1 change: 1 addition & 0 deletions c-test-arith/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../common/common.mk
33 changes: 33 additions & 0 deletions c-test-arith/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
static void putc(int);

int x;
int y;
int z;

void _start(void)
{
/* TODO: handle sp/fp init better -- separate crt0.S? */
asm ("law 03000");
asm ("dac 209");
asm ("law 04000");
asm ("dac 208");

x = 21;
y = 37;

z = x << 3;
if (z == 168)
putc(027);

z = y >> 3;
if (z == 4)
putc(027);

asm ("hlt");
__builtin_unreachable();
}

static void putc(int c) {
asm ("lio %0" : : "r"(c));
asm ("tyo");
}
15 changes: 8 additions & 7 deletions tests/test.exp
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ proc run_test { demo_name expected_output } {
spawn "pdp1"
send "attach ptr $demo_name/main.rim\n"
expect {
"PTR: creating new file" { fail "Didn't find the RIM tape file\n" }
"sim>" { pass "Successfully loaded the RIM tape file\n" }
default { fail "Test failed unexpectedly\n" }
"PTR: creating new file" { fail "$demo_name: Didn't find the RIM tape file\n" }
"sim>" { pass "$demo_name: Successfully loaded the RIM tape file\n" }
default { fail "$demo_name: Test failed unexpectedly\n" }
}

send "boot ptr\n"
expect {
"$expected_output" { pass "Encountered expected output\n" }
default { fail "Didn't encounter expected output\n" }
"$expected_output" { pass "$demo_name: Encountered expected output\n" }
default { fail "$demo_name: Didn't encounter expected output\n" }
}
expect {
-re "HALT instruction,.*" { pass "Program finished running normally\n" }
default { fail "Program halted unexpectedly\n" }
-re "HALT instruction,.*" { pass "$demo_name: Program finished running normally\n" }
default { fail "$demo_name: Program halted unexpectedly\n" }
}

send "quit\n"
Expand All @@ -29,3 +29,4 @@ 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"
run_test "c-test-arith" "xx"

0 comments on commit bb84cb1

Please sign in to comment.