Search

Wednesday, December 7, 2016

OpenVMS VAX Compiler Fun: Hello World in BASIC, C, C++, COBOL, FORTRAN and PASCAL

OpenVMS VAX Compiler Fun: Hello World in BASIC, C, C++, COBOL, FORTRAN and PASCAL
Beginning of C Compiler Listing file with Machine Code

I just brought up my 2nd SIMH VAX - a VAX-11/780 named CLOUDY with a DECnet address of 1.551. I installed BASIC, C, C++, COBOL, FORTRAN and PASCAL compilers on it one by one, and tested each with a little "Hello, World" derivative.

There is a free public guest account on CLOUDY VAX if you want to write programs in any of these languages. To get to it, telnet to my oldest VAX - a VAXserver 3900 at sanyalnet-openvms-vax.freeddns.org, login to guest account (password is in the SYS$WELCOME banner), and choose the option to SET HOST CLOUDY. You can then login to the guest account on CLOUDY the same way.

BASIC

$ TYPE HELLO_BAS.BAS
10 PRINT "   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0"

$ BASIC

VAX BASIC V3.9-000

Ready

 Exit
$ BASIC HELLO_BAS.BAS
$ LINK HELLO_BAS.OBJ
$ RUN HELLO_BAS.EXE
   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0
$

C

$ TYPE HELLO_C.C
#include<stdio.h>
main()
{
        printf("   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0\n");
}

$ CC/VERSION
Compaq C V6.4-005 on OpenVMS VAX V7.3
$ CC HELLO_C.C
$ LINK HELLO_C.OBJ
$ RUN HELLO_C.EXE
   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0
$

C++

$ TYPE HELLO_CXX.CXX
#include <iostream>

int main()
{
        cout << "   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0\n";
}
$ CXX/VERSION
Compaq C++ V5.6-023 on OpenVMS VAX V7.3
$ CXX HELLO_CXX.CXX
$ LINK HELLO_CXX.OBJ
$ RUN HELLO_CXX.EXE
   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0
$

COBOL

$ TYPE HELLO_COBOL.COB
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
* simple hello world program
PROCEDURE DIVISION.
P0.
    DISPLAY '   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0'.
    STOP RUN.
$ COBOL HELLO_COBOL.COB
$ LINK HELLO_COBOL.OBJ
$ RUN HELLO_COBOL.EXE
   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0
$

FORTRAN

$ TYPE HELLO_FOR.FOR
      program main
      implicit none
      write ( *, '(a)' ) '   OpenVMS (TM) VAX Version V7.3'
      write ( *, '(a)' ) '   Major version id = 1 Minor version id = 0'
      stop
      end
$ FORTRAN HELLO_FOR.FOR
$ LINK HELLO_FOR.OBJ
$ RUN HELLO_FOR.EXE
  OpenVMS (TM) VAX Version V7.3
  Major version id = 1 Minor version id = 0
FORTRAN STOP
$

PASCAL

$ TYPE HELLO_PAS.PAS
program Hello(output);

begin
  writeln ('   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0');
end.
$ PASCAL/VERSION
Compaq Pascal V5.8-90 on OpenVMS VAX V7.3
$ PASCAL HELLO_PAS.PAS
$ LINK HELLO_PAS.OBJ
$ RUN HELLO_PAS.EXE
   OpenVMS (TM) VAX Version V7.3     Major version id = 1 Minor version id = 0
$

EXECUTABLE SIZE COMPARISON

Here are the sizes of the executables produced by the different compiler and linker invocations. BASIC and FORTRAN came in with the biggest EXE sizes, while C and Pascal EXEs are the smallest. COBOL and C++ executables are in the middle in terms of executable sizes. I was a bit surprised since I was expecting C++ to come in the biggest.

$ DIR /SIZE HELLO*.EXE

Directory DUA2:[GUEST]

HELLO_BAS.EXE;1            6
HELLO_C.EXE;1              4
HELLO_COBOL.EXE;1          5
HELLO_CXX.EXE;1            5
HELLO_FOR.EXE;1            6
HELLO_PAS.EXE;1            4

Total of 6 files, 30 blocks.
$

DOWNLOAD

You can download all of these source, object and executable files along with source listings including machine code and link map files with cross-reference from my google drive.


No comments:

Post a Comment

Recommended Products from Amazon