The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] New project to recreate the B compiler for the PDP-11
@ 2019-04-23 22:11 Robert Swierczek
  2019-04-23 22:47 ` Angelo Papenhoff
  2019-04-23 23:12 ` Angelo Papenhoff
  0 siblings, 2 replies; 4+ messages in thread
From: Robert Swierczek @ 2019-04-23 22:11 UTC (permalink / raw)
  To: TUHS main list

I just started a project to recreate the B compiler for the PDP-11 as
authentically as possible, given the few fragments that remain and
some educated guesswork.  It should be fun (for various definitions of
fun).

Here is the repository  https://github.com/rswier/pdp11-B

I have borrowed some tools from Warren's
https://github.com/DoctorWkt/unix-jun72

I have made a good start at reverse engineering the B run time library
in /usr/lib/libb.a.  I have tried to make the source match the same
style as the earliest C library found on the last1120c-bits tape.  The
remaining functions in libb.a include printf and printn which appear
to be written in B.  This should provide more clues needed to create
the compiler.

I am also tackling the dis-assembly of the threaded code interpreter
/usr/lib/bilib.a (which at the moment is a big mess on my hard-drive)

Later steps will include creating the B compiler itself by carefully
pruning down the last1120c C compiler.  The fun here will be to
boot-strap the B compiler without help from any existing modern
compilers.  I think TMG will come into play to make that happen.

All are welcome to contribute!

Rob

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [TUHS] New project to recreate the B compiler for the PDP-11
  2019-04-23 22:11 [TUHS] New project to recreate the B compiler for the PDP-11 Robert Swierczek
@ 2019-04-23 22:47 ` Angelo Papenhoff
  2019-04-23 23:36   ` Robert Swierczek
  2019-04-23 23:12 ` Angelo Papenhoff
  1 sibling, 1 reply; 4+ messages in thread
From: Angelo Papenhoff @ 2019-04-23 22:47 UTC (permalink / raw)
  To: Robert Swierczek; +Cc: TUHS main list

Nice project. I wanted to do something like this too at some point.
I documented B for the PDP-7 and -11 here:
http://squoze.net/B/
I have a partially working, sort of portable B compiler (in C) here:
http://squoze.net/B/b.zip

Since B is so damn portable I wanted to target a bunch of architectures.
Started amd64 and pdp-8 but then other things got in a way (a VCF) and
my attention shifted.

best,
Angelo

On 23/04/19, Robert Swierczek wrote:
> I just started a project to recreate the B compiler for the PDP-11 as
> authentically as possible, given the few fragments that remain and
> some educated guesswork.  It should be fun (for various definitions of
> fun).
> 
> Here is the repository  https://github.com/rswier/pdp11-B
> 
> I have borrowed some tools from Warren's
> https://github.com/DoctorWkt/unix-jun72
> 
> I have made a good start at reverse engineering the B run time library
> in /usr/lib/libb.a.  I have tried to make the source match the same
> style as the earliest C library found on the last1120c-bits tape.  The
> remaining functions in libb.a include printf and printn which appear
> to be written in B.  This should provide more clues needed to create
> the compiler.
> 
> I am also tackling the dis-assembly of the threaded code interpreter
> /usr/lib/bilib.a (which at the moment is a big mess on my hard-drive)
> 
> Later steps will include creating the B compiler itself by carefully
> pruning down the last1120c C compiler.  The fun here will be to
> boot-strap the B compiler without help from any existing modern
> compilers.  I think TMG will come into play to make that happen.
> 
> All are welcome to contribute!
> 
> Rob

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [TUHS] New project to recreate the B compiler for the PDP-11
  2019-04-23 22:11 [TUHS] New project to recreate the B compiler for the PDP-11 Robert Swierczek
  2019-04-23 22:47 ` Angelo Papenhoff
@ 2019-04-23 23:12 ` Angelo Papenhoff
  1 sibling, 0 replies; 4+ messages in thread
From: Angelo Papenhoff @ 2019-04-23 23:12 UTC (permalink / raw)
  To: Robert Swierczek; +Cc: TUHS main list

Forgot to mention something on my site but I think I should bring it up
on the list anyway because I think it's a very neat hack
(by dmr, as scj told me):

B expects word addresses but the linker can't generate those on a byte
addressed machine. So all addresses have to be patched before calling
main at runtime. How can you do that if you link multiple files?
You will notice that the disassembled B files printn.s and printf.s
start with 'jmp 9f' and end with 'jsr r5,chain; 0'
Unfortunately we don't have the chain function but the way this
must work is the B runtime falls off into the first B object file,
which jumps to the end, calls a function to patch all addresses in
the current file, and falls off at the end itself into the next file.
The last file in the link has to be a B runtime file as well to end
the chain.

Note that this doesn't work with printn and printf because they're
inside bilib, but they have no addresses that need patching anyway,
guess you have to be careful.

aap

On 23/04/19, Robert Swierczek wrote:
> I just started a project to recreate the B compiler for the PDP-11 as
> authentically as possible, given the few fragments that remain and
> some educated guesswork.  It should be fun (for various definitions of
> fun).
> 
> Here is the repository  https://github.com/rswier/pdp11-B
> 
> I have borrowed some tools from Warren's
> https://github.com/DoctorWkt/unix-jun72
> 
> I have made a good start at reverse engineering the B run time library
> in /usr/lib/libb.a.  I have tried to make the source match the same
> style as the earliest C library found on the last1120c-bits tape.  The
> remaining functions in libb.a include printf and printn which appear
> to be written in B.  This should provide more clues needed to create
> the compiler.
> 
> I am also tackling the dis-assembly of the threaded code interpreter
> /usr/lib/bilib.a (which at the moment is a big mess on my hard-drive)
> 
> Later steps will include creating the B compiler itself by carefully
> pruning down the last1120c C compiler.  The fun here will be to
> boot-strap the B compiler without help from any existing modern
> compilers.  I think TMG will come into play to make that happen.
> 
> All are welcome to contribute!
> 
> Rob

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [TUHS] New project to recreate the B compiler for the PDP-11
  2019-04-23 22:47 ` Angelo Papenhoff
@ 2019-04-23 23:36   ` Robert Swierczek
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Swierczek @ 2019-04-23 23:36 UTC (permalink / raw)
  To: Angelo Papenhoff; +Cc: TUHS main list

> I documented B for the PDP-7 and -11 here: http://squoze.net/B/

Fantastic, it looks like you have solved the libb and bilib reverse engineering!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-23 23:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23 22:11 [TUHS] New project to recreate the B compiler for the PDP-11 Robert Swierczek
2019-04-23 22:47 ` Angelo Papenhoff
2019-04-23 23:36   ` Robert Swierczek
2019-04-23 23:12 ` Angelo Papenhoff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).