## BASIC Programming on MVS

There are many flavors of BASIC available for the IBM MVS operating system. The original port of Dartmouth BASIC, known as DTSS BASIC, is called BASIC/360, and is already implemented by the supplement tape for MVS 3.8j. So, everything I do on the emulator is based on that version of BASIC.

Here's the original comment flower box from the core BASIC/360 compiler module, written in PL/I. The users of this BASIC compiler did not need to compile th PL/I from source, however. The binary would have been available on the original distribution tape. 

<pre class="mvs">
 000002  /********************************************************************
 000003  *                                                                   *
 000004  *   SOUTH HAMMOND INSTITUTE OF TECHNOLOGY  BASIC/360   FALL 1974    *
 000005  *                                                                   *
 000006  *********************************************************************
 000007  *                                                                   *
 000008  *   IMPLEMENT A BASIC COMPILER/INTERPRETER FOR THE IBM/360          *
 000009  *   USING THE ORIGINAL DARTMOUTH SPECS FOR BASIC.  THE PRIMARY      *
 000010  *   INTENT IS TO CREATE A BASIC COMPILER/INTERPRETER FOR BEGINNING  *
 000011  *   STUDENTS TO LEARN THE BASIC LANGUAGE INSTEAD OF GOTRAN ON THE   *
 000012  *   SOON TO BE RETIRED 1620.                                        *
 000013  *                                                                   *
 000014  *   THE TARGET ENVIRONMENT IS A 32K IBM/360 MOD 30 RUNNING          *
 000015  *   DOS/360 AND PL/I(D) COMPILER.                                   *
 000016  *                                                                   *
 000017  *   STUDENTS MAY NOT BE COMPUTER MAJORS AND MOST PROGRAMS WOULD BE  *
 000018  *   SMALL, A SIMPLE MONITOR MONITOR WAS IMPLEMENTED SO THE LAB AID  *
 000019  *   OR INSTRUCTOR COULD ACTUALLY SUBMIT ALL THE BASIC PROGRAMS AS   *
 000020  *   ONE JOB.                                                        *
 000021  *                                                                   *
 000022  *   THIS PACKAGE IS BEING DESIGNED TO HAVE MODULAR SOURCE CODE      *
 000023  *   SINCE IT ENVISIONED THAT THIS PRODUCT WILL BE IMPLEMENTED       *
 000024  *   IN SEVERAL DIFFERENT ENVIRONMENTS                               *
 000025  *      1) SIMPLE BATCH - 1 BASIC PROGRAM AT A TIME                  *
 000026  *      2) MONITOR BATCH - MULTIPLE BASIC PROGRAMS CAN BE EXECUTED   *
 000027  *                         PER RUN.                                  *
 000028  *      3) ONLINE (WISH) - BASIC PROGRAM CAN BE ENTERED, EDITED AND  *
 000029  *                         EXECUTED ON LINE.                         *
 000030  *                                                                   *
 000031  ********************************************************************/
</pre>

Here's a copy of the very first BASIC program. A simple mortgage calculator that I copied directly from the Dartmouth Time-Share System BASIC implementation. This program runs as-is, in BASIC/360:

<pre class="mvs">
 000001 1 REM MORTGATE COMPUTER
 000002 10 DATA 0.05,28500,170,1,1964
 000003 50 READ I,P,P1,M,Y
 000004 60 LET R=1+I/12
 000005 70 PRINT "YEAR", "PRINCIPLE"
 000006 80 PRINT Y,P
 000007 90 LET P=P*R-P1
 000008 100 IF P>0 THEN 120
 000009 110 LET P=0
 000010 120 LET M=M+1
 000011 130 IF M>12 THEN 160
 000012 140 PRINT "          ",
 000013 150 GOTO 190
 000014 160 LET M=1
 000015 170 LET Y=Y+1
 000016 180 PRINT Y,
 000017 190 PRINT INT(P)
 000018 200 IF P>0 THEN 90
 000019 210 END  
</pre>

To run this on MVS, you need a JCL job card deck, to define the batch job to the system. Here's a version that is designed to run interactively. I'm using this JCL, because the program in "monitor" mode is designed to self-terminate after 5000 iterations of a loop. This "interactive" version will produce the complete set of output. 

<pre class="mvs">
 000001 //@050541 JOB (BASIC),'BASIC INTERACTIVE',NOTIFY=&SYSUID,
 000002 //        CLASS=S,
 000003 //        MSGCLASS=A,
 000004 //        MSGLEVEL=(1,1)
 000005 //*
 000006 //*   BASIC INTERACTIVE
 000007 //*
 000008 //S1    EXEC PGM=BASIC1UP
 000009 //STEPLIB  DD DSN=SYSC.LINKLIB,DISP=SHR
 000010 //         DD DSN=SYSC.PL1LIB,DISP=SHR
 000011 //SYSPRINT DD SYSOUT=*
 000012 //RENUMFL  DD DUMMY,DCB=BLKSIZE=80
 000013 //SYSIN  DD DSN=@05054.SRCLIB.BASIC(MYMORT1),DISP=SHR
 000014 //KEYINPT  DD *
 000015 "THIS IS A TEST"
 000016 // 
</pre>

Mainframe batch jobs are designed from the start to produce printed output. They were written in an era where end-user applications presented interactively on a screen were not really an option. The only people who had screens were engineers, system operators, and programmers. Everyone else interacted with computers by way of printed output. To see the output from this program, you can [download it here](http://gmgauthier.us-east-1.linodeobjects.com/docs/mymort1.pdf).
