Q: How to load a binary image into memory sin simh?

543 views
Skip to first unread message

anton.la...@gmail.com

unread,
Aug 10, 2021, 8:56:49 PM8/10/21
to [PiDP-11]
Hi all,

Can somebody point out how to load a binary image data right into PDP11's memory under simh?

I see in the manuals how I can dump the memory to files (not binary, though, all textual forms), and wondered if there was a way just to populate the memory from a file...
Maybe dump it the same way, too.

There is not much about the dump / load commands in the manual, so I can't exactly figure what they are doing and how to use them, but from what I read, it looks like they might be doing something more than just dumping / loading the memory contents..

Thanks for all the hints,
Anton

Mark Pizzolato

unread,
Aug 11, 2021, 12:40:28 PM8/11/21
to [PiDP-11]
The simh LOAD and DUMP commands are simulator specific.  By that I mean that each different simh simulator defines it's own allowed input formats and any potential subtleties of how these commands operate.  In the PDP11 simulator the simulator code which does both of these things is in the file pdp11_sys.c in the routine sim_load().  It seems that the DUMP command isn't implemented for this simulator (flag argument value = 1).  The comments that describe the single currently supported load binary format says:

/* Binary loader.

   Loader format consists of blocks, optionally preceded, separated, and
   followed by zeroes.  Each block consists of:

        001             ---
        xxx              |
        lo_count         |
        hi_count         |
        lo_origin        > count bytes
        hi_origin        |
        data byte        |
        :                |
        data byte       ---
        checksum

   If the byte count is exactly six, the block is the last on the tape, and
   there is no checksum.  If the origin is not 000001, then the origin is
   the PC at which to start the program.
*/

Apart from using this approach, you could always translate whatever file you want to load into a simulator into a series of simh DEPOSIT commands, and similarly you could extract memory contents with a single (or series of) EXAMINE command.

Anton Lavrentiev

unread,
Aug 11, 2021, 1:44:21 PM8/11/21
to Mark Pizzolato, [PiDP-11]
Thanks.

I understand what the loader format is for PDP11, and what LOAD / DUMP
commands are doing.

Doing a series of EXAMINE commands are rather awkward, especially if
the series is long.

So I was looking for something that can do so in batch, like hypothetically:

DEPOSIT -b @memdump.bin 07777

where "-b" stands for "binary", the DEPOSIT command reads bytes from
memdump.bin and stores them in memory beginning at the location 07777
and up until the end of the file; or, if the range is given, then only
until the range gets populated; or, an error shown, if the file is too
small (in case of a
larger file, a partial load is warned about).

Consequently,

EXAMINE -b @memdump.bin 07777-017776 (or 07777/10000)

stores just the memory dump (again, in binary) into memdump.bin, from
the range 07777-017776 (so it can be later loaded with the DEPOSIT
above, possibly relocated).

Something like that. It'd be awesome if the same DEPOSIT command
could also accept the '-m' switch (and all textual representation
switches, -2, -8, etc of the EXAMINE command)
to populate the memory from the file using assembler mnemonics or text
data (as previously stored by EXAMINE). Obviously for instructions,
the initial address must be always even
(for text, locations output by EXAMINE will be offset with the initial
address given, or loaded at their original locations, if the location
was specified in the command as 0 or omitted at all).

I guess this feature does not exist in the simulator...
> --
> You received this message because you are subscribed to a topic in the Google Groups "[PiDP-11]" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/pidp-11/AZkNx5FUpRY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to pidp-11+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pidp-11/95a5c720-f747-47c1-989e-cdf4c033c96dn%40googlegroups.com.

Mark Pizzolato

unread,
Aug 11, 2021, 2:36:42 PM8/11/21
to [PiDP-11]
>  Doing a series of EXAMINE commands are rather awkward, especially if
> the series is long.

A single EXAMINE command can display an arbitrary range of memory.  This can also be output directly to a file:

sim> EXAMINE @file.txt startaddr:endaddr 

But this will be text.  Adding a -b switch isn't in the cards since the binary data would be simulator and endian dependent .

You may not be aware of the SAVE & RESTORE commands.  SAVE takes a snapshot of complete simulator state (including memory) and puts it into a file.  RESTORE loads a previously SAVEd simulator state.  RESTORE is only 100% reliable when it is executed as the first state/configuration changing command after simulator startup.

I might be possible to add a switch to the EXAMINE command that will produce output which is a series of DEPOSIT commands.  This would be similar to the "SHOW BREAK -C" command which will display a set of breakpoint commands that would define the current breakpoints.

Anton Lavrentiev

unread,
Aug 11, 2021, 4:53:53 PM8/11/21
to Mark Pizzolato, [PiDP-11]
>>  Doing a series of EXAMINE commands are rather awkward, especially if the series is long. 

> A single EXAMINE command can display an arbitrary range of memory

Sorry, I meant to say "DEPOSIT" there...

I guess when I brought up a binary dump, it was assumed to be a guest-machine-native byte stream... No conversion should be required regardless of the host system architecture.

--
You received this message because you are subscribed to the Google Groups "[PiDP-11]" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pidp-11+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pidp-11/1d545fc3-f375-478f-933a-7b52b29aa3edn%40googlegroups.com.

steve...@gmail.com

unread,
Aug 11, 2021, 7:55:27 PM8/11/21
to [PiDP-11]

Anton,
SIMH supports simulated paper tape on the PDP-11 and there's  a DEC standard PDP-11 binary tape loader (Absolute Loader).

You can use one of the PDP-11 text editors to define you binary data in an ASCII format file that includes the memory address and the data. Specifically, create a *.MAC file in RT-11, RSX-11/m, RSTS/E, etc. Then use MACRO-11 to assemble that file into a PDP-11 *.obj binary file. Then export that *.obj binary file into a simulated binary paper tape image on the host. Now, when you want to load the data into memory, you:

1) use the DEC bootstrap paper tape loader (which can be embedded into your SIMH boot script) to read in the Absolute Loader
2) use Absolute Loader to read in your binary paper tape image

Now your binary image data is in your PiDP-11.

It's just like how we used to do it back in the real DEC iron days   :^)

You can even embed the commands to make this happen in a SIMH script file so it's all done automatically.

The DEC Bootstrap paper tape loader and a link to the Absolute Loader paper tape image can be found in this description of PDP-11 Paper Tape Basic:


All you would need to do would be to substitute your binary data paper tape in place of the PDP-11 BASIC paper tape.



Cheers,

-- steve





Clem Cole

unread,
Aug 12, 2021, 11:14:15 AM8/12/21
to steve...@gmail.com, [PiDP-11]
I was thinking the same thing... Anton please check out https://github.com/jwbrase/pdp11-tools

In same, Jon Base has a perl script (abstapewrite.pl) that will generate paper tape load images as Steve describes.

Two other thoughts:

1.) FWIW: there are copies of a DEC Macro 11 compatible assembler and linker for DEC RT11/RSX style OBJ files that ran on Sixth Edition Unix (originally on the Harvard tape from about 1975).  I believe someone updated to work on 2.xBSD (i.e. to use K&R1 C) but I'm not sure it was ever ANSI-fied (K&R2).  I have not looked at it in a few years, but this topic came up before on other lists and I was under the impression it has been used with Jon's tools to prepare things for simh. [If I get a chance I'll try to do some digging offer a pointer, but your search skills are likely as good as mine -- start with the TUHS archives].   This might be a good base for some local tools on a modern host.

2.) Using Jon's script as an example, I would think it would be pretty easy to output a bunch of EXAMINE/DEPOSIT commands into a file and then use Mark's indirection facility @script of simh to suck in those commands.  Yes this is not quite easy as built in command to simh, but you need to prepare to image on the local system anyway, so adding an extra step to convert from DEC OBJ or a.out or the like command to a set of DEPOSIT commands seems does not seem that more heavy.  

--
You received this message because you are subscribed to the Google Groups "[PiDP-11]" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pidp-11+u...@googlegroups.com.

Mark Pizzolato

unread,
Aug 12, 2021, 11:39:46 AM8/12/21
to [PiDP-11]
2.) ... it would be pretty easy to output a bunch of EXAMINE/DEPOSIT commands into a file and then use Mark's indirection facility @script of simh to suck in those commands.

Point taken, but to be a little more precise, the @syntax is specific to capture the output of the EXAMINE command.

Once you've got a file containing any number of simh commands, you "suck in those commands" via "sim> DO filespec"



Clem Cole

unread,
Aug 12, 2021, 11:54:20 AM8/12/21
to Mark Pizzolato, [PiDP-11]
Thanks Mark.. sorry to confuse.  But you got my drift - which is not to mess with simh, do the work in the preparation of the data and use simh's features as they are.

--
You received this message because you are subscribed to the Google Groups "[PiDP-11]" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pidp-11+u...@googlegroups.com.

Warner Losh

unread,
Aug 12, 2021, 11:54:51 AM8/12/21
to Clem Cole, steve...@gmail.com, [PiDP-11]
On Thu, Aug 12, 2021 at 9:14 AM Clem Cole <cl...@ccc.com> wrote:
I was thinking the same thing... Anton please check out https://github.com/jwbrase/pdp11-tools

In same, Jon Base has a perl script (abstapewrite.pl) that will generate paper tape load images as Steve describes.

Two other thoughts:

1.) FWIW: there are copies of a DEC Macro 11 compatible assembler and linker for DEC RT11/RSX style OBJ files that ran on Sixth Edition Unix (originally on the Harvard tape from about 1975).

Yes. There was. This wasn't in V6, but ran on V6 and V7. It was written in macro assembler, though, so you needed a binary to bootstrap it (which was also on the tape). It was used to build the pdp-11 lisp system.
 
I believe someone updated to work on 2.xBSD (i.e. to use K&R1 C) but I'm not sure it was ever ANSI-fied (K&R2).

There's m11 and l11 on the 2.x BSD tapes. It's written in DEC macro assembler. It was originally in the standford lisp directory (since it needed m11 to compile), but was moved elsewhere. This is the same thing as on the usenix 77 tapes and newer, more or less.
 
I have not looked at it in a few years, but this topic came up before on other lists and I was under the impression it has been used with Jon's tools to prepare things for simh. [If I get a chance I'll try to do some digging offer a pointer, but your search skills are likely as good as mine -- start with the TUHS archives].   This might be a good base for some local tools on a modern host.

Since it's not in 'C' you'd have to base this on apout...

You did some work 4 years ago to package up the macro-11 stuff. It lives in Applications/Macro-11 in the TUHS archive. looks like you wrote something to take the output of bind and massage it so it could be linked using ld. It looks to be different than all the other ones, though...

I did find https://github.com/shattered/macro11 which is written in 'C' though.

Warner

Stephen Casner

unread,
Aug 12, 2021, 12:46:31 PM8/12/21
to Warner Losh, [PiDP-11]
On Thu, 12 Aug 2021, Warner Losh wrote:

> I did find https://github.com/shattered/macro11 which is written in 'C'
> though.

That original fork is no longer active. The one more recently
maintained is this:

https://github.com/Rhialto/macro11

-- Steve

Clem Cole

unread,
Aug 12, 2021, 1:52:25 PM8/12/21
to Warner Losh, steve...@gmail.com, [PiDP-11]
On Thu, Aug 12, 2021 at 11:54 AM Warner Losh <i...@bsdimp.com> wrote:


On Thu, Aug 12, 2021 at 9:14 AM Clem Cole <cl...@ccc.com> wrote:
I was thinking the same thing... Anton please check out https://github.com/jwbrase/pdp11-tools

In same, Jon Base has a perl script (abstapewrite.pl) that will generate paper tape load images as Steve describes.

Two other thoughts:

1.) FWIW: there are copies of a DEC Macro 11 compatible assembler and linker for DEC RT11/RSX style OBJ files that ran on Sixth Edition Unix (originally on the Harvard tape from about 1975).

Yes. There was. This wasn't in V6, but ran on V6 and V7. It was written in macro assembler, though, so you needed a binary to bootstrap it (which was also on the tape). It was used to build the pdp-11 lisp system.

Yeah -- that the one originally on the Harvard tape.   I was under the impression it was the original DEC RT11 or DOS11 assembler that somebody hacked.  You're right, it was in assembler not C. It was a v6 binary plus source on the Harvard tape.  It might have run to some extent on v7, until you did a system call like that changed (IIRC stat and seek).   I remember that was something about it's V6-ness had to be done to make it work properly on to V7 -  Which was done at Stanford and was made available on in the 81 USENIX tape.    I also seem to remember the UPitts folks used one of the versions for the support for the dungeon's game running in vax compatibility mode on BSD 4.1.
 
I believe someone updated to work on 2.xBSD (i.e. to use K&R1 C) but I'm not sure it was ever ANSI-fied (K&R2).

There's m11 and l11 on the 2.x BSD tapes. It's written in DEC macro assembler. It was originally in the standford lisp directory (since it needed m11 to compile), but was moved elsewhere. This is the same thing as on the usenix 77 tapes and newer, more or less.
Yeah - that was what I was referring to... the Stanford stuff was based on the earlier work but they did something to make it work on V7. 
 
 Since it's not in 'C' you'd have to base this on apout...
Right -- I stand corrected.
 

You did some work 4 years ago to package up the macro-11 stuff. It lives in Applications/Macro-11 in the TUHS archive. looks like you wrote something to take the output of bind and massage it so it could be linked using ld. It looks to be different than all the other ones, though...
Thanks -- slow cache refill ...  Paul W [Mr. Linker at DEC - wrote the VMS one among other things] gave us some guidance when we were doing what it was at the time [I've forgotten].
 

I did find https://github.com/shattered/macro11 which is written in 'C' though.
Right -- As I this is all (slowly) coming back back.  Needed to search some old emails.    IIRC it has some issues, which I've forgotten maybe - something about RSX OBJ's vs. RT11. Richard Krehbiel wrote it original and number of people have hacked on it since (Joerg Hoppe and Rhialto Seibert).   I'm found a note that said:  Rhialto macro11 in C is Rhialto's version

Clem Cole

unread,
Aug 12, 2021, 1:55:40 PM8/12/21
to Stephen Casner, Warner Losh, [PiDP-11]
On Thu, Aug 12, 2021 at 12:46 PM Stephen Casner <cas...@acm.org> wrote:
That original fork is no longer active.  The one more recently
maintained is this: https://github.com/Rhialto/macro11
Right that is what I have in another email thread. 

Warner Losh

unread,
Aug 12, 2021, 9:33:32 PM8/12/21
to Clem Cole, steve...@gmail.com, [PiDP-11]
On Thu, Aug 12, 2021 at 11:52 AM Clem Cole <cl...@ccc.com> wrote:


On Thu, Aug 12, 2021 at 11:54 AM Warner Losh <i...@bsdimp.com> wrote:


On Thu, Aug 12, 2021 at 9:14 AM Clem Cole <cl...@ccc.com> wrote:
I was thinking the same thing... Anton please check out https://github.com/jwbrase/pdp11-tools

In same, Jon Base has a perl script (abstapewrite.pl) that will generate paper tape load images as Steve describes.

Two other thoughts:

1.) FWIW: there are copies of a DEC Macro 11 compatible assembler and linker for DEC RT11/RSX style OBJ files that ran on Sixth Edition Unix (originally on the Harvard tape from about 1975).

Yes. There was. This wasn't in V6, but ran on V6 and V7. It was written in macro assembler, though, so you needed a binary to bootstrap it (which was also on the tape). It was used to build the pdp-11 lisp system.

Yeah -- that the one originally on the Harvard tape.   I was under the impression it was the original DEC RT11 or DOS11 assembler that somebody hacked.  You're right, it was in assembler not C. It was a v6 binary plus source on the Harvard tape.  It might have run to some extent on v7, until you did a system call like that changed (IIRC stat and seek).   I remember that was something about it's V6-ness had to be done to make it work properly on to V7 -  Which was done at Stanford and was made available on in the 81 USENIX tape.    I also seem to remember the UPitts folks used one of the versions for the support for the dungeon's game running in vax compatibility mode on BSD 4.1.

The 2.79BSD tape (but not the 2BSD tape) has it ported to V7 (or at least living in the v7.src directory).

There were several folks that had variations on this theme, grepping through the USENIX tapes anyway. There's several RT-11 emulators / implementations that use different techniques to run RT11 binaries and/or programs written for RT11 on V6 and V7. There was quite the prolific group. I think the upitt version is the one that wound up in 4.mumble BSD as well, but I've not re-checked right now.

I believe someone updated to work on 2.xBSD (i.e. to use K&R1 C) but I'm not sure it was ever ANSI-fied (K&R2).

There's m11 and l11 on the 2.x BSD tapes. It's written in DEC macro assembler. It was originally in the standford lisp directory (since it needed m11 to compile), but was moved elsewhere. This is the same thing as on the usenix 77 tapes and newer, more or less.
Yeah - that was what I was referring to... the Stanford stuff was based on the earlier work but they did something to make it work on V7. 

Yea.  It's interesting that m11/l11 were ported to the new 2.11BSD system calls, but the Standford LISP was not that I could find...

 Since it's not in 'C' you'd have to base this on apout...
Right -- I stand corrected.
 

You did some work 4 years ago to package up the macro-11 stuff. It lives in Applications/Macro-11 in the TUHS archive. looks like you wrote something to take the output of bind and massage it so it could be linked using ld. It looks to be different than all the other ones, though...
Thanks -- slow cache refill ...  Paul W [Mr. Linker at DEC - wrote the VMS one among other things] gave us some guidance when we were doing what it was at the time [I've forgotten].

It surprised me a bit to find it, but it seems similar, but different, code to what Harvard and Stanford hacked on... I've tried tried to play the usual games of seeing what's newer based on the differences between them.
 
I did find https://github.com/shattered/macro11 which is written in 'C' though.
Right -- As I this is all (slowly) coming back back.  Needed to search some old emails.    IIRC it has some issues, which I've forgotten maybe - something about RSX OBJ's vs. RT11. Richard Krehbiel wrote it original and number of people have hacked on it since (Joerg Hoppe and Rhialto Seibert).   I'm found a note that said:  Rhialto macro11 in C is Rhialto's version

Yea, others have pointed out I found the stale project... I kinda wish that it also had a 'backend' that generated something like 'C' that can run on a more modern machine... But the actual need for that is kinda small I guess...

Warner
Reply all
Reply to author
Forward
0 new messages