I am learning assembler. Could you please help me to understand how PUT works. I wrote the below program
Code:
BALPOC CSECT
STM R14,R12,12(R13)
BALR R12,0
USING *,R12
LA R2,SAVEAREA
ST R2,8(,R13)
LR R2,R13
ST R2,SAVEAREA+4
OPEN (PRINTER,OUTPUT)
PUT PRINTER,PRHEAD
PUT PRINTER,PRTEST1
PUT PRINTER,PRTEST2
CLOSE PRINTER
L R13,SAVEAREA+4
LM R14,R12,12(R13)
LA R15,0
BR R14
SAVEAREA DS 18F
PRHEAD DC CL11'HELLO ASHIM'
PRTEST1 DC CL11'HELLO TEST1'
PRTEST2 DC CL11'HELLO TEST2'
PRINTER DCB DSORG=PS,MACRF=(PM),DEVD=DA,DDNAME=DDOUT,
RECFM=FBM,LRECL=80
END BALPOC
When I am running this program the control is not returning back to OS. But if I just comment out the PUT instructions the control is coming back to OS. With the above code I am getting the below o/p from the run
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
The PUT macro expects register 13 to point to the new save area your program has established. Your program does not set register 13 correctly so the PUT macro is destroying the save area initially provided by the system. That is why your program is failing.
Mr. Sample's comments about record length are absolutely correct.
You specify RECFM=FBM in your DCB macro, but you are not providing any carriage control. Just as a comment: "machine" carriage control is very tricky. "Machine" in this case refers to the CCW operation codes used in CCW instructions to print lines on line printers used in the 1960s and 1970s. Finding the codes any more is quite difficult. They are rarely used even by advanced Assembler programmers, even though their proper use can slightly improve printer performance compared to using ASA carriage control. Which brings to mind a war story from the 1980s where JES2 was doing some very funky things converting ASA carriage control to machine carriage control. Technically JES2 was 100% correct, but it was "printing" to a non IBM page printer whose vendor claimed correctly responded to 1403/3211 (those are printer models) commands. Well, the vendor lied, and they refused to correct the problem in their printer. While there are a couple of dozen CCW commands, most are never used.
Regardless, specify RECFM=FBA and supply correct ASA carriage control characters, or just specify RECFM=FB. In addition, as Mr. Sample mentioned, correct your line definitions. One other point; most of the 1960 era line printers printed a maximum line length of 132 characters, the carriage control character added an extra non printed character so LRECL=133 was common. You frequently see LRECL=121; some 1403 models only printed 120 character lines, so defensively coded programs just used this standard.
The topic "How do I coding assembly code for hex data calculate" has a complete (and correct) program that does some printing that might serve as a model for you.
If you insist on using "machine" carriage control, use X'09', the code for write and space 1.