rcornwell / sims

Burroughs B5500, ICL1900, SEL32, IBM 360/370, IBM 7000 and DEC PDP10 KA10/KI10/KL10/KS10, PDP6 simulators for SimH
http://sky-visions.com
95 stars 20 forks source link

KI10: FORTRAN compiler errors on Real data types #104

Closed pascalgp closed 5 years ago

pascalgp commented 5 years ago

Under Fortran 5A(621), TOPS-10 6.03 on the KI10 emulator.

This will compile correctly (assign value to implicitly declared integer)

.copy testi.for=tty:
      I=1
      END
^Z

.r fortra

*testi=testi
MAIN.
*^Z

However, assigning a value to a variable of type Real results in a system error

.copy testa.for=tty:
      A=1
      END
^Z

.r fortra

*testa=testa

?INTERNAL COMPILER ERROR
?MEMORY PROTECTION VIOLATION AT LOCATION 407224 IN PHASE FORTB
?WHILE PROCESSING STATEMENT 00001

It will compile without error on the KA10 as well as under 7.03/SIMH (KS10) with the same compiler.

rcornwell commented 5 years ago

Since this happens under both KA and KS sims this sounds like a compiler bug. I would recommend generating a listing of the compiler, setting a break point at that location and seeing what is going wrong. I have run the compiler through the NBSFortran IV test suite and other than a problem with numeric input it passes all tests. Also it should be "A=1.0" Fortran has no automatic type conversion.

If you find a solution send me a patch and I will add it to my build scripts.

pascalgp commented 5 years ago

The DEC compilers will perform an integer to real conversion in such cases. For example, this code compiles and runs correctly on the KA-10 (Fortran 5A - 6.03) and KS-10 (Fortran 5A - 7.03):

      REAL A,B,C
      A=123.0
      B=14.0
      C=A+2*B
10    FORMAT(F8.2)
      WRITE(5,10) C
      END

It fails to compile on the KI-10 emulator with the same system error as with the more trivial example.

I built FORTB.EXE and looking at the map and code, the error occurs int the CNSTCM module (at offset 646) which relevantly handles type conversions. The code at fault is described in the comments as "FROM INTEGER TO DOUBLE-PREC OR REAL". I uploaded the listings for reference.

I went ahead and loaded Fortran 6 which the documentation indicates will run on the KI. This compiler also gives a system error on compilation. If I substitute 2 with 2.0 then it compiles but execution gives a system error. This code will compile and run correctly on the KS10 emulator.

.copy test2.for=tty:
      REAL A,B,C
      A=123.0
      B=14.0
      C=A+2.0*B
10    FORMAT(F8.2)
      WRITE(5,10) C
      END
^Z

.r fortra

*test2=test2
MAIN.
*^Z

.load test2
LINK:   Loading

EXIT

.save
TEST2 saved

.run test2

?
?Proprietary violation at user PC 400044

fortb.prn.gz

rcornwell commented 5 years ago

Now a propriety violation means something in the pager. If it is occurring at 646, this is location INTDP1, which would come from 636 via a jrst, However since we are fetching on the same page, there should be no change in the PUBLIC flag.

Note Tops10 from 7.03 on uses Tops20 style paging, so the paging is not the same. I will have to dig into this when I finish the PDP6 changes. Note KI-10 passes DBKEA,B,C diags without any error.

Is this with VMSER version or non-vmser version or does it occur on both?

pascalgp commented 5 years ago

That was on a monitor built with VMSER. The same code also compiled with FORTRA 6(1144) fails exactly the same way and at the same program counter location (400044) on a KI monitor without VMSER.

rcornwell commented 5 years ago

Fixed an issue with DP FP code. It was setting modify flag for fetching second half of operand.

pascalgp commented 5 years ago

The problem no longer occurs with Fortran 5A. APLSF would also crash on FP operations but that is no longer the case. Thank you. Fortran 6 (KI and KV) still gives a runtime error. Maybe it would run on a 7 monitor but we don't have a way to test this.

.r fortra

*^Z

.ver
FORTRA 6(1144) + 
.copy test.for=tty:
      REAL A,B,C
      A=123.0
      B=14.0
      C=A+2.0*B
10    FORMAT(F8.2)
      WRITE(5,10) C
      END
^Z

.exec test
FORTRAN: TEST
MAIN.   
LINK:   Loading
[LNKXCT TEST Execution]
?
?Proprietary violation at user PC 400044

.
rcornwell commented 5 years ago

Did you recompile Fortran 6 or just use it off the tape? I can try Fortran 6 and see if I can reproduce it.

pascalgp commented 5 years ago

That was with the binaries from the tape. I rebuilt the compiler from sources and get the same error when running the test.

rcornwell commented 5 years ago

I will add Fortran 6 to my build as an option for the KI, is there any other languages that should be updated for the KI?

pascalgp commented 5 years ago

I'm not aware of other languages available that would run on the KI but not on the KA. I've tested these successfully on the KA:

BASIC 17E Fortran 5A Algol Version 10A COBOL-68 V12A SORT V4 (302) (+ edits 322 and 332 from V4B to play well with IQL) IQL V3A DBMS-10 V5A

DECUS:

SNOBOL4 (3.4.3) / [43,50150] University of Hamburg Pascal (30-DEC-76) / [43,50417] UCI Lisp 1.6 / [43,50322] University of Pennsylvania Medical School BASIC V-1 / [43,50516] Caltech Forth / [43,50361] Simula 4A(310) / [43,50337,03]simerr.err, [43,50337,04] Pilot / [43,50355] FOCAL-10 / [43,50462] RPGII-10 / [43,50517] CPL / [43,50126]cpl.exe MATHLAB / [43,50216]

rcornwell commented 5 years ago

I am in the process of cleaning up KI DP FP code so it will work correctly. Also fixed an issue with Overflow handling in executive mode. Once I fix DP FP I will try Fortran 6.

rcornwell commented 5 years ago

I did some fixing to KI to properly handle Overflow in Executive mode. Also DP and regular FP is almost 100%. There are still some edge cases that I have not passed. Give Fortran 6 a test and let me know if it works or not now. Keep this issue open until Fortran 6 is in the KI builds.

pascalgp commented 5 years ago

I am still getting the error: ?Proprietary violation at user PC 400044

rcornwell commented 5 years ago

Ok. I will try and set up Fortran 6 this weekend. If you can set instruction history and give me the last couple instructions before the violation and a few after that might help.

pascalgp commented 5 years ago

I can't determine looking at the instruction trace where the error occurs. According to the load map, 400044 is somewhere in the high segment of the FORINI section of the Fortran library (FORLIB.REL).

rcornwell commented 5 years ago

I pushed out some more changes to fix some paging issues with KI. It now reports PC out of range. The problem appears to be a page fault going to 400044 where the page is not accessible. Perhaps you can run your tests and verify that everything else is still working.

pascalgp commented 5 years ago

I am also getting this error now:

?PC out of bounds at user PC 400043

Otherwise, I haven't encountered any new issues with this build.

rcornwell commented 5 years ago

I am going to close this issue. I did some checking on this and I do not believe that Fortran 6 can run on 6.03 without changes. What is happening is that forini.mac is doing a GETSEG call from the High segment. Tops 6.03 replaces the high segment with forots and then returns to after the GETSEG call which is now not in any memory page. To fix this forini.mac needs to be in low seg. I suspect that on Tops 10 7.xx the pages were replaced rather then replacing the whole segment. So the simulator is behaving correctly.