ChatGPT generated this program:
HELLOPGM START 0
USING *,15 Base register
OPEN (OUTDCB,(OUTPUT)) Open SYSPRINT for output
MVC OUTREC,=CL80'Hello World' Move "Hello World" to record
PUT OUTDCB,OUTREC Write the record
CLOSE (OUTDCB) Close the SYSPRINT file
RETURN (14,12),RC=0 Return to caller
END HELLOPGM End of program
OUTDCB DCB DDNAME=SYSPRINT,DSORG=PS,MACRF=PM, +
RECFM=F,LRECL=80 Define output DCB
OUTREC DS CL80 Output record buffer
My comments:
- No entry housekeeping
- No exit housekeeping
- END statement in wrong location
Grok was not tested.
Gemini generated this program:
HELLOWLD CSECT
*
* This program demonstrates basic file output using QSAM.
* It opens SYSPRINT, writes one record, and closes it.
*
* Standard entry linkage: save registers and establish a base
STM 14,12,12(13) Save the caller's registers
BALR 12,0 Load the current address into R12
USING *,12 Tell the assembler R12 is the base
*
* Open the SYSPRINT file, specifying it's for output
OPEN (SYSPRINT,(OUTPUT))
*
* Write the pre-defined record to the file
PUT SYSPRINT,HELLOREC
*
* Close the file now that we are done with it
CLOSE (SYSPRINT)
*
* Standard exit linkage: restore registers and return
L 13,4(13) Restore the caller's save area
LM 14,12,12(13) Restore the original registers
SR 15,15 Set a return code of 0 (success)
BR 14 Branch back to the caller
*
* Define the Data Control Block (DCB) for the SYSPRINT file
SYSPRINT DCB DSORG=PS,MACRF=PM,DDNAME=SYSPRINT,RECFM=F,LRECL=80
*
* Define the output record constant
HELLOREC DC CL80'Hello World'
*
END HELLOWLD
My comments:
- Didn't create and use a register save area
Copilot generated this program:
HELLOPG START
OPEN (SYSPRINT,OUTPUT) OPEN file for output
USING *,15 Establish addressability
MVC OUTREC,=C'Hello World'Move text to output buffer
PUT SYSPRINT,OUTREC Write buffer to file
CLOSE SYSPRINT Close the file
END HELLOPG End of program
OUTREC DS CL80 Output record buffer
My comments:
- No entry housekeeping
- No exit housekeeping
- END statement in wrong location
- SYSPRINT DCB was not defined.
Claude generated this program:
HELLO CSECT Main program entry point
STM R14,R12,12(R13) Save registers
LR R12,R15 Establish base register
USING HELLO,R12 Tell assembler about base
LA R11,SAVEAREA Point to save area
ST R13,4(R11) Chain save areas
ST R11,8(R13) Chain save areas
LR R13,R11 Set new save area
*
OPEN (SYSPRINT,OUTPUT) Open file for output
LTR R15,R15 Check return code
BNZ ERROR Branch if open failed
*
PUT SYSPRINT,RECORD Write the record
LTR R15,R15 Check return code
BNZ ERROR Branch if write failed
*
CLOSE SYSPRINT Close the file
LTR R15,R15 Check return code
BNZ ERROR Branch if close failed
*
LA R15,0 Set return code to zero
B RETURN Branch to return
*
ERROR DS 0H Error handling
LA R15,8 Set error return code
*
RETURN DS 0H Return to caller
L R13,4(R13) Restore save area pointer
LM R14,R12,12(R13) Restore registers
BR R14 Return to caller
*
SAVEAREA DS 18F Register save area
*
SYSPRINT DCB DDNAME=SYSPRINT,DSORG=PS,MACRF=PM,RECFM=F,LRECL=80
*
RECORD DC CL80'Hello World' Output record
*
END HELLO End of program
My comments:
- Almost Correct code - It used register equates like from YREGS but didn't use the YREGS macro.