- Get TK4- MVS Sofware
- Get wc3270 Terminal Emulator
- Install wc3270 Terminal Emulator
- Install and Run MVS 3.8j
- Logging In to/Out of MVS 3.8j
- Shutting down MVS 3.8j from TSO
- Using TSO RFE Application
- Adding a User
- Creating Datasets
- JCL Overview
- Your First Cobol Program
- Your First Assembler Program
- Your First Fortran Program
- Your First PL/1 Program
Your First 370 Assembler Program
000001 WRMSG START
000002 STM 14,12,12(13) STORE REGISTERS IN CALLERS AREA
000003 BALR 12,0 SETUP REGISTER 12 AS BASE
000004 USING *,12
000005 ST 13,SAVEAREA+4 STORE ADDRESS OF CALLERS AREA
000006 LA 13,SAVEAREA ESTABLISH OUR SAVEAREA
000007 * WRITE 'HELLO, WORLD" ON WHATEVER HAS BEEN SETUP AS SYSPRINT IN
000008 * THE INVOKING JCL (NO, UNIX DOESN'T HAVE A MONOPOLY ON DEVICE-
000009 * INDEPENDENT I/O])
000011 OPEN (SYSPRINT,OUTPUT)
000012 PUT SYSPRINT,HELLOMSG
000013 CLOSE SYSPRINT
000014 * RESTORE THE SAVEAREA TO THE REGISTERS
000015 L 13,SAVEAREA+4 RESTORE CALLERS R 13
000016 LM 14,12,12(13) RESTORE CALLERS REGISTERS
000017 LA 15,0 RETURN CODE
000018 BR 14 RETURN
000020 SAVEAREA DS 18F
000021 HELLOMSG DC C' HELLO WORLD '
000022 SYSPRINT DCB DSORG=PS,MACRF=PM,DDNAME=SYSPRINT,
000024 END WRMSG
Assembler is the first compiler written for a new operating system. It is easily
translatable to the machine code that the computer uses.
Creating a source dataset
The creation of a source dataset along with the first member is covered in the First
COBOL program. Create another source dataset named 'learn.asemblr.src' and create a member
Assembler is an interesting programming language. It is closest to the
actual hardware. Since it is so close to the hardware, it also, when written
correctly, executes faster than the other programming languages.
One thing that is unique about assembler is that to run propertly it has to
establish linkage with the calling or any called program. This is not required
when programming in COBOL, FORTRAN, or PL/1.
Let's go over the assembler code
|1||This is the start of the program and needs a name. The name to this is WRMSG.
|2||There are values in the registers that have significance to the
calling progam. Register 13 points the the calling program's save area. And
this statement copies all register from register 14 through register 12 into the
area twelve bytes into the save area. So the order that these registers are saved
are 14,15,0,1,2,3,4,5,6,7,8,9,10,11, and 12. Notice that register 13 is not copied.
|3-4||These establish register 12 as the base register and
the USING statement establishes the contents of register 12 to be the next executable
|5||This statement stores register 13 into the area four bytes
into the savearea in our program. This effective save the address of the caller's
|6||This statement loads the address of our savearea into
|11||This executes the assembler macro OPEN and opens our DCB
SYSPRINT as output.
|12||This executes the PUT macro telling it to put
the data described HELLOMSG onto the output file SYSPRINT.
|13||The executes the CLOSE macro which closes the
output file SYSPRINT.
|15||Restores register 13 with the area where we saved
it on line 5. This now make register 13 point to the save area in the caller's
|16||This restores the registers 12 bytes from the
beginning of the callers save area. This is the reverse of line 5
|17||This loads register 15 with a value of 0. Register
15 contains the return code by convention.
|18||This returns to the statement referenced by register
|20||This is our programs save area. It reguires a space of
18 full words. That allows it to hold the 15 registers 14, 15, 0 - 12. Plus space
for three registers at the front of the save area.
|21||This is the definition of the character variable HELLOMSG.
|22-23||This is the definition of the SYSPRINT Data Control Block. It's
DSORG is PS meaning it is a sequential file, MACRF is PM meaning it is a PUT DCB, DDNAME is
SYSPRINT, RECFM memans it is Fixed Block, LRECL means the record length is 166 characters,
BLKSIZE means the blocksize is 100 records.
|24||This indicates that it is the end of the source module
WRMSG. Notice that this is the same name as the START module name.
You can take lines 1 - 13, 14-20, and line 24, put them in a copy src and then whenever you are
writing an assembler program copy that into a new member and you already have your linkage done for you.
Compile, Link, and Go
Now that we have a dataset member containing our ASSEMBLER program we are not finished. We need
a way to assemble the source, link it with any link modules that are needed and execute the
resulting program. There are two ways that will be discussed here on how to accomplish the
compile, link, and go.
- JCL Job Stream with embedded source
- JCL Job Stream with external source
000001 //RLAWW1 JOB (WRMSG),'WRT MSG TO PRT',
000002 // CLASS=A,MSGCLASS=H,MSGLEVEL=(1,1)
000003 //STEP01 EXEC ASMFCG,PARM.ASM=(OBJ,NODECK),MAC1='SYS2.MACLIB'
000004 //ASM.SYSIN DD *
000005 WRMSG START 0
000006 STM 14,12,12(13) STORE REGISTERS IN CALLERS AREA
000007 BALR 12,0 SETUP REGISTER 12 AS BASE
000008 USING *,12
000009 ST 13,SAVEAREA+4 STORE ADDRESS OF CALLERS AREA
000010 LA 13,SAVEAREA ESTABLISH OUR SAVEAREA
000011 * WRITE 'HELLO, WORLD" ON WHATEVER HAS BEEN SETUP AS SYSPRINT IN
000012 * THE INVOKING JCL (NO, UNIX DOESN'T HAVE A MONOPOLY OR DEVICE-
000013 * INDEPENDENT I/O])
000015 OPEN (SYSPRINT,OUTPUT)
000016 PUT SYSPRINT,HELLOMSG
000017 CLOSE SYSPRINT
000018 * RESTORE THE SAVEAREA TO THE REGISTERS
000019 L 13,SAVEAREA+4 RESTORE CALLERS R 13
000020 LM 14,12,12(13) RESTORE CALLERS REGISTERS
000021 LA 15,0 RETURN CODE
000022 BR 14 RETURN
000024 SAVEAREA DS 18F
000025 HELLOMSG DC C' HELLO WORLD '
000026 SYSPRINT DCB DSORG=PS,MACRF=PM,DDNAME=SYSPRINT,
000028 END WRMSG
000030 //GO.SYSPRINT DD SYSOUT=*
When the source code is embedded in a jcl job steam then the DD that references the input
for the compile step is coded as a "here" document. Notice line 4 in the above images. It
says //ASM.SYSIN DD *. This statement means that in the ASM step (which is part of the exec
procedure) has a SYSIN DD that this job stream is providing as in instream dataset. This is
done in lines 5 - 28 followed by a line that says /* which means end of instream dataset.
The next to last line (line 30)
is for the GO step of the job and is referenced in programs as the SYSPRINT file. Notice line 26 of the
program where is defines that the file SYSPRINT in the assembler program is externally SYSPRINT. The
GO.SYSPRINT jcl statement says the the output is based on the job parameters and its DCB (DATA
CONTROL BLOCK) is Fixed Block A, record length is 166, and block size is 16600. The
And the organizaton is a physical sequenal file and it uses the macro PM which is the put macro this line
is followed by line 31 which marks the end of the job stream.
The advantage to have the assembler source as a "here" document in the job stream is that you
can modify the source, save it, and submit it all on one screen.
//RLAWAS JOB (WRMSG),'WRT MSG TO PRT',
//STEP01 EXEC ASMFCG,PARM.ASM=(OBJ,NODECK),MAC1='SYS2.MACLIB'
//ASM.SYSIN DD DSN=LEARN.ASEMBLR.SRC(FIRSTPGM),DISP=OLD
//GO.SYSPRINT DD SYSOUT=*
The advantage to having the JCL seperate from the assembler source is that there
is only one copy of the JCL and it is reusable with changing the ASM.SYSIN DSN name.
Also, if the assembler program was large, as many of them are it is easier to have the
assembler progam seperate and the steps to build would be standard for all programs.