PDP-10 / its

Incompatible Timesharing System
Other
853 stars 80 forks source link

SAIL compiler #843

Open larsbrinkhoff opened 6 years ago

larsbrinkhoff commented 6 years ago

Compiler for SAIL, the Algol dialect.

Needed to build PUB, #841.

larsbrinkhoff commented 6 years ago

https://www.saildart.org/[*,AIL]

larsbrinkhoff commented 6 years ago

Also needed for pre-Pascal TEX. #867

TheFausap commented 6 years ago

I'm trying to recreate the SAIL compiler. I'm starting from the SAIL debugger BAIL. I used the files in [NEW,AIL] (from SAILDART), and I also found some useful MIC files describing how to link them. For BAIL we have ASMBAI.MIC. It should be a TOPS-10 file, but FAIL.200 uses the same standard, so assembling the file is ok, I basically did:

:FAIL
baiclc_bpdahd,baiclc
[etc]

but the file BAISM1 has some warnings:

 ENTER  UNDEF   000023'
 RESET  UNDEF   000000'
  EXIT  UNDEF   000056'
RELEAS  UNDEF   000055'
PROGRAM BREAK   002253'
ELAPSED CPU TIME 0:00.000 

those UNDEF are related (according the latest manual @larsbrinkhoff put in the repo) to some UUO.

- RELEAS 071000,,0 UUO
- ENTER 077000,,0 UUO
- RESET CALLI 0 UUO
- EXIT CALLI 12 UUO

the two files (BAISM1 and BSM1HD) are here: https://gist.github.com/TheFausap/c6f2cb8d2215d3e5f3e28d182d345d9c

Eventually I got a REL file anyway, and according the mic file,

.r fail
*baiclc←bpdahd,baiclc
*baiio1←bpdahd,baiio1
*baiio2←bpdahd,baiio2
*baimsc←bpdahd,baimsc
*baiprc←bpdahd,baiprc
*baism1←bsm1hd,baism1
*baipd9←baipd9
.exec baism1

I should exec BAISM1(this is a sort of loader of the other REL files). But how can I run a REL file generated by FAIL ? Using DECUUO ?

larsbrinkhoff commented 6 years ago

I don't think you can run a REL file in DECUUO. Can TOPS-10 or WAITS do this? A REL file would normally need to be linked to be run.

DECUUO can run TOPS-10 and WAITS programs. Like those with an extension of EXE, SHR, LOW, DMP.

TheFausap commented 6 years ago

Ok. The exec command in TOPS-10, compile (if needed) then loads the REL file into the core, and run it. To do that in ITS, maybe we should use a loader...

larsbrinkhoff commented 6 years ago

Ah yes, that sounds like a TOPS-10 thing to do.

FAIL in ITS is hacked to write the MIDAS/STINK REL format. So you should be able to use STINK to make an executable file from one or more REL files.

It uses a peculiar command syntax. See .INFO.; STINK DOC for information. There are also a few sample LOADER files in the repository.

atsampson commented 6 years ago

BAIL.DOC says that when you compile a program with the /B switch, BAIL.REL "is loaded automatically when the program is loaded". There's an example of starting and using it in there.

MAPS shows MC: DECSYS; BAIL REL, so try putting it there, then compiling a SAIL program with /B?

rmaldersoniii commented 6 years ago

I keep seeing a lot of interest in WAITS programs, in the form of forcing^Wporting them into ITS. Would anyone be interested in an account on a real WAITS system (KL-1095 running WAITS, with emulated RP07 disks), for an experience different from ITS?

TheFausap commented 6 years ago

@larsbrinkhoff I tried to copy the idea of fail.loader, but I'm not sure what is the output: a TS file ? I did in this way:

:STINK
*MBAISM1;JOBDATL$$
*JBAISM1TD$$
*

$ is ESC. But I have no outputs from commands and also I have no TS BAISM1 (I should have this or not?). @atsampson I think running this BAISM1, I should have the BAIL.REL as output.

TheFausap commented 6 years ago

Ok, maybe I understood my error: if I don't use a command file, I need to give all the commands in one line separated by ESC and ending with a double ESC. So, this should be: MBAISM1$JBAISM1$TD$$ and in this case my STINK job became BAISM1 (if I do $$v I can see that).

But now ? I could use a PDUMP to create a TS file or what ?

TheFausap commented 6 years ago

@rmaldersoniii This could be nice. Thanks!

larsbrinkhoff commented 6 years ago

Yes, you do have to get your ESCs right. I think you don't need everything on one line; try ending all commands with double ESC. (Also known as ALTMODE.)

Yes, the STINK output is a regular "TS" ITS executable, in SBLK format.

I got a WAITS account the other day, and it's very interesting to snoop around! There's a long-standing tradition of porting between ITS and WAITS. Let's keep it going.

TheFausap commented 6 years ago

I'm looking the build procedure of DRAW. I do not understand all the steps:

SUDS drawing program [...] respond "" ":fail d\r" --- use the file d.files as command procedure for FAIL and generate REL files [...] respond "" ":stink d\r" --- call stink using d.loader as command procedure

The file d.loader contains (side-question: how can I type an ESC char in :

msail;jobdat$1
mDRAW;d$1
MWL;BOARDS$L
jd$1?Wtd

[...]

respond "??" "\033\0331L decsys; decbot bin\r"

Now I'm lost: Are the two ESC completing the commands in the d.loader file ? If so, I return to DDT, but the following command (L decsys... etc) is a STINK command not a DDT one.

respond "*" ".jbsa/strt\r" respond ":" "56/107\r"

Another question: the commands in STINK should be terminated by double ESC... but I cannot see them.

respond "\n" ":pdump datdrw; d bin\r" respond "*" ":kill\r"

The next step is the pdump, and this is ok. If I do something similar, creating a loader file:

Msail;jobdat$1
Mfausap;baism1$L
jbaism1$1?td

I have an Non-existent memory error. I tried with/without W

larsbrinkhoff commented 6 years ago

I'll try to adress all your questions.

:fail d assembles the file D >. D FILES isn't involved.

Correct, :stink d uses D LOADER.

You can type an ESC character in EMACS like this: Control-Q ESC

The command in D LOADER isn't 1 but l. Maybe your terminal font doesn't make a clear distinction between 1 and lowercase l. msail;jobdat$l is two commands: M...$ sets the file name, and L loads a REL file.

The build script uses ?? to see STINK is finished. If you try :cwd draw and then :stink d in ITS you can see better what's going on.

$$1L isn't a STINK command but a DDT command. Last in the LOADER script is the command D, which makes STINK exit to DDT. $L is the DDT command to load a file. If you type double ALTMODE, DDT will merge instead of load. If you add a 1 prefix argument, DDT will skip the symbo table. So in this case, insert DECSYS; DECBOT BIN into the D job core image and ignore the symbols.

I think double ESC isn't needed when STINK reads from a file.

The NXM may be because you use the 1 STINK command instead of L.

TheFausap commented 6 years ago

Thanks Lars. the NXM error is generated by loading BAISM1, and I checked with STINK that relocation factor is 100, so may this address is wrong. But how can I be sure ?

larsbrinkhoff commented 6 years ago

Sorry, I can't answer that. I don't know. But the NXM is a serious error not matter what STINK does, and that should be looked into.

larsbrinkhoff commented 5 years ago

Since we have made progress on PUB (#841), it's would be nice to get the SAIL compiler going.

I see files TS SAILV and TS SAILC. From recent snooping in the PUB directory, I see SAILV may be the "file salvager". Strings in TS SAILV match those in PUB; LISTER 1 and PUB; PSAILV 2. The message "NULLS DELETED" makes me think it's a program to make an ordinary text file from a file saved by the E editor in use at SAIL.

TS SAILC would then be the compiler, by my guess.

CC @bgbaumgart

larsbrinkhoff commented 5 years ago

I tried the binary in SAIL; TS SAILC, but it doesn't seem to work quite right. Here's an attempt to compile the PUB; ABC 10 file.


*:sail;sailc
*abc_abc.10
ABC.10 1
  SHARE. 1
    GLOBE. 1
      SITE. 1 2
      COMMON. 1 2
     2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
?BOGUS IDENTIFIER IN IDENTIFIER LIST.
GLOBE, PAGE 16
00300           LONG,
                      comment, TRUE in a LONG etc. command;

^
larsbrinkhoff commented 5 years ago

The line that SAILC complains about is this one:

        LONG, comment TRUE in a LONG etc. command;

I compared with the Saildart file GLOBE.SAI[PUB,SYS]3 and found this:

comment LONG, comment TRUE in a LONG etc. command.  (*** Seems not to be used,
         and is no longer legal in Sail anyway.  Flushed by MJC, 6/1/77.);
larsbrinkhoff commented 5 years ago

Now this:


ABC.10 1
  SHARE. 1
    GLOBE. 1
      SITE. 1 2
      COMMON. 1 2
     2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
    PROCS. 1 2
WARNING: Form-feed while scanning false conditional compilation.
Last source-file macro: PROCEDURES  00500/1
Current macro: FALSE
 3 4 5 6
WARNING: Form-feed while scanning false conditional compilation.
Last source-file macro: PRIVATE  06300/5
Current macro: ENDC
 7
WARNING: Form-feed while scanning false conditional compilation.
Last source-file macro: PRIVATE  06200/6
Current macro: PRIVATE
 8 9 10
?UNDECLARED IDENTIFIER: SHARE, PAGE 1
04700      COMMENT
                   EXTERNAL AND FORWARD PROCEDURES ;
larsbrinkhoff commented 4 years ago

Hello @kahrs,

Here are some notes from me attempting to run the SAIL compiler found on ITS, to compile PUB:
https://github.com/PDP-10/its/issues/843#issuecomment-489303183

I had a false recollection I was trying to compile the SAIL compiler itself, but that was not the case.