Instruction to print value in storage to spool



High Level Assembler(HLASM) for MVS & VM & VSE

Instruction to print value in storage to spool

Postby tanu_2302 » Wed Nov 23, 2016 12:57 pm

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
tanu_2302
 
Posts: 9
Joined: Tue Nov 08, 2016 12:45 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Instruction to print value in storage to spool

 

Re: Instruction to print value in storage to spool

Postby steve-myers » Wed Nov 23, 2016 5:32 pm

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);
steve-myers
Global moderator
 
Posts: 1897
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 200 times

Re: Instruction to print value in storage to spool

Postby tanu_2302 » Wed Nov 23, 2016 6:46 pm

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
tanu_2302
 
Posts: 9
Joined: Tue Nov 08, 2016 12:45 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Instruction to print value in storage to spool

Postby enrico-sorichetti » Wed Nov 23, 2016 6:49 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2664
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 134 times

Re: Instruction to print value in storage to spool

Postby steve-myers » Wed Nov 23, 2016 9:44 pm

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.
steve-myers
Global moderator
 
Posts: 1897
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 200 times

Re: Instruction to print value in storage to spool

Postby tanu_2302 » Thu Nov 24, 2016 11:19 am

Thanks Steve for your help :)
tanu_2302
 
Posts: 9
Joined: Tue Nov 08, 2016 12:45 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Instruction to print value in storage to spool

Postby willy jensen » Thu Dec 01, 2016 3:29 pm

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=*                                                            
willy jensen
 
Posts: 133
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 21 times

Re: Instruction to print value in storage to spool

Postby steve-myers » Fri Dec 02, 2016 5:53 am

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.
steve-myers
Global moderator
 
Posts: 1897
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 200 times


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post