Search

Wednesday, December 7, 2016

OpenVMS VAX Compiler Fun: Hello World in BASIC, BLISS-32, 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
$

BLISS-32

$ TYPE HELLO_BLISS.BLS
%TITLE 'HELLO_WORLD'
MODULE HELLO_WORLD (IDENT='V1.0', MAIN=HELLO_WORLD,
        ADDRESSING_MODE (EXTERNAL=GENERAL)) =
BEGIN
    LIBRARY 'SYS$LIBRARY:STARLET';
EXTERNAL ROUTINE
        LIB$PUT_OUTPUT;
    GLOBAL ROUTINE HELLO_WORLD =
BEGIN
LIB$PUT_OUTPUT(%ASCID %STRING('Hello World!'))
END;
 END
    ELUDOM
$  TYPE HELLO_BLISS.LIS
                HELLO_WORLD                                      8-Jan-2020 02:08:10    VAX Bliss-32 V4.4-838               Page   1
                                                                 8-Jan-2020 02:06:04    DUA1:[SANYAL.TEMP]HELLO_BLISS.BLS;1      (1)

;   0001  0     %TITLE 'HELLO_WORLD'
;   0002  0     MODULE HELLO_WORLD (IDENT='V1.0', MAIN=HELLO_WORLD,
;   0003  0             ADDRESSING_MODE (EXTERNAL=GENERAL)) =
;   0004  1     BEGIN
;   0005  1         LIBRARY 'SYS$LIBRARY:STARLET';
;   0006  1     EXTERNAL ROUTINE
;   0007  1             LIB$PUT_OUTPUT;
;   0008  1         GLOBAL ROUTINE HELLO_WORLD =
;   0009  2     BEGIN
;   0010  2     LIB$PUT_OUTPUT(%ASCID %STRING('Hello World!'))
;   0011  1     END;


                                                                          .TITLE  HELLO_WORLD HELLO_WORLD
                                                                          .IDENT  \V1.0\

                                                                          .PSECT  $PLIT$,NOWRT,NOEXE,2

            21  64  6C  72  6F  57  20  6F  6C  6C  65  48  00000 P.AAB:  .ASCII  \Hello World!\                              ;
                                                  010E000C  0000C P.AAA:  .LONG   17694732                                    ;
                                                  00000000' 00010         .ADDRESS P.AAB                                      ;

                                                                          .EXTRN  LIB$PUT_OUTPUT

                                                                          .PSECT  $CODE$,NOWRT,2

                                                       0000 00000         .ENTRY  HELLO_WORLD, Save nothing                   ; 0008
                                              0000'  CF  9F 00002         PUSHAB  P.AAA                                       ; 0010
                            00000000G  00            01  FB 00006         CALLS   #1, LIB$PUT_OUTPUT                          ;
                                                         04 0000D         RET                                                 ; 0011

; Routine Size:  14 bytes,    Routine Base:  $CODE$ + 0000


;   0012  1      END
;   0013  0         ELUDOM






;                                      PSECT SUMMARY
;
;       Name                     Bytes                         Attributes
;
;  $PLIT$                              20  NOVEC,NOWRT,  RD ,NOEXE,NOSHR,  LCL,  REL,  CON,NOPIC,ALIGN(2)
;  $CODE$                              14  NOVEC,NOWRT,  RD ,  EXE,NOSHR,  LCL,  REL,  CON,NOPIC,ALIGN(2)




;                               Library Statistics
;
;                                            -------- Symbols --------      Pages       Processing
;       File                                 Total    Loaded   Percent      Mapped      Time
;

HELLO_WORLD     HELLO_WORLD                                      8-Jan-2020 02:08:10    VAX Bliss-32 V4.4-838               Page   2
V1.0                                                             8-Jan-2020 02:06:04    DUA1:[SANYAL.TEMP]HELLO_BLISS.BLS;1      (1)

;  SYS$COMMON:[SYSLIB]STARLET.L32;1          24705         0         0      1450          00:00.1







;                                       COMMAND QUALIFIERS

;       BLISS32/LIST HELLO_BLISS.BLS

; Size:         14 code + 20 data bytes
; Run Time:        00:00.2
; Elapsed Time:    00:00.3
; Lines/CPU Min:    3900
; Lexemes/CPU-Min: 27600
; Memory Used:  51 pages
; Compilation Complete

$ LINK/MAP HELLO_BLISS.OBJ
$ RUN HELLO_BLISS.EXE
Hello World!
$ 

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 (excluding BLISS-32 which was added to this post a long time after initial publication)  from my google drive.


No comments:

Post a Comment

"SEO" link builders: move on, your spam link will not get posted.

Note: Only a member of this blog may post a comment.

Recommended Products from Amazon