* [TUHS] 'more' command for Unix V7
@ 2023-02-16 14:24 KenUnix
2023-02-16 15:06 ` [TUHS] " Hellwig Geisse
0 siblings, 1 reply; 6+ messages in thread
From: KenUnix @ 2023-02-16 14:24 UTC (permalink / raw)
To: UNIX TUHS Group
[-- Attachment #1: Type: text/plain, Size: 4303 bytes --]
Here is a simplified 'more' command for Unix V7:
/*********************************************************************
* UNIX pager (v7 compatible) Chipmaster and KenUnix
*
* cc -o more more.c
*
* Usage examples:
* man wall | more
* more xyz
* more abc def xyz
*
* Started February 15th, 2023 YeOlPiShack.net
*
* This is the ultimately dumbest version of more I have experienced.
* Its main purpose is to illustrate the use of /dev/tty to interact
* with the user while in a filter role (stdin -> stdout). This also
* leaves stderr clear for actual errors.
*
*
* NOTES on Antiquity:
*
* - The early C syntax didn't allow for combining type information
* in the parenthesized argument list only the names were listed.
* Then a "variable" list followed the () and preceded the { that
* declared the types for the argument list.
*
* - There is no "void", specifically there is no distinction
* between a function that returns an int or nothing at all.
*
* - Many of the modern day header files aren't there.
*
* - Apparently "/dev/tty" couldn't be opened for both reading and
* writing on the same FD... at least not in our VM.
*
* - Apparently \a wasn't defined yet either. So I use the raw code
* \007.
*
* - Modern compilers gripe if you do an assignment and comparison in
* the same statement without enclosing the assignment in (). The
* original compilers did not. So if it looks like there are too
* many ()s it's to appease the modern compiler gods.
*
* - I'm not sure where they hid errno if there was one. I'd think
* there had to be. Maybe Kernighan or Pike knows...
*
*********************************************************************/
#include <stdio.h>
/*** Let's make some assumptions about our terminal columns and lines. ***/
#define T_COLS 80
#define T_LINES 24
/*** Let's set up our global working environment ***/
FILE *cin; /* TTY (in) */
FILE *cout; /* | (out) */
int ct = 0;
/*** message to stderr and exit with failure code ***/
err(msg)
char *msg;
{
fputs(msg, stderr);
exit(1);
}
/*** A poor man's CLear Screen ***
*
* Yup! This is how they used to do it, so says THE Kenrighan & Pike!
* termcap?!?! What's that?
*/
cls()
{
int x;
for(x=0; x<T_LINES; ++x) fputc('\n', cout);
ct = 0; /* reset global line count */
}
/*** The PAUSE prompt & wait ***/
pause()
{
char in[T_COLS+1]; /* TTY input buffer */
fflush(stdout); /*JIC*/
fputs("--- [ENTER] to continue --- Ctrl-d exits ", cout);
fflush(cout);
if(!fgets(in, 81, cin)) {
/* ^D / EOF */
fputc('\n', cout); /* cleaner terminal */
exit(0);
}
}
/*** Read and page a "file" ***/
int pg(f)
FILE *f;
{
char buf[T_COLS+1]; /* input line: usual term width + \0 */
/*** read and page stdin ***/
while(fgets(buf, sizeof(buf), f)) {
/* page break at T_LINES */
if(++ct==T_LINES) {
pause();
ct = 1;
}
fputs(buf, stdout);
}
return 0;
}
/*** Let's do some paging!! ***/
int main(argc, argv)
int argc;
char *argv[];
{
FILE *in;
int x, er;
/*** Grab a direct line to the TTY ***/
if(!(cin=fopen("/dev/tty", "r")) || !(cout=fopen("/dev/tty", "w")))
err("\007Couldn't get controlling TTY\n");
/*** with CLI args ***/
if(argc>1) {
er = 0;
for(x=1; x<argc; ++x) {
if(argc>2) {
if(!er) cls();
er = 0;
/* remember all user interaction is on /dev/tty (cin/cout) */
fprintf(cout, ">>> %s <<<\n", argv[x]);
pause();
}
/* - is tradition for stdin */
if(strcmp("-", argv[x])==0) {
pg(stdin);
/* it must be a file! */
} else if((in=fopen(argv[x], "r"))) {
pg(in);
fclose(in);
} else {
/* errors go on stderr... JIC someone want to log */
fprintf(stderr, "Could not open '%s'!\n", argv[x]);
fflush(stderr);
er = 1; /* this prevents cls() above. */
}
}
/*** no args - read and page stdin ***/
} else {
pg(stdin);
}
return 0;
}
End...
--
WWL 📚
[-- Attachment #2: Type: text/html, Size: 5382 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] Re: 'more' command for Unix V7
2023-02-16 14:24 [TUHS] 'more' command for Unix V7 KenUnix
@ 2023-02-16 15:06 ` Hellwig Geisse
2023-02-16 15:23 ` KenUnix
0 siblings, 1 reply; 6+ messages in thread
From: Hellwig Geisse @ 2023-02-16 15:06 UTC (permalink / raw)
To: KenUnix, UNIX TUHS Group
On Do, 2023-02-16 at 09:24 -0500, KenUnix wrote:
>
> * - I'm not sure where they hid errno if there was one. I'd think
> * there had to be. Maybe Kernighan or Pike knows...
It's a .comm variable, as you can see, e.g., in
/usr/src/libc/crt/cerror.s in Keith Bostic's V7.
Hellwig
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] Re: 'more' command for Unix V7
2023-02-16 15:06 ` [TUHS] " Hellwig Geisse
@ 2023-02-16 15:23 ` KenUnix
2023-02-16 16:20 ` Hellwig Geisse
0 siblings, 1 reply; 6+ messages in thread
From: KenUnix @ 2023-02-16 15:23 UTC (permalink / raw)
To: Hellwig Geisse; +Cc: UNIX TUHS Group
[-- Attachment #1: Type: text/plain, Size: 856 bytes --]
Helwig,
$ cd /usr/src
$ ls -al
total 2
drwxrwxr-x 2 bin 224 Sep 25 1980 .
drwxr-xr-x 17 root 304 Feb 15 19:30 ..
$
These are the disks I am using
Interdata Unix V7
iu7_dp0.dsk 10MB disk image containing / and /usr
iu7_dp1.dsk 10MB disk for swap and /tmp
Both dated 23 Feb, 2003.
If there is a better set let me know. I could not get Unix V7
to run under PDP-11 so I am using Interdata-32.
Thanks
On Thu, Feb 16, 2023 at 10:06 AM Hellwig Geisse <hellwig.geisse@mni.thm.de>
wrote:
> On Do, 2023-02-16 at 09:24 -0500, KenUnix wrote:
> >
> > * - I'm not sure where they hid errno if there was one. I'd think
> > * there had to be. Maybe Kernighan or Pike knows...
>
> It's a .comm variable, as you can see, e.g., in
> /usr/src/libc/crt/cerror.s in Keith Bostic's V7.
>
> Hellwig
>
--
End of line
JOB TERMINATED
[-- Attachment #2: Type: text/html, Size: 1590 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] Re: 'more' command for Unix V7
2023-02-16 15:23 ` KenUnix
@ 2023-02-16 16:20 ` Hellwig Geisse
2023-02-17 0:19 ` KenUnix
0 siblings, 1 reply; 6+ messages in thread
From: Hellwig Geisse @ 2023-02-16 16:20 UTC (permalink / raw)
To: KenUnix; +Cc: UNIX TUHS Group
Ken,
years ago, when I ported V7 to my own microprocessor ECO32,
I wanted to have a stable reference running on a (simulated)
PDP-11 in order to better understand some difficult corners
of the original implementation. The set of files I used can
be found here (and the archive's docs say "This set of files
from Keith Bostic looks like the original tape records from
the 7th Edition distribution tape."):
https://www.tuhs.org/Archive/Distributions/Research/Keith_Bostic_v7/
I had a few minor difficulties to get it running in simh,
mostly centered around the tape format and the configuration
of the simulator, but finally I was able to install V7 exactly
as advised in the manual ("Setting Up UNIX"). I packaged the
whole adventure (original files, simh, scripts) together with
a HOWTO:
https://homepages.thm.de/~hg53/pdp11-unix/
On this site, you can also find all files extracted from the
V7 file system to the host (Linux in my case).
If you have questions, I will be glad to help.
Hellwig
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] Re: 'more' command for Unix V7
2023-02-16 16:20 ` Hellwig Geisse
@ 2023-02-17 0:19 ` KenUnix
2023-02-17 6:55 ` Hellwig Geisse
0 siblings, 1 reply; 6+ messages in thread
From: KenUnix @ 2023-02-17 0:19 UTC (permalink / raw)
To: Hellwig Geisse; +Cc: UNIX TUHS Group
[-- Attachment #1: Type: text/plain, Size: 5491 bytes --]
I am stuck here:
PDP-11 simulator V3.6-0
Disabling XQ
PDP-11 simulator configuration
CPU, 11/45, FPP, autoconfiguration on, 256KB
SYSTEM
RHA, address=17776700-17776753, vector=254
RHB, disabled
PTR, address=17777550-17777553, vector=70, not attached
PTP, address=17777554-17777557, vector=74, not attached
TTI, address=17777560-17777563, vector=60, 7b
TTO, address=17777564-17777567, vector=64, 7b
CR, address=17777160-17777167, vector=230, 285 cards per minute,
translation 029, not attached, CR11, auto EOF, unknown format
LPT, address=17777514-17777517, vector=200, not attached
CLK, 60Hz, address=17777546-17777547, vector=100
PCLK, disabled
DZ, address=17760100-17760137*, vector=300-334, lines=32, not attached, 8b
VH, address=17760500-17760577*, vector=340-374, lines=32, 4 units
VH0, not attached, DHU mode
VH1, not attached, DHU mode
VH2, not attached, DHU mode
VH3, not attached, DHU mode
RK, address=17777400-17777417, vector=220, 8 units
RK0, 1247KW, not attached, write enabled
RK1, 1247KW, not attached, write enabled
RK2, 1247KW, not attached, write enabled
RK3, 1247KW, not attached, write enabled
RK4, 1247KW, not attached, write enabled
RK5, 1247KW, not attached, write enabled
RK6, 1247KW, not attached, write enabled
RK7, 1247KW, not attached, write enabled
RL, address=17774400-17774411, vector=160, 4 units
RL0, 2621KW, not attached, write enabled, autosize
RL1, 2621KW, not attached, write enabled, autosize
RL2, 2621KW, not attached, write enabled, autosize
RL3, 2621KW, not attached, write enabled, autosize
HK, address=17777440-17777477, vector=210, 8 units
HK0, 6944KW, not attached, write enabled, autosize
HK1, 6944KW, not attached, write enabled, autosize
HK2, 6944KW, not attached, write enabled, autosize
HK3, 6944KW, not attached, write enabled, autosize
HK4, 6944KW, not attached, write enabled, autosize
HK5, 6944KW, not attached, write enabled, autosize
HK6, 6944KW, not attached, write enabled, autosize
HK7, 6944KW, not attached, write enabled, autosize
RX, address=17777170-17777173*, vector=264, 2 units
RX0, 256KB, not attached, write enabled
RX1, 256KB, not attached, write enabled
RY, disabled
RP, Massbus adapter 0, 8 units
RP0, 43MW, attached to system.hp, write enabled, RP04
RP1, 33MW, not attached, write enabled, autosize
RP2, 33MW, not attached, write enabled, autosize
RP3, 33MW, not attached, write enabled, autosize
RP4, 33MW, not attached, write enabled, autosize
RP5, 33MW, not attached, write enabled, autosize
RP6, 33MW, not attached, write enabled, autosize
RP7, 33MW, not attached, write enabled, autosize
RQ, address=17772150-17772153*, no vector, 4 units
RQ0, 159MB, not attached, write enabled, RD54
RQ1, 159MB, not attached, write enabled, RD54
RQ2, 159MB, not attached, write enabled, RD54
RQ3, 409KB, not attached, write enabled, RX50
RQB, disabled
RQC, disabled
RQD, disabled
TC, disabled
TM, address=17772520-17772533, vector=224, 8 units
TM0, attached to unix_v7.tm, write locked, SIMH format, unlimited capacity
TM1, not attached, write enabled, SIMH format, unlimited capacity
TM2, not attached, write enabled, SIMH format, unlimited capacity
TM3, not attached, write enabled, SIMH format, unlimited capacity
TM4, not attached, write enabled, SIMH format, unlimited capacity
TM5, not attached, write enabled, SIMH format, unlimited capacity
TM6, not attached, write enabled, SIMH format, unlimited capacity
TM7, not attached, write enabled, SIMH format, unlimited capacity
TS, disabled
TQ, TK50 (94MB), address=17774500-17774503, no vector, 4 units
TQ0, not attached, write enabled, SIMH format
TQ1, not attached, write enabled, SIMH format
TQ2, not attached, write enabled, SIMH format
TQ3, not attached, write enabled, SIMH format
TU, disabled
XQ, disabled
XQB, disabled
XU, disabled
XUB, disabled
100000: 012700
100002: 172526
100004: 010040
100006: 012740
100010: 060003
100012: 000777
sim> run 100000
Simulation stopped, PC: 100012 (BR 100012)
sim> run 0
Boot
: tm(0,4)
Tape? tm(0,5)
Disk? hp(0,0)
Last chance before scribbling on disk.
Out of space <====
Exit called
Boot
:
Simulation stopped, PC: 010762 (BEQ 10754)
sim> run 0 <====
HALT instruction, PC: 000174 (HALT)
sim> run 100000 <====
HALT instruction, PC: 100002 (HALT)
sim>
Ken
On Thu, Feb 16, 2023 at 11:20 AM Hellwig Geisse <hellwig.geisse@mni.thm.de>
wrote:
> Ken,
>
> years ago, when I ported V7 to my own microprocessor ECO32,
> I wanted to have a stable reference running on a (simulated)
> PDP-11 in order to better understand some difficult corners
> of the original implementation. The set of files I used can
> be found here (and the archive's docs say "This set of files
> from Keith Bostic looks like the original tape records from
> the 7th Edition distribution tape."):
>
> https://www.tuhs.org/Archive/Distributions/Research/Keith_Bostic_v7/
>
> I had a few minor difficulties to get it running in simh,
> mostly centered around the tape format and the configuration
> of the simulator, but finally I was able to install V7 exactly
> as advised in the manual ("Setting Up UNIX"). I packaged the
> whole adventure (original files, simh, scripts) together with
> a HOWTO:
>
> https://homepages.thm.de/~hg53/pdp11-unix/
>
> On this site, you can also find all files extracted from the
> V7 file system to the host (Linux in my case).
>
> If you have questions, I will be glad to help.
>
> Hellwig
>
>
--
End of line
JOB TERMINATED
[-- Attachment #2: Type: text/html, Size: 6752 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] Re: 'more' command for Unix V7
2023-02-17 0:19 ` KenUnix
@ 2023-02-17 6:55 ` Hellwig Geisse
0 siblings, 0 replies; 6+ messages in thread
From: Hellwig Geisse @ 2023-02-17 6:55 UTC (permalink / raw)
To: KenUnix; +Cc: UNIX TUHS Group
On Do, 2023-02-16 at 19:19 -0500, KenUnix wrote:
> I am stuck here:
>
> PDP-11 simulator V3.6-0
> Disabling XQ
> PDP-11 simulator configuration
> [...]
> Simulation stopped, PC: 100012 (BR 100012)
> sim> run 0
> Boot
> : tm(0,4)
> Tape? tm(0,5)
> Disk? hp(0,0)
> Last chance before scribbling on disk.
> Out of space <====
> Exit called
You skipped step 5 from the manual, which runs
mkfs. Without an empty file system, trying
restor (": tm(0,4)") is bound to fail.
I suggest continuing our mail exchange off-list,
if you don't mind. The old hands here don't need
any further discussion of boot procedures... ;-)
Hellwig
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-17 6:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 14:24 [TUHS] 'more' command for Unix V7 KenUnix
2023-02-16 15:06 ` [TUHS] " Hellwig Geisse
2023-02-16 15:23 ` KenUnix
2023-02-16 16:20 ` Hellwig Geisse
2023-02-17 0:19 ` KenUnix
2023-02-17 6:55 ` Hellwig Geisse
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).