Skip to content

Commit

Permalink
binutils: support relocs in law for array iterators
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Kokosiński <[email protected]>
  • Loading branch information
fkokosinski committed Jun 8, 2024
1 parent f732099 commit d9108b1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
22 changes: 20 additions & 2 deletions c-print-array/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions common/common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ MEMORY

SECTIONS
{
.text :
.text 0x12c :
{
*(.text)
} > ram

.data 0x400 :
.data :
{
*(.data)
} > ram
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" "xyzxyzxyzxyz"
run_test "c-print-for-loop" "xxxxyxxx"

0 comments on commit d9108b1

Please sign in to comment.