Jump to content
Sign in to follow this  
dhe

Fortran99 Challenge

Recommended Posts

2 hours ago, HOME AUTOMATION said:

Looks like, you left out this reciprocal instruction...

 

MOV  R11,@RETADR

Fortean 99 handles that automatically. All I have to do is reserve 4 bytes in BASEAD and RETADR. I should clarify that the subprogram returns normally to the main program and the main issue is when that main program terminates.

Share this post


Link to post
Share on other sites

OK I figured out how to properly restore the Fortran 99 environment after accessing files in bitmap mode with assembly subroutines.

Apparently the CRT has to be reopened as FILE 6 using something called the File Open Processor routine located at >2070 and I have no clue as what that routine does exactly. I got this straight out from the CALL FILES subroutine by sheer trial and error. Here's the revised bitmap image display routine:

 

       DEF  IMGSHW
 
VMBW   EQU  >2048
DSRLNK EQU  >2058
OPFILE EQU  >2070        FILE OPEN PROCESSOR
PABADR EQU  >3A12        PAB ADDRESS IN VDP
BASEAD BSS  2            SUBROUTINE RETURN POINTER
RETADR BSS  2            SUBROUTINE RETURN POINTER
 
 
IMGSHW DATA 0            NUMBER OF PASSED ARGUMENTS
       DATA BASEAD
 
PABP   DATA >0500,>0000,>0000,>1800,>000D
       TEXT 'DSK3.VIGER4_P'
       EVEN
PABC   DATA >0500,>2000,>0000,>1800,>000D
       TEXT 'DSK3.VIGER4_C'
       EVEN
 
CRTPAB DATA >0003,>0000,>5000,>0000,>0003
       TEXT 'CRT'
       EVEN
 
* LOAD PATTERN FILE
       LI   R0,PABADR
       LI   R1,PABP
       LI   R2,23
       BLWP @VMBW
       LI   R6,PABADR+9
       MOV  R6,@>8356
       BLWP @DSRLNK
       DATA 8
 
* LOAD COLOR FILE
       LI   R0,PABADR
       LI   R1,PABC
       LI   R2,23
       BLWP @VMBW
       LI   R6,PABADR+9
       MOV  R6,@>8356
       BLWP @DSRLNK
       DATA 8
 
* RETURN TO MAIN PROGRAM
       LI   R0,6
       LI   R1,CRTPAB
       BL   @OPFILE
       MOV  @BASEAD,R3
       MOV  @RETADR,R11
       B    *R11
       END
 
 

The 3 lines below the RETURN TO MAIN PROGRAM comment is where the magic occurs. Don't ask me why but would love to hear an explanation if somebody has one :lol:

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Finally got some simple i/o going...

Some first observations:

  1) I kept getting an odd error -  don't understand >eod - Vorticon nailed this error, some junk had appeared after end...

       ( I think this is a bug)... Easy enough to work around once you know what the problem is.....

  2) the end in the read, seems to sense end of data line, not end of file, I had to default to

       reading for a z (or 9999) record at the end of the data file.

  3) could not get Hollerith or S types to work in a file read.

  4) could not get just A to work.

  5) what ended up working was 8a1 - because, it seems like fortran99 only wants to do single character

      i/o.

 

1  99 FORTRAN File: DSK2.FI_S                                      Page    1
 
     1. C FI_S - FILE I/O SOURCE 04/06/2020
     2. C2345678
     3. C     DEFINE DATA TYPES
     4.       CHARACTER NAME(8)
     5.       INTEGER ERRSTS, NSTU, GRATOT, AVGGRA
     6.
     7.       INTEGER FILEID(8), GRADE
     8.       DATA FILEID / 10HDSK2.FI_D /
     9.
    10. C     INITALIZE DATA
    11.       NSTU = 0
    12.       GRATOT = 0
    13.       AVGGRA = 0
    14.
    15.       CALL FILES (3)
    16.       CALL OPEN ( 3, FILEID, 2, 0, 1, 0, 80, ERRSTS)
    17.
    18.     1 FORMAT (' ', C12, M1.1, '     ***  GRADES  ***' )
    19.     2 FORMAT (' ', ' ')
    20.       WRITE (6,1)
    21.       WRITE (6,2)
    22.
    23.    10 FORMAT ( 8A1, I3)
    24.    11 READ (3, 10, END=99, STATUS=ERRSTS ) NAME, GRADE
    25.
    26.       IF (GRADE.EQ.999) THEN
    27.          GO TO 25
    28.       ENDIF
    29.
    30.    20 FORMAT (' ', 8A1 , 1X, I3)
    31.       WRITE (6,20) NAME, GRADE
    32.
    33.       GRATOT = GRATOT + GRADE
    34.       NSTU   = NSTU + 1
    35.
    36.       GO TO 11
    37.
    38.
    39.    25 CONTINUE
    40.    30 FORMAT (' ',' ')
    41.    35 FORMAT ('+', 'AVG GRADE:')
    42.       WRITE (6,30)
    43.       WRITE (6,35)
    44.
    45. C     CALCULATE AVG GRADE - SIMPLE AVG
    46.       AVGGRA = GRATOT / NSTU
    47.    40 FORMAT (' ', I3)
    48.       WRITE (6,40) AVGGRA
    49.
    50.
    51. C 3 - FILE NUMBER, NO EQ TO A FORTRAN UNIT NUMBER USED IN FORMAT
    52. C 2 - INPUT MODE
    53. C 0 - DISPLAY
    54. C 1 - VARIABLE
    55. C 0 - SEQ ACCESS
1  99 FORTRAN File: DSK2.FI_S                                      Page    2
 
    56. C 80 - MAX RECORD LENGTH
    57. C ERROR - VARIABLE TO RETURN ERROR IN
    58.
    59. C     SEE PAGE 07-11 - FILE I/O REF
    60. C     SEE CALC1 FOR FILE I/O EXAMPLES
    61.
    62. C  NAME = 8   HOL
    63. C  SPACE = 1  HOL
    64. C  GRADE = 3  INT
    65.
    66.
    67.    99 CALL CLOSE ( 3 )
    68.       STOP
    69.       END

 

and the data file...

 

1  99 FORTRAN File: DSK2.FI_D                                      Page    1
 
     1. DAN     060
     2. SALLY   100
     3. BOB     074
     4. JOE     097
     5. EOF     999

Small working, byte size pieces of code is what you build off of.

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Yeah file I/O in Fortran 99 is not for the faint of heart :) I feel it would be better and much faster to do all file access from assembly except for the simplest of tasks...

Share this post


Link to post
Share on other sites

So, it was asked here, how does fortran99 compare speed wise to other compilers.

 

I decided to write two little programs that looped and printed a value. Our first contender, while not a compiled language, was BASIC

10 FOR I=1 TO 100
20 PRINT I
30 NEXT I

This took 19 seconds to run.

For a comparison - in BASIC on my little Cambridge Z88 - it took 8 seconds.

 

Next up was FORTRAN99

1  99 FORTRAN File: DSK2.SC_S                                      Page    1
 
     1. C QUICK FOR LOOP SPEED COMPARISON VS TI BASIC 04/07/2020
     2. C234567
     3.       INTEGER I
     4.
     5.       CALL CLEAR
     6.
     7.       I = 1
     8.       DO 1 I=1,100
     9.          PRINT , I
    10.
    11.     1 CONTINUE
    12.       STOP
    13.       END

This took 8 seconds to run.

 

Of course, even the simplistic program wasn't a walk in the park and included a fight with the compiler and linker. Over and above speed, not being tied to line numbers is great. I think Microsoft realized late in life, line numbers {BAD}, because on the Tandy Model 100, the last machine, I'm told that Bill Gates worked on, when you type edit, the line numbers are there, but your in full screen editing mode.

 

VORTICON again came to my rescue. The take away, I believe, if you want to use call clear (and maybe print) you have to link in the gl (graphics) library. The manual says, you will keep being prompted for libraries, until all dependencies have been resolved. That was not the behavior I was seeing. Instead, I would enter fl, and it would take me to the section about symbolic debugging. To force what I needed to happen, I entered gl on the library line, the linker, then prompted me again, for a library, this time, I entered fl.

 

That did the trick, I was now able to run the program, I did end up with so oddities, in the compiler. It would say I had 1 Error(s) - but it wouldn't tell me what that error was! fortran99 can be a tough task master! 😃

 

I'm very much, hoping someday the source for FORTRAN99 show up, because, as a new user, I'm seeing a few rough spots, that probably wouldn't be that hard to fix, with specific test cases.

 

d.

 

 

Share this post


Link to post
Share on other sites

In Extended Basic it takes about 10 secs.

 

I believe programs that scroll the screen will spend most of their time in the scrolling routine, so it's not a good comparison of the actual languages.

 

Edited by Asmusr

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...