AGF      TITLE 'agf test case'                                                  
                                                                                
* This file was put into the public domain 2015-11-12                           
* by John P. Hartmann.  You can use it for anything you like,                   
* as long as this notice remains.                                               
                                                                                
 punch '*Testcase agf &sysdatc &systime'                                        
 punch 'sysclear'                                                               
 punch 'archlvl z'                                                              
agf start 0                                                                     
agf rmode any                                                                   
agf amode any                                                                   
 using agf,15                                                                   
 org agf+x'1a0'                                                                 
 dc x'0000000180000000',ad(x'200')                                              
 org agf+x'1d0' Program new                                                     
 dc x'0002000180000000',ad(x'deaddead')                                         
 org agf+x'200'                                                                 
 LA 0,testcount   0=Number of test data                                         
 LA 1,TEST1       1=>Test data table                                            
 LA 10,rES1       10=>Result table                                              
 Sr 8,8          Clear CC register                                              
A LG 4,0(,1)     Load 4=TESTn                                                   
 L 5,8(,1)       Load 5=TESTn+8                                                 
 AGF 4,8(,1)     Add fullword at TESTn+8                                        
 IPM 8            8=Cond code and pgm mask                                      
 STG 4,0(,10)    Store 4 in result table                                        
 ST 8,8(,10)     Store CC in table                                              
 LA 10,16(,10)   15=>next result table                                          
 LA 1,16(,1)     1=>Next TESTn                                                  
 BCT 0,A          Loop to end of TEST table                                     
 ltr 14,14     Have a return address?                                           
 bnzr 14       return if so                                                     
 LPSWE WAITPSW     Load wait PSW                                                
 ds 0d                                                                          
WAITPSW dc x'0002000180000000',ad(0) OK wait state PSW                          
TEST1 DC fd'5',F'3'                                                             
TEST2 DC fd'-5',F'-3'                                                           
TEST3 DC fd'-5',F'3'                                                            
TEST4 DC fd'-9223372036854775808',F'1'                                          
TEST5 DC fd'9223372036854775807',F'-2147483648'                                 
TEST6 DC fd'4294967295',F'1'                                                    
TEST7 DC fd'4294967296',F'1'                                                    
TEST8 DC fd'4294967296',F'-1'                                                   
 dc fd'0',f'0'                                                                  
 ds 0d Align                                                                    
testcount equ (*-test1)/16                                                      
 org agf+x'900'                                                                 
res1 ds 0d                                                                      
 ltorg                                                                          
 punch 'runtest .1'                                                             
 punch '*Compare'                                                               
 punch 'r 900.9'                                                                
 punch '*Want 00000000 00000008 20'                                             
 punch 'r 910.9'                                                                
 punch '*Want FFFFFFFF FFFFFFF8 10'                                             
 punch 'r 920.9'                                                                
 punch '*Want FFFFFFFF FFFFFFFE 10'                                             
 punch 'r 930.9'                                                                
 punch '*Want 80000000 00000001 10'                                             
 punch 'r 940.9'                                                                
 punch '*Want 7FFFFFFF 7FFFFFFF 20'                                             
 punch 'r 950.9'                                                                
 punch '*Want 00000001 00000000 20'                                             
 punch 'r 960.9'                                                                
 punch '*Want 00000001 00000001 20'                                             
 punch 'r 970.9'                                                                
 punch '*Want 00000000 FFFFFFFF 20'                                             
 punch 'r 980.9'                                                                
 punch '*Want 00000000 00000000 00'                                             
 punch '*Done'                                                                  
 END  ,                                                                         
