//ASMFCLG JOB  (001),'ASM HELLO WORLD',                             
//             CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),REGION=128K        
//HELLO  EXEC ASMFCLG                                               
//ASM.SYSUT1 DD UNIT=SYSDA                                          
//ASM.SYSUT2 DD UNIT=SYSDA                                          
//ASM.SYSUT3 DD UNIT=SYSDA                                          
//ASM.SYSGO DD UNIT=SYSDA                                           
//ASM.SYSIN DD *                                                    
R0       EQU   0
R1       EQU   1
R2       EQU   2
R3       EQU   3
R4       EQU   4
R5       EQU   5
R6       EQU   6
R7       EQU   7
R8       EQU   8
R9       EQU   9
R10      EQU   10
R11      EQU   11
R12      EQU   12
R13      EQU   13
R14      EQU   14
R15      EQU   15

HELLO    CSECT            
    SAVE  (14,12)		
    BALR  12,0
    USING *,12
    LR R11,R13			;Backup old R13
    LA R13,SAVEAREA		;R13-> Savearea (for subs)


        BAL R14,NEWLINE
        BAL R14,NEWLINE



        WTO 'Hello wWorld!'   
        
        L R9,=F'0'
        
        L R0,=X'12345679'
        L R7,=F'8'
        BAL R14,SHOWHEX     
        
        BAL R14,PRINTMSG           ;   DISPLAY MESSAGE, RETURN VIA R3

        
        L R0,=X'0101010'
        L R1,=X'1111111'
        L R10,=X'CCCCCCCC'
        L R15,=X'FFFFFFF'
        BAL R14,MONITOR
        
        LA R1,TEST
        L R3,=F'1'
        L R2,1(R1,R3)
        
        BAL R14,MONITOR
            

        BAL R14,PRINTMSG           ;   DISPLAY MESSAGE, RETURN VIA R3


        BAL R14,NEWLINE
        BAL R14,NEWLINE

	LR R13,R11	
	RETURN (14,12),RC=0                                        
	
	
SAVEAREA	DS 	76B			
			DS 	76B			
			DS 	76B					;Space for subs 3 deep
			CNOP 0,4

MONITOR  SAVE  (0,15)
         A R13,=F'72' 		    	
         
            L R5,=F'-72'
         
            
            L R4,=F'4'
            L R8,=C' R0:'
            
MONITOR3    L R3,=F'4'
            
MONITOR2    L R0,20(R5,R13)
            BAL R14,SHOWREG   

            A R5,=F'4'
            C R5,=F'-32'
            BNE MONITROK
            L R8,=C' RA:'
            
MONITROK    S R3,=F'1'
            BNZ MONITOR2

            BAL R14,PRINTMSG 
            
            S R4,=F'1'
            BNZ MONITOR3
            
            
         S R13,=F'72'		    	
		 RETURN (0,15)  
            

SHOWREG  SAVE  (14,7)
         A R13,=F'72' 		    	
            LA R6,WTOTEXT
            
            ST R8,0(R6,R9)          ;Show label R1
            A R9,=F'4'
         
            BAL R14,SHOWHEX8        ;Show R0
            
            A R8,=F'256'
         S R13,=F'72'		    	
		 RETURN (14,7)

			
SHOWHEX8     L R7,=F'8'
SHOWHEX     LA R6,WTOTEXT
           
SHOWHEXA    LR R1,R0                ;Load
            SRL R1,28
            N R1,=X'0000000F'                ;AND
            A R1,=C'   0'               ;+0
            
            C R1,=C'   9'
            BNH SHOWHCOK
            S R1,=F'57'
            
SHOWHCOK    STC R1,0(R6,R9)
            SLL R0,4
            A R9,=F'1'             ;BufferOffset
            S R7,=F'1'             ;CharCount
            BNZ SHOWHEXA
            
      	BR R14
    
    
SUB2    SAVE  (14,12)
            A R13,=F'72' 			;Move to a new savearea for nesting subs
            
            S R13,=F'72'			;Back to old savearea
		RETURN (14,12)
	
			
NEWLINE SAVE  (14,12)
	 	WTO ' '
		RETURN (14,12)

	
	
PRINTMSG SAVE  (14,8)	
		
		WTO   MF=(E,WTOBUFR)
		
        LA R9,WTOTEXT
        L R8,=F'0'
        L R7,=C'    '
        
PRINTCLR ST R7,0(R8,R9)
        A R8,=F'4'
        C R8,=F'76'
        BNE PRINTCLR
        
        L R9,=F'0'
        
		
		RETURN (14,8)
		

         DS    0H   			; Align to half word
WTOBUFR  DC    H'80'         											;For WTO, length of WTO buffer, should be binary zeroes
         DC    H'0'            
WTOTEXT  DC    CL76' '

		CNOP 0,4
TEST    DC X'12345678'

		LTORG
        


         END                                                      
//                                                                