willy jensen wrote:Unfortunately there is no 'zOS Assembler for beginners' nor a free self-study as already mentioned. There are still some people offering courses, but not for free. And neither will I. So I suggest that you try to find a mentor in your organization.
This small sample only demonstrates one method for starting and ending a program, plus a bit of I/O thrown in. By the way, this is a assemble-link-go, so the module is not stored permanently.
But there is of course much more to assembler than that. First you must decide in which environment the program will run.
Search the internet for 'ibm assembler language tutorial' and similar and see what pops up.
//ASMMINI JOB (WJ),'small asm pgm',CLASS=A,MSGCLASS=T,COND=(0,LT)
//*
// EXEC HLASMCLG,PARM.C='TERM',PARM.L='RMODE(24),AMODE(31)'
//C.SYSLIB DD DISP=SHR,DSN=SYS1.MACLIB
// DD DISP=SHR,DSN=SYS1.MODGEN
//C.SYSTERM DD SYSOUT=*
//C.SYSIN DD *
*PROCESS COMPAT(NOCASE,MACROCASE)
sysstate archlvl=2
*
* equate registers
*
r0 equ 0
r1 equ 1
r2 equ 2
r3 equ 3
r4 equ 4
r5 equ 5
r6 equ 6
r7 equ 7
r8 equ 8
r9 equ 9
r10 equ 10
r11 equ 11
r12 equ 12
r13 equ 13
r14 equ 14
r15 equ 15
*
* Macro for clearing area
*
Macro
CLEAR &area
mvi &area,c' ' clear
mvc &area+1(l'&area-1),&area target
Mend
*
* Program prolog
*
using ASMMINI,r12
ASMMINI amode 31
ASMMINI rmode any
ASMMINI csect
save (14,12)
larl r12,ASMMINI
sam31
* get dynamic storage
getmain R,lv=workln
lr r10,r1
using work,r10
* chain saveareas re linkage conventions
la r14,sa1
st r13,4(,r14)
st r14,8(,r13)
lr r13,r14
*
* open files
*
Open (infile,(input))
Open (prtfile,(output))
*
clear prtrec
mvc prtrec(20),=cl20'*Starting program'
put prtfile,prtrec
*
* read and list
*
Readit equ *
get infile,inrec
clear prtrec
mvc prtrec,inrec
put prtfile,prtrec
j readit
Readend equ *
clear prtrec
mvc prtrec(25),=cl25'*End of file reached'
put prtfile,prtrec
* remove the asterix in the next statement to get a S0C1 abend
* dc h'0'
clear prtrec
mvc prtrec(15),=cl25'*End of program'
put prtfile,prtrec
*
* close files
*
close infile
close prtfile
*
* Program epilog
*
l r13,4(,r13) unchain savearea
* release dynamic storage
Freemain R,lv=workln,a=(10)
* wto 'freemain done'
* set rc and get back
xr r15,r15
l r14,12(,r13)
return (2,12)
*
* static work area
*
blank dc cl150' '
print nogen
infile dcb ddname=INDATA,dsorg=ps,macrf=gm,recfm=fb,eodad=readend
prtfile dcb ddname=SYSPRINT, c
dsorg=ps,macrf=pm,recfm=fb,lrecl=l'prtrec,blksize=0
print gen
ltorg
*
* dynamic work area
*
work Dsect
sa1 ds 18f
ds 0d
inrec ds cl200
prtrec ds cl133
ds 0d
workln equ *-work
End
//G.SYSPRINT DD SYSOUT=*
//G.INDATA DD *
kilroy
was
here
Hi Willy,
Thanks a lot for taking the time to provide me with that example.
This is a Macro right? I was reading about Macro's the other day and I read that they can be quite complex and more difficult to write than actual Assembler. I do not know if there is much truth in that.
I think Macro's are designed to generate Assembler code? I am not sure why, perhaps it makes creating Assembler programs faster and more dynamic?
I will study your example and see if I can make sense of it.
Really appreciate your time and help.