Page 1 of 1

Instruction to print value in storage to spool

PostPosted: Wed Nov 23, 2016 12:57 pm
by tanu_2302
Hi,
I wrote code for comparison between three numbers. i defined three constants- num1,num2,num3 and a storage-great. i want to print the value of great in my spool. which instruction could i use.
thanks

Re: Instruction to print value in storage to spool

PostPosted: Wed Nov 23, 2016 5:32 pm
by steve-myers
There are a number of ways to print a value. All of them require more than one instruction. There is nothing in Assembler comparable to the standard C library printf("The greatest value is %d\n",biggest);

Re: Instruction to print value in storage to spool

PostPosted: Wed Nov 23, 2016 6:46 pm
by tanu_2302
yeah i know that its not that much easy as c. So could you please help me with that by providing instructions for prnting purpose

Re: Instruction to print value in storage to spool

PostPosted: Wed Nov 23, 2016 6:49 pm
by enrico-sorichetti
unfortunately a Forum is not a training center

did You read the documentation for the tool You are using for the programming ...
the TX... macros should be documented somewhere
and probably You might find some dealing with I/O


anyway see here for example for some basic training topics
http://www.simotime.com/indexasm.htm

Re: Instruction to print value in storage to spool

PostPosted: Wed Nov 23, 2016 9:44 pm
by steve-myers
tanu_2302 wrote:Hi,
I wrote code for comparison between three numbers. i defined three constants- num1,num2,num3 and a storage-great. i want to print the value of great in my spool. which instruction could i use.
thanks

in Assembler - regardless of platform - there are two things you have to do
  • Prepare the message you want print (e.g. sprintf("The value is ",%d\n",great);
             ED    LISTGRT,GREAT
             ...
    TEXT     DC    AL2(L'MSG)
    MSG      DC    0C'
    THE VALUE IS NNN'
             DC    C'
    THE VALUE IS'
    LISTGRT  DC    0C'
    NNN',C' ',X'202120'
    GREAT    DC    P'
    99'
    There is a lot of Assembler trickery here.
    • AL2(L'MSG) Prepares a 2 byte binary value with the length attribute assigned to a label.
    • 0C'THE VALUE IS NNN' defines storage, but does not actually emit any text.
    • 0C' NNN',C' ',X'202120' This does the previous bullet and then adds additional data. In total, this data builds an ED instruction pattern area. I am not going to go into this instruction here. This link goes to the z/Architecture Principles of Operation manual that discusses the the instruction in detail.
  • "print ... in my SPOOL" is terribly vague. There are many places "in my SPOOL" where you can send messages; the method used here will send the message to the JESMSGLG data set where it can be viewed using SDSF. Add this instruction immediately after the ED machine instruction.
             WTO TEXT=TEXT,ROUTCDE=11,DESC=7
    The WTO instruction does not require additional preparation. ROUTCDE=11,DESC=7 directs the system to send the message to the JESMSGLG SPOOL data set. The message will also appear in the JESYSMSG data set, but it is harder to find there.

Re: Instruction to print value in storage to spool

PostPosted: Thu Nov 24, 2016 11:19 am
by tanu_2302
Thanks Steve for your help :)

Re: Instruction to print value in storage to spool

PostPosted: Thu Dec 01, 2016 3:29 pm
by willy jensen
Or write to a sysout file like shown below.


         open  (print,(OUTPUT))                                                
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 1 Line(s) not Displayed
         mvc   printrec,blank                                                  
         mvc   printrec(6),=cl6'Header'                                        
         mvc   printrec+7(100),data                                            
         put   print,printrec                                                  
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 1 Line(s) not Displayed
         close (print)                                                          
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 3 Line(s) not Displayed
print    dcb   ddname=PRINT,macrf=PM,dsorg=PS,lrecl=l'printrec                  
printrec dc    cl132'
'                                                        
blank    dc    cl132'
'                                                        
data     dc    cl100'
testdata '
            ltorg                                                
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 8 Line(s) not Displayed
//PRINT  DD SYSOUT=*                                                            

Re: Instruction to print value in storage to spool

PostPosted: Fri Dec 02, 2016 5:53 am
by steve-myers
Two problems
  • Many more than one one instruction
  • Does not convert a two byte packed decimal number to decimal digits
This still has more than one instruction, but in other respects is simpler than Mr. Jenson's idea and does essentially the same thing.
         OPEN  (PRINT,OUTPUT)
         ED    OUTVAL,DATA
         PUT   PRINT,MSG
         ...
PRINT    DCB   DSORG=PS,MACRF=PM,DDNAME=SYSPRINT,RECFM=FBA,LRECL=121
DATA     DC    P'12'
MSG      DC    0CL121' THE VALUE IN DATA IS NNN'
         DC         C' THE VALUE IN DATA IS'
OUTVAL   DC    0C' NNN',C' ',X'202120',CL(L'MSG-(*-MSG))' '
Sorry about the complicated way the output message is defined.

Sadly, perhaps, but I've become addicted to complex DC statements like

0C' NNN',C' ',X'202120',CL(L'MSG-(*-MSG))' '

0C' NNN',C' ',X'202120'

Specifies the edit instruction pattern. 0C' NNN' is a relatively high level abstraction of the effect of the pattern, and

C' ',X'202120' is the actual pattern. Personally, I find this better than X'40202120' since I don't have to memorize 40 as an EBCDIC blank, even though most Assembler programmers have this memorized - even me. However -

OUTVAL DC 0C' NNN,NNN,NNN',C' ',3X'20',C',',3X'20',X'202120'

After more than 40 years one would think I have comma memorized. But I don't!

CL(L'MSG-(*-MSG))' ' Fills out the line with blanks. L'MSG is the Assembler determine length of the data area specified by the symbol MSG, so

(L'MSG-(*-MSG)) becomes the bytes to fill out the line *-MSG directs the Assembler to calculate the number of bytes from the address assigned to MSG and the location counter.