From 4e05c963644cd353cab56b4b78ba025656643086 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] binutils: support relocs in `law` for array iterators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filip KokosiƄski --- c-print-array/main.c | 22 ++++++++++++++++++++-- common/common.ld | 4 ++-- pdp1-binutils | 2 +- tests/test.exp | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/c-print-array/main.c b/c-print-array/main.c index 6f95439..50ce282 100644 --- a/c-print-array/main.c +++ b/c-print-array/main.c @@ -2,17 +2,35 @@ 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/o func call */ + 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++) + putc(x[j]); + asm ("hlt"); __builtin_unreachable(); } diff --git a/common/common.ld b/common/common.ld index 10426b3..6f9318d 100644 --- a/common/common.ld +++ b/common/common.ld @@ -8,12 +8,12 @@ MEMORY SECTIONS { - .text : + .text 0x12c : { *(.text) } > ram - .data 0x400 : + .data : { *(.data) } > ram diff --git a/pdp1-binutils b/pdp1-binutils index a6982b8..aec2e97 160000 --- a/pdp1-binutils +++ b/pdp1-binutils @@ -1 +1 @@ -Subproject commit a6982b84374a15d1273871f0dc21007a5c77d251 +Subproject commit aec2e975da83e60b47a50f4e99d866860a468d0f diff --git a/tests/test.exp b/tests/test.exp index e8caf86..304d72f 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" "xyzxyzxyzxyz" run_test "c-print-for-loop" "xxxxyxxx"