您的位置:首页 > 大数据 > 人工智能

大型机汇编(mainframe assembler/HLASM)之显示变量值('DISPLAY' in COBOL)

2012-10-19 15:46 411 查看
In COBOL, we can use DISPLAY to display some variable's value; Instead, we can issue macro WTO(Write To Operator)
in assembler to meet it.

WTO   MF=(E,LISTMSG1)
LTR   R15,R15     IS REG-15 = ZERO...
BNZ   ABEND4         IF NOT, ABEND...
*
LA    R8,LISTMSG2
WTO   MF=(E,(R8))
LTR   R15,R15     IS REG-15 = ZERO...
BNZ   ABEND4         IF NOT, ABEND...
*
***********************************************************************
* WTO using the EXECUTE format with user-coded WTO buffer. This
* routine illustrates the use of a single WTO to display different
* messages.
*
BAL   R3,DOMSG              DISPLAY MESSAGE, RETURN VIA R3
MVC   WTOTEXT(76),WTOMSG1
BAL   R3,DOMSG              DISPLAY MESSAGE, RETURN VIA R3
MVC   WTOTEXT(76),WTOMSG2
BAL   R3,DOMSG              DISPLAY MESSAGE, RETURN VIA R3
*
*
***********************************************************************
* WTO using the EXECUTE format with user-coded WTO buffer. This
* routine illustrates the use of a single WTO to display different
* messages. This will cause a length error with WTO execution.
*
WTO   MF=(E,WTOCRASH)
LTR   R15,R15     IS REG-15 = ZERO...
BZ    ABEND4         THEN ABEND, SHOULD BE 4...
B     EOJ
*
*
***********************************************************************
* Common WTO routine to display WTOBLOCK...
*
DOMSG    EQU   *
WTO   MF=(E,WTOBLOCK)
LTR   R15,R15     IS REG-15 = ZERO...
BNZ   ABEND4         IF NOT, ABEND...
BR    R3          Return via Register 3
***********************************************************************
* Return to caller
*
EOJ      EQU   *
WTO   '* ASMWTOA1 is FINISHED...'
RETURN (14,12),RC=0
***********************************************************************
* Abnormal termination of program
*
ABEND4   EQU   *
WTO   '* ASMWTOA1 MLC, is ABENDING, RC=4...'
RETURN (14,12),RC=4

***********************************************************************
* The following is an example of a user-coded WTO buffer.
*
CNOP  0,4
WTOBLOCK DC    Y(80,0) * For WTO, the first length of WTO buffer, the second should be binary zeroes.
WTOTEXT  DC    CL76'* ASMWTOA1 WTO with user-coded buffer...'
***********************************************************************
* The following is an example of a user-coded WTO buffer that will
* cause an error conditions, length of text exceeds 251 bytes.
     CNOP  0,4
WTOCRASH DC    Y(512,0)
WTOCTEXT DC    CL76'* ASMWTOA1 WTO FOR CRASH TEST...'
*
DC    436CL1'X'
*
END

Remember, this maybe not the best way to display the contents. ie, how to display all the regs' value at the any
time within one program when you debug? Pls refer to ANOTHER subject... Thanks.

MAIN     CSECT                 
         USING *,12            
         STM   14,12,12(13)    
         LR    12,15           
         ST    13,SAVE+4       
         LA    13,SAVE         
START    EQU   *               
         WTO   MF=(E,WTOBLOCK) 
EXIT     EQU   *               
         L     13,SAVE+4       
         LM    14,12,12(13)    
         LA    15,0            
         BR    14              
WTOBLOCK DC    Y(L'DEF+4,0)    
DEF      DC    C'HELLO WORLD'  
SAVE     DS    18F             
         END   MAIN            

please remember the contents will be displayed in the JESYSMSG data set.

有疑问请联系QQ349106216


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cobol 汇编 mvc buffer crash