binutils 2.45 from tarball hosted on Fedora 42 configured with : ./configure --prefix=/opt/pdp11 --target=pdp11-aout --enable-languages=c,c++ --host=x86_64-linux-gnu --build=x86_64-linux-gnu built and installed into /opt/pdp11
The attaches .s file when assembled produces the following (from the listing): 58 .globl _start > 59 > 60 f600 4444 _start: .ascii "DD" // device code > (reversed) > 61 > 62 f602 0400 .word last - . // offset to next boot > header > 63 > 64 f604 00000000 dd0n: sec // boot std csr, unit > zero, no diags > 64 0000B100 > 65 f60c C0150000 dd0d: mov $0, r0 // boot std csr, unit > zero, with diags > 66 f610 C11540FD ddNr: mov $ddcsr, r1 // boot std csr, > unit <R0> > 67 f614 C411 ddNb: mov pc, r4 // boot csr <R1>, > unit <R0> > 68 f616 0387 bcs go // no diags > 69 f618 0000 halt // diags requested: > halt > 70 > SEC (set carry flag) correctly produces 00B1 (0261 octal). But it's preceded by three zero words. It's actually trying to output a 64-bit integer for .word prior (the link word). This is not just a listing artifact; they appear in the output as well. If I remove the .word the spurious zeroes go away: 58 .globl _start > 59 > 60 f600 4444 _start: .ascii "DD" // device code > (reversed) > 61 > 62 //.word last - . // offset to next boot > header > 63 > 64 f602 B100 dd0n: sec // boot std csr, unit > zero, no diags > 65 f604 C0150000 dd0d: mov $0, r0 // boot std csr, unit > zero, with diags > 66 f608 C11540FD ddNr: mov $ddcsr, r1 // boot std csr, > unit <R0> > 67 f60c C411 ddNb: mov pc, r4 // boot csr <R1>, > unit <R0> > 68 f60e 0387 bcs go // no diags > 69 f610 0000 halt // diags requested: > halt I've attached the source file and a Makefile... Later in the file, .word outputs 16-bit values correctly: 68 f60e 0387 bcs go // no diags > 69 f610 0000 halt // diags requested: > halt > 70 > 71 // -------------------------------------------------- > 72 > 73 //. = _start + 024 > 74 > 75 f612 00F6 .word 0173000 // prom start > addess @ 24 > 76 f614 E000 .word 0340 // and priority > level @ 26 So this appears to be either because it's first thing in the file, or because the expression is backfilled after assembling the whole file. Same thing happens with .short instead .word. Workaround: 58 .globl _start > 59 > 60 f600 4444 _start: .ascii "DD" // device code > (reversed) > 61 > 62 size = last - . > 63 f602 7E00 .word size // offset to next boot > header > 64 > 65 f604 B100 dd0n: sec // boot std csr, unit > zero, no diags > 66 f606 C0150000 dd0d: mov $0, r0 // boot std csr, unit > zero, with diags Now I notice the size calculated in the erroneous output is incorrect (007E is correct, which with the two ASCII bytes becomes 128 bytes). -Jan.
23-765b9.s
Description: Binary data
link.lds
Description: Binary data
Makefile
Description: Binary data
