Blinky source code

Skip to first unread message

Fabrizio Furnari

unread,
Apr 15, 2022, 7:13:50 AM4/15/22
to pid...@googlegroups.com
Hi all,
I've built my PiDP-11 last week and now I'm in full learning mode, I've followed some tutorials on how to write some assembly code for PDP-11 (SIMH) and also how to do some cross-compilation for C programs on Linux and feed them.
Now I'd like to play a little with the blinkenlights :) maybe writing something simple to change the led patterns like the Blinky or Idleds programs.

Anyone has the source code of these two to study and learn something new?

Thanks!

F

Neil Higgins

unread,
Apr 16, 2022, 10:35:53 PM4/16/22
to [PiDP-11]
Hi Fabrizio. It’s not clear whether you want to drive the lights using a PDP-11 program on the simulated PDP-11, or using a Raspberry Pi program on the underlying Raspberry Pi (without SIMH running). In the first case, you will ned to access the relevant registers in the PDP-11 address space (sorry I don’t know the details but a look at a PDP-11 manual should give you the necessary information). In the second case you will need access to the PDP-11 schematic and information about how to program the Raspberry Pi GPIOs. I have done this in a Python program (which runs on Raspberry Pi OS) which you can find by searching this Group for “stand-alone test program”. Cheers, Neil P.S. I developed the program on a Raspberry Pi 2 or 3 - I’m not sure if it will run unmodified on a Raspberry Pi 4.

Fabrizio Furnari

unread,
Apr 17, 2022, 6:46:05 AM4/17/22
to Neil Higgins, [PiDP-11]
Hi Neil, first thanks for your answer, I've downloaded your python script attached to the thread you mentioned and now I'm studying it!

To better clarify: I'm a total beginner both in ASM and PDP-11 architecture so the idea would be to write a simple C program that uses the PDP-11 registers to do some blinky stuff, compile it for PDP-11 and run it maybe under BSD (is the OS I know better among the PDP-11 ones).

I'd like also to learn how to detect (in BSD, for example) to react to interrupts like the various button presses...

Thanks again, this group is an invaluable source of information...

F
--
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/4dc283c5-6e4e-4a95-b242-ad86975b2299n%40googlegroups.com.


Johnny Billquist

unread,
Apr 17, 2022, 6:54:25 AM4/17/22
to pid...@googlegroups.com
Fabrizio. In general, handling low level stuff like interrupts is not
something you do in user programs. That is the domain of the OS, so you
need to understand how to write device drivers. This is a fairly complex
topic, and if you don't have much experience, you can expect that this
will take you some time to understand and work through.

Especially under Unix systems, that aren't really supposed to expose the
underlying hardware, and tries to abstract things quite far.

Basically, in Unix, you'd have a device, and then you'd just do a read
on it, and when something happens, the read would complete. The actual
handling of the interrupt happens inside the driver, and the feeding of
the data to your program is done there, as an effect of the interrupt.
Your program itself don't interact with the interrupt as such. The most
fancy thing would be to get this to also do signals in your program when
an interrupt happens.

Other systems, like RT-11, are easier to work with in this aspect, since
it pretty much leaves the hardware exposed and available for you to use,
but you are then also going for a rather different system, so the
learning curve on that side is then greater.

And of course, in either case, a bit of assembler understanding, and how
hardware works, will be required. Even if you'd do most everything in C
on 2.11BSD.

Johnny

On 2022-04-17 12:46, 'Fabrizio Furnari' via [PiDP-11] wrote:
> Hi Neil, first thanks for your answer, I've downloaded your python
> script attached to the thread you mentioned and now I'm studying it!
>
> To better clarify: I'm a total beginner both in ASM and PDP-11
> architecture so the idea would be to write a simple C program that uses
> the PDP-11 registers to do some blinky stuff, compile it for PDP-11 and
> run it maybe under BSD (is the OS I know better among the PDP-11 ones).
>
> I'd like also to learn how to detect (in BSD, for example) to react to
> interrupts like the various button presses...
>
> Thanks again, this group is an invaluable source of information...
>
> F
>
> April 17, 2022 4:35 AM, "Neil Higgins" <1955...@gmail.com
> <mailto:1955...@gmail.com?to=%22Neil%20Higgins%22%20<1955...@gmail.com>>>
> <mailto:pidp-11+u...@googlegroups.com>.
> <https://groups.google.com/d/msgid/pidp-11/4dc283c5-6e4e-4a95-b242-ad86975b2299n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
>
> --
> 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
> <mailto:pidp-11+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pidp-11/8705f8237e5a0256d6fda55403fde4e9%40fabfur.it
> <https://groups.google.com/d/msgid/pidp-11/8705f8237e5a0256d6fda55403fde4e9%40fabfur.it?utm_medium=email&utm_source=footer>.

--
Johnny Billquist || "I'm on a bus
|| on a psychedelic trip
email: b...@softjar.se || Reading murder books
pdp is alive! || tryin' to stay hip" - B. Idol

Clem Cole

unread,
Apr 17, 2022, 6:01:24 PM4/17/22
to Fabrizio Furnari, Neil Higgins, [PiDP-11]
On Sun, Apr 17, 2022 at 6:46 AM 'Fabrizio Furnari' via [PiDP-11] <pid...@googlegroups.com> wrote:
To better clarify: I'm a total beginner both in ASM and PDP-11 architecture so the idea would be to write a simple C program that uses the PDP-11 registers to do some blinky stuff, compile it for PDP-11 and run it maybe under BSD (is the OS I know better among the PDP-11 ones).
Maybe I am miss-understanding you.  Are you asking how to read/write the console display lights (0777570 in unibus space) from user mode?
BSD will not allow you to address the I/O space from a user program.  You either need to write a simple driver or you need to do it in the kernel, plus you will have issues with the UNIX scheduler for the PDP-11s.  I think the late Mike Muess had such a driver at JH and BRL.

There were a number of different idle loop drivers for V6 and V7 over the years (again I think Mike did one, and maybe the Rand folks -- frankly I have forgotten). he RSTS guys did a pretty slick one and RSX tied (and IIRC) did an even better one. Fred Canter may have one for V7m or Ultrix, but I don't remember.    But I never saw one for the PDP-11 UNIX as sexy as the RSX or RSTS ones.  At one point, I personally wrote one that just shifted 2 bits back and forth every few seconds.   It's a pretty simple C routine, and we just added to the idle code.  It worked, but it was not very satisfying.    T

Anton Lavrentiev

unread,
Apr 17, 2022, 6:13:33 PM4/17/22
to Clem Cole, Fabrizio Furnari, Neil Higgins, [PiDP-11]
I would assume that the OP was asking for the blinky code that runs by SimH (and this PiDP11) when you don't select anything by the console switches (code 0).... That was my understanding 

--
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.

Charley Jones

unread,
Apr 17, 2022, 7:51:18 PM4/17/22
to Anton Lavrentiev, Clem Cole, Fabrizio Furnari, Neil Higgins, [PiDP-11]
The code for kill the bit:

;  Kill the Bit game by Dean McDaniel, May 15, 1975
;
;  Object: Kill the rotating bit. If you miss the lit bit, another
;	   bit turns on leaving two bits to destroy. Quickly 
;	   toggle the switch, don't leave the switch in the up
;	   position. Before starting, make sure all the switches
;	   are in the down position.	   
;
	org	0
	lxi	h,0		;initialize counter
	mvi	d,080h		;set up initial display bit
	lxi	b,0eh		;higher value = faster
beg:	ldax	d		;display bit pattern on
	ldax	d		;...upper 8 address lights
	ldax	d
	ldax	d
	dad	b		;increment display counter
	jnc	beg
	in	0ffh		;input data from sense switches
	xra	d		;exclusive or with A
	rrc			;rotate display right one bit
	mov	d,a		;move data to display reg
	jmp	beg		;repeat sequence
	end

From:


Sent from my iPhone 12pm!
Charley Jones, PMP

On Apr 17, 2022, at 3:13 PM, Anton Lavrentiev <anton.la...@gmail.com> wrote:



Anton Lavrentiev

unread,
Apr 17, 2022, 8:06:47 PM4/17/22
to Charley Jones, Clem Cole, Fabrizio Furnari, Neil Higgins, [PiDP-11]
I don't think it's a PDP-11 assembler code so IDK how is this relevant to the original request

Charley Jones

unread,
Apr 17, 2022, 8:11:42 PM4/17/22
to Anton Lavrentiev, Clem Cole, Fabrizio Furnari, Neil Higgins, [PiDP-11]
Oh duh, 

Kill the Bit was something for the Altair not the PDP-11.  As the article states it was due to a side effect of the 8080 and Altair.  I don’t know of such a program for the PDP-11.


Sent from my iPhone 12pm!
Charley Jones, PMP

On Apr 17, 2022, at 5:06 PM, Anton Lavrentiev <anton.la...@gmail.com> wrote:



Garry A Lockyer

unread,
Apr 17, 2022, 8:34:22 PM4/17/22
to Charley Jones, Anton Lavrentiev, Clem Cole, Fabrizio Furnari, Neil Higgins, [PiDP-11]
A similar side effect for the PDP 11 would be R0 being displayed in the data lights while waiting for an interrupt.  It wouldn’t take much to write an equivalent program for the ‘11.

Regards,

Garry A. Lockyer


On Apr 17, 2022, at 17:11, Charley Jones <data...@gmail.com> wrote:

Oh duh, 

Heinz-Bernd Eggenstein

unread,
Apr 17, 2022, 8:39:21 PM4/17/22
to [PiDP-11]
BAck to the OP's request: As for reading the switches (at least 0...15) you can do that via memory mapped IO running as root under BSD with a simple C program or ASM if you insist, right? no need for a driver or kernel code.

HB

Howard Cripe

unread,
Apr 17, 2022, 9:45:55 PM4/17/22
to pid...@googlegroups.com
It looks like to me that the source code for the IDLED idle LED
generator is in the boot.ini file in the /opt/pidp11/systems/idled
folder. I'm going to try to make some changes to it just to see if I can.

Howard

Johnny Billquist

unread,
Apr 18, 2022, 6:20:44 AM4/18/22
to pid...@googlegroups.com
That is true, but if you want a more precise control, read/write the
switch register, and have the front panel set to displaying the switch
register.

The R0 is shown at WAIT if you display the data path.

Johnny
>>>> <anton.la...@gmail.com <mailto:anton.la...@gmail.com>>
>>>> wrote:
>>>>
>>>> 
>>>> I would assume that the OP was asking for the blinky code that
>>>> runs by SimH (and this PiDP11) when you don't select anything by
>>>> the console switches (code 0).... That was my understanding
>>>>
>>>> On Sun, Apr 17, 2022, 6:01 PM Clem Cole <cl...@ccc.com
>>>> <mailto:cl...@ccc.com>> wrote:
>>>>
>>>>
>>>>
>>>> On Sun, Apr 17, 2022 at 6:46 AM 'Fabrizio Furnari' via
>>>> [PiDP-11] <pid...@googlegroups.com
>>>> <mailto:pid...@googlegroups.com>> wrote:
>>>>
>>>> __
>>>> To better clarify: I'm a total beginner both in ASM and
>>>> PDP-11 architecture so the idea would be to write a
>>>> simple C program that uses the PDP-11 registers to do
>>>> some blinky stuff, compile it for PDP-11 and run it
>>>> maybe under BSD (is the OS I know better among the
>>>> PDP-11 ones).
>>>>
>>>> Maybe I am miss-understanding you.  Are you asking how to
>>>> read/write the console display lights (0777570 in unibus
>>>> space) from user mode?
>>>> BSD will not allow you to address the I/O space from a user
>>>> program.  You either need to write a simple driver or you
>>>> need to do it in the kernel, plus you will have issues with
>>>> the UNIX scheduler for the PDP-11s.  I think the late Mike
>>>> Muess had such a driver at JH and BRL.
>>>>
>>>> There were a number of different idle loop drivers for V6
>>>> and V7 over the years (again I think Mike did one, and maybe
>>>> the Rand folks -- frankly I have forgotten). he RSTS guys
>>>> did a pretty slickone and RSX tied (and IIRC) did an even
>>>> better one. Fred Canter may have one for V7m or Ultrix, but
>>>> I don't remember.    But I never saw one for the PDP-11 UNIX
>>>> as sexy as the RSX or RSTS ones.  At one point, I personally
>>>> wrote one that just shifted 2 bits back and forth every few
>>>> seconds.   It's a pretty simple C routine, and we just added
>>>> to the idle code.  It worked, but it was not very
>>>> satisfying.    T
>>>>
>>>> --
>>>> 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
>>>> <mailto:pidp-11+u...@googlegroups.com>.
>>>> <https://groups.google.com/d/msgid/pidp-11/CAC20D2N9H6YM11FR7GUjPGt3CfPH6dL-6W70xGJ4juVbaqPFcg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>>>
>>>> --
>>>> 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
>>>> <mailto:pidp-11+u...@googlegroups.com>.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/pidp-11/CAAo%3Dyr1UQt1-sT%3DTVaKLuQNOHVzr82%2BYWjtjbr%2BvrpPDih_f-w%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/pidp-11/CAAo%3Dyr1UQt1-sT%3DTVaKLuQNOHVzr82%2BYWjtjbr%2BvrpPDih_f-w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>>>
>> --
>> 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
>> <mailto:pidp-11+u...@googlegroups.com>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pidp-11/0666DF3C-09C0-40CF-8BB8-08E2BEE15C06%40gmail.com
>> <https://groups.google.com/d/msgid/pidp-11/0666DF3C-09C0-40CF-8BB8-08E2BEE15C06%40gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> 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
> <mailto:pidp-11+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pidp-11/3A22F156-21EF-482D-B17B-B514ACDA05A8%40gmail.com
> <https://groups.google.com/d/msgid/pidp-11/3A22F156-21EF-482D-B17B-B514ACDA05A8%40gmail.com?utm_medium=email&utm_source=footer>.

Johnny Billquist

unread,
Apr 18, 2022, 6:50:44 AM4/18/22
to pid...@googlegroups.com
BSD will allow you to address the I/O space from user mode. That's what
/dev/kmem is there for.
However, normally, writing to /dev/kmem is not allowed, so you can only
read the switch register.
You need to switch the system to insecure mode in order to be able to
write to /dev/kmem.
That is done by setting securelevel to -1 before going multiuser.

See sysctl for details.


But of course, all of this will only allow people to poll things. The
switch register can only ever be polled anyway, but for other things
that might generate interrupts, /dev/kmem does not allow you to set up
anything related to interrupts.

And the scheduler will not interfere. BSD also have an idle light
pattern, but just like for all other systems, it is not using the switch
register for this in the first place, so you are free to play with it as
you want.

Johnny

On 2022-04-18 00:00, Clem Cole wrote:
>
>
> On Sun, Apr 17, 2022 at 6:46 AM 'Fabrizio Furnari' via [PiDP-11]
> <pid...@googlegroups.com <mailto:pid...@googlegroups.com>> wrote:
>
> __
> To better clarify: I'm a total beginner both in ASM and PDP-11
> architecture so the idea would be to write a simple C program that
> uses the PDP-11 registers to do some blinky stuff, compile it for
> PDP-11 and run it maybe under BSD (is the OS I know better among the
> PDP-11 ones).
>
> Maybe I am miss-understanding you.  Are you asking how to read/write the
> console display lights (0777570 in unibus space) from user mode?
> BSD will not allow you to address the I/O space from a user program.
> You either need to write a simple driver or you need to do it in the
> kernel, plus you will have issues with the UNIX scheduler for the
> PDP-11s.  I think the late Mike Muess had such a driver at JH and BRL.
>
> There were a number of different idle loop drivers for V6 and V7 over
> the years (again I think Mike did one, and maybe the Rand folks --
> frankly I have forgotten). he RSTS guys did a pretty slickone and RSX
> tied (and IIRC) did an even better one. Fred Canter may have one for V7m
> or Ultrix, but I don't remember.    But I never saw one for the PDP-11
> UNIX as sexy as the RSX or RSTS ones.  At one point, I personally wrote
> one that just shifted 2 bits back and forth every few seconds.   It's a
> pretty simple C routine, and we just added to the idle code.  It worked,
> but it was not very satisfying.    T
>
> --
> 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
> <mailto:pidp-11+u...@googlegroups.com>.
> To view this discussion on the web visit

Neil Higgins

unread,
Apr 18, 2022, 7:48:33 AM4/18/22
to [PiDP-11]
Hi Fabrizio. If you want to “play” with the machinery, you will have more fun with assembly language on RT-11 (or even on simulated bare metal) than with C on BSD Unix. On a small PDP-11, RT-11 will let you access the entire address space, including the I/O space. Having said that, I am not sure what impediments the hardware of a larger PDP-11 (like an 11/70) will put in your way; however I expect that the machine would start in a simple mode which gives you access to everything. The RT-11 manual and the associated MACRO-11 assembler manual will tell you how to do the things you want to do. Bear in mind that the PDP-11 equivalent of “GPIO” and serial lines involved extra plug-in cards for the Unibus or QBus. There was a recent post where someone had implemented simulated “GPIO” (PDP-11 style) using the Raspberry Pi’s SPI or I2C. A search of this group should find it fairly quickly.

Johnny Billquist

unread,
Apr 18, 2022, 7:50:40 AM4/18/22
to pid...@googlegroups.com
RT-11 works the same no matter what hardware it is running on.
Of course, on more capable hardware, you can also run more fancy
variants of RT-11, but all variants work, and the simple ones do the
same things independent of the hardware.

Johnny

On 2022-04-18 13:48, Neil Higgins wrote:
> Hi Fabrizio. If you want to “play” with the machinery, you will have
> more fun with assembly language on RT-11 (or even on simulated bare
> metal) than with C on BSD Unix. On a small PDP-11, RT-11 will let you
> access the entire address space, including the I/O space. Having said
> that, I am not sure what impediments the hardware of a larger PDP-11
> (like an 11/70) will put in your way; however I expect that the machine
> would start in a simple mode which gives you access to everything. The
> RT-11 manual and the associated MACRO-11 assembler manual will tell you
> how to do the things you want to do. Bear in mind that the PDP-11
> equivalent of “GPIO” and serial lines involved extra plug-in cards for
> the Unibus or QBus. There was a recent post where someone had
> implemented simulated “GPIO” (PDP-11 style) using the Raspberry Pi’s SPI
> or I2C. A search of this group should find it fairly quickly.
>
> On Sunday, 17 April 2022 at 20:46:05 UTC+10 Fabrizio Furnari wrote:
>
> __
> <https://groups.google.com/d/msgid/pidp-11/4dc283c5-6e4e-4a95-b242-ad86975b2299n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
>
> ____
>
> --
> 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
> <mailto:pidp-11+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pidp-11/9e8e137c-4a24-4ad0-ba51-446cd097143dn%40googlegroups.com
> <https://groups.google.com/d/msgid/pidp-11/9e8e137c-4a24-4ad0-ba51-446cd097143dn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Clem Cole

unread,
Apr 18, 2022, 10:09:01 AM4/18/22
to Fabrizio Furnari, Neil Higgins, [PiDP-11]
I probably should have added if you look in the the two files:  V7 sys/clock.c and V7 conf/mch.s   and look for the routine _display() defined in the later and called in the clock routine in the former, you'll see Ken's support for reading and writing of the PDP-11 CSW for V7.    The routine _idle() is also defined in assembler and called from in V7 sys/prf.c and V7 sys/slp.c   They are all quite small, and if you look at them and you'll get the idea how they work [you'll file the definitions for the address of CSW and SWR in mach.s].

Fabrizio Furnari

unread,
Apr 18, 2022, 10:23:41 AM4/18/22
to Fabrizio Furnari' via [PiDP-11]
Wow guys, I honestly didn't expect so many answers, and all so interesting!

I'll try to reply to all, in the meantime thanks again for packing my next days with study and more study!

F

> --
> 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/fabff3e5ba180e6c...@fabfur.it.

Fabrizio Furnari

unread,
Apr 18, 2022, 10:33:23 AM4/18/22
to Clem Cole, [PiDP-11]
Very interesting thanks, I'll look for the drivers you mentioned, but the more I read through your replies the more I'm convinced I better stick with ASM for this kind of task...

F

Fabrizio Furnari

unread,
Apr 18, 2022, 10:40:06 AM4/18/22
to Anton Lavrentiev, [PiDP-11]

Hi Anton, yes I've read the boot.ini for the IDLED system in the PiDP folder and now I'm wrapping my head around that to understand deeply how it works!

I firstly thought that the IDLED would recognize the pressed console switches and *then* reboots to the selected systems (so it should trap also the rotary encoder press) but then I realized that maybe this is done *outside* the IDLED program: If I understand correctly the rotary encoder switch (which is something that should not "exists" in a "real" PDP-11) is trapped _outside_ the IDLED program (maybe scanswitch?) and causes the SIMH restart with the program selected by the switches...

Am I right?

Thanks,

F

Fabrizio Furnari

unread,
Apr 18, 2022, 10:42:18 AM4/18/22
to Charley Jones, Anton Lavrentiev, Clem Cole, Neil Higgins, [PiDP-11]
Well thanks anyway, maybe Altair 8800 could be my next system to study!

F

Mike Katz

unread,
Apr 18, 2022, 11:33:26 AM4/18/22
to Fabrizio Furnari, Clem Cole, [PiDP-11]
I am not a PDP-11 programmer (the PDP-8 was the first machine language I learned).

That being said and from reading the message thread I would recommend a minimal operating system like RT-11 and coding in C might be a shorted learning curve.

Even though the PDP-11 has probably the best machine language architecture. C handle a lot of the mundane arithmetic that assembler requires.

If you do use C be sure to make all of your memory mapped pointers volatile.

For example:

volatile uint32_t *ConsoleDisplay = 077570;   // Note:  the leading zero makes that value octal.

This forces the compiler to never optimize out any references to that memory address.
--
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.

Clem Cole

unread,
Apr 18, 2022, 12:11:14 PM4/18/22
to Mike Katz, Fabrizio Furnari, [PiDP-11]
On Mon, Apr 18, 2022 at 11:33 AM Mike Katz <justme...@gmail.com> wrote:
I am not a PDP-11 programmer (the PDP-8 was the first machine language I learned).

That being said and from reading the message thread I would recommend a minimal operating system like RT-11 and coding in C might be a shorted learning curve.
I agree.

Even though the PDP-11 has probably the best machine language architecture. C handle a lot of the mundane arithmetic that assembler requires.
C provides a lot of good housekeeping and hygiene.

If you do use C be sure to make all of your memory mapped pointers volatile.
Right .. sort of ;-)  A few historical dragons of which it is smart to be aware.   That statement depends on the compiler you are using...

The keywords and ideas behind volatile and const are 'late' in the language i.e. after the Typesetter C, Dennis describes them in K&R2, they came along with ANSI prototypes.  Typesetter C (which is what was in the Seventh edition) is when the stdio library was introduced [see K&R 1 - The C Programming Language, First Edition - 1978]  Before that (Sixth edition - distribution - although Typesetter C will build and run on V6) uses Mike Lesk's 'portable I/O' library. The good news in this case is that Dennis's optimizer was pretty weak in those days and the keywords were not needed for the PDP-11.  [Fun fact, it was the embedded C folks that actually started to push for them and prototypes for the microprocessors in the early 1980s].

I personally did not mess much with C on a DEC OS for the PDP-11 [I did use Culter's VAX-11C on VMS later on].  I did a little bit with RT-11, using something from DECUS; I believe (actually we used DEC FORTRAN and OMSI Pascal more often on that system].  My memory / impression that the DECUS C compiler for RT11 et al, was based on what Dennis and Brian described in K&R1.  That said, development at DEC continued on the 11s for many years after I stopped paying attention to them, so there may be (??likely??) a later compiler that supports K&R2 or maybe an even later version of the language post Dennis' passing.  

Bottom line ->> YMMV



Anton Lavrentiev

unread,
Apr 18, 2022, 12:48:32 PM4/18/22
to Howard Cripe, [PiDP-11]
If I'm looking at the same package, then I see that there's a setup
file, boot.ini that loads another file PDP-11xx.ini, which loads a
machine state with the load command and then jumps to execute it.
There's no source code for 70CORE.ptp (which is loaded in memory),
it's a binary file, but I presume it's in the formatted binary format
(or maybe absolute formatted binary format) -- I remember seeing
something like that in the responses on this list when I asked
questions here. Anyways, it can be disassembled, but having some sort
of source code would have been much more useful (and definitely easier
to read), for the purposes of the original question from the OP.
> --
> 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/8d1b318d-359e-c6cd-2745-ce8e36b5cf4e%40gmail.com.

Neil Higgins

unread,
Apr 18, 2022, 6:06:03 PM4/18/22
to [PiDP-11]
The only issue here is that, to my knowledge, the only C compiler available for RT-11 was DECUS C, and it was regarded as quirky and bit unstable. I would still advocate using assembler if you want to play with hardware features. The PDP-11 has an elegant, easy-to-learn instruction set, and the hardware (including interrupts) is well documented and well behaved. But it all comes down to what you want to achieve.

Clem Cole

unread,
Apr 18, 2022, 6:37:28 PM4/18/22
to Neil Higgins, [PiDP-11]
On Mon, Apr 18, 2022 at 6:06 PM Neil Higgins <1955...@gmail.com> wrote:
The only issue here is that, to my knowledge, the only C compiler available for RT-11 was DECUS C, and it was regarded as quirky and bit unstable.
Not going to argue with that.  We used the OMSI Pascal and FORTRAN (and even ratfor) way more than the DECUS C.

 
I would still advocate using assembler if you want to play with hardware features.
Mumble -- very little the HW has that can not be seen by the different HLLs on RT-11.  The system Mellon Institute did for automating newspaper sorting and delivery originally for the Pittsburgh Press (and duplicated many times later), even had some special/custom hardware interfaces had very little if any assembler and we had some pretty good assembler folks.   It just wasn't worth it.   (And FORTRAN was used over C because DEC supported it, which the customer wanted).
 
The PDP-11 has an elegant, easy-to-learn instruction set, and the hardware (including interrupts) is well documented and well behaved.
I 100% agree.


But it all comes down to what you want to achieve.
But Mike Katz's observation (which I also 100% agree) is that using an HLL, like C (or Pascal or FORTRAN) to first learn about the basics of the PDP-11 is far easier and has a lot less cruft. - as a lot of details that at the beginning are not all that important are taken care of for you.   His words shorten the learning curve.    At some point, learning the full PDP-11 ISA is a good thing, too, but if you first learn how to use the editors, development system, and basic calls using an HLL, I think it will be faster.

Remember when Ken created B and later Dennis morphed it into C, they looked at it as a higher level assembler to handle those details for them.  I take the same attitude.  I just think Mike is right that the learning curve should be much more shallow if you don't start with Macro-11.

Your choice of course and different strokes as they say. 

Mike Katz

unread,
Apr 18, 2022, 6:59:22 PM4/18/22
to Clem Cole, Neil Higgins, [PiDP-11]
Though I was not aware that early C compilers did not support the volatile keyword.  I don't think it would be possible to write a device driver in C without the use of volatiles.  Especially in a DMA environment. it is a requirement for writing device drivers (unless optimization is completely disabled).

Here is a link to how to cross compile for the PDP-11 using GCC.

This might be a great way to do what you want without much more than a binary loader on the PDP-11 and no OS to get in your way.

https://www.teckelworks.com/2020/03/c-programming-on-a-bare-metal-pdp-11/
--
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.

Johnny Billquist

unread,
Apr 18, 2022, 7:11:39 PM4/18/22
to pid...@googlegroups.com
The DECUS C compiler isn't particularly quirky or unstable, but it is
very old K&R. So people of today might find it a bit difficult to adopt.

DEC also did an ANSI C89 compiler, which I believe was also available
for RT-11. But I don't have it myself, and don't know where to find it.
Maybe check trailing-edge if someone wants to try and locate it.

Assembler on the PDP-11 is certainly a fairly nice experience, but it's
still way more to learn and do compared to writing something in C.

Johnny
> The keywords and ideas behind volatileand const are 'late' in the
> language/i.e./ after the Typesetter C, Dennis describes them in
> K&R2, they came along with ANSI prototypes.  Typesetter C (which is
> what was in the Seventh edition) is when the stdio library was
> introduced [see K&R 1 - The C Programming Language, First Edition -
> 1978
> <https://ia801303.us.archive.org/1/items/TheCProgrammingLanguageFirstEdition/The%20C%20Programming%20Language%20First%20Edition%20%5BUA-07%5D.pdf>]
> Before that (Sixth edition - distribution - although Typesetter C
> will build and run on V6) uses Mike Lesk's 'portable I/O' library.
> The good news in this case is that Dennis's optimizer was pretty
> weak in those days and the keywords were not needed for the PDP-11.
>  [Fun fact, it was the embedded C folks that actually started to
> push for them and prototypes for the microprocessors in the early
> 1980s].
>
> I personally did not mess much with C on a DEC OS for the PDP-11 [I
> did use Culter's VAX-11C on VMS later on].  I did a little bit with
> RT-11, using something from DECUS; I believe (actually we used DEC
> FORTRAN and OMSI Pascal more often on that system].  My memory /
> impression that the DECUS C compiler for RT11/et al/, was based on
> what Dennis and Brian described in K&R1.  That said, development at
> DEC continued on the 11s for many years after I stopped paying
> attention to them, so there may be (??likely??) a later compiler
> that supports K&R2 or maybe an even later version of the language
> post Dennis' passing.
>
> Bottom line ->> YMMV
>
>
>
> --
> 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
> <mailto:pidp-11+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pidp-11/cf17e7bb-3124-4014-8598-6a568a31ed0bn%40googlegroups.com
> <https://groups.google.com/d/msgid/pidp-11/cf17e7bb-3124-4014-8598-6a568a31ed0bn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Johnny Billquist

unread,
Apr 18, 2022, 7:14:15 PM4/18/22
to pid...@googlegroups.com
With modern versions of the language, volatile is absolutely neccesary
in order to write something like a device driver, yes.

Older compilers aren't nearly as creative with optimizations, so there
volatile isn't actually necessary.

volatile is in fact rather recent. And yet, Unix have existed for 50
years...

Johnny
>> ᐧ
>> --
>> 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/CAC20D2NfBDN7uBKeOsm2bjNzQZTB8mHYhshWY2o3Bpe0_GQusA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/pidp-11/CAC20D2NfBDN7uBKeOsm2bjNzQZTB8mHYhshWY2o3Bpe0_GQusA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> 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
> <mailto:pidp-11+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pidp-11/da303281-5dbe-29f9-ae54-358604489652%40gmail.com
> <https://groups.google.com/d/msgid/pidp-11/da303281-5dbe-29f9-ae54-358604489652%40gmail.com?utm_medium=email&utm_source=footer>.

Clem Cole

unread,
Apr 18, 2022, 7:50:19 PM4/18/22
to Mike Katz, Neil Higgins, [PiDP-11]
The BLISS optimizer for the 11 was the first that was good enough for that to be an issue. This is described in Wulfs book which pretty much set the standard for optimizers like you know today  (The Design of an Optimizing Compiler -aka The Green Book).  

At the time many people in both academia and industry did not believe you could beat assembler.  After the BLISS compiler and Wulfs infamous demonstration, it started to change peoples attitudes.  In fact, DEC picked BLISS as its systems language because of what Wulf and students were able to demonstrate.  In fact BLISS calls them “code comments” - as a way to tell the optimizer to back off [I have some great stories about that but not now].

Today, most compilers are said to be post Green Book and it’s hard to believe it was such disbelief in those days [BTW Cutler was famous for hating BLISS and not wanting to use it.  Paul Winalski had regaled us with some of his stories from being the DEC compiler team in those days on the TUHS mailing list].

Anyway Dennis’s and later Steve Johnson optimizer were decent for the time but not in the same class and they were used for all the drivers.  Look at the TUHS archives btw. 

The first commerial compilers that started to be that good were the DEC ones. After VAX11 compiler and things like const and volatile started to be an issues.    FYI vax11c used the same back end from Pl/1 although originally FTN and Pascal did not use common back ends.  FYI it was a bunch of ex-DEC compiler folks that built the Masscomp C and FORTRAN which was Green book style.  Sun would not follow suit for a few years. 

IIRC volatile did not come on the scene until the mid/late 80s.  C was a good 12-15 years old by that point.  

Btw early Gcc was pretty good in its optimization (better than Dennis) but it has never in the same class as the DEC compilers particularly the final generation- aka the GEM compilers.   Intel has all the DEC DNA in their development suit and actually is slowly adding it into LLVM.  [Folks in my team are heavily involved with that work].
--
Sent from a handheld expect more typos than usual

Neil Higgins

unread,
Apr 18, 2022, 9:58:52 PM4/18/22
to [PiDP-11]
Horses for courses. If you want to learn about how interrupts work, do it in assembler (it only takes a few instructions to set up an interrupt). If you want to use interrupts for some higher purpose, use a HLL. I personally dislike C immensely and actually find PDP-11 assembler more approachable. But I do like Python - that’s my kind of language.

Fabrizio Furnari

unread,
Apr 20, 2022, 6:49:33 AM4/20/22
to Neil Higgins, [PiDP-11]
Thanks Neil,
I'm planning to study the RT-11 OS and MACRO-11, is definitely on the list!

F

will...@gmail.com

unread,
May 2, 2022, 11:47:30 AM5/2/22
to [PiDP-11]
Posting some of my blog posts pertinent to this discussion for anyone reading the thread and looking for where to start  putting up a v6/v7/rt-11 instance and for macro programming on rt-11:

Will
Reply all
Reply to author
Forward
0 new messages