* Set storage key extended test case.                                   00010000
                                                                                
* This file was put into the public domain 2015-10-05                   00020000
* by John P. Hartmann.  You can use it for anything you like,           00030000
* as long as this notice remains.                                       00040000
                                                                                
* We load code at x'200' unless prefixing is indicated, in which                
* case we load at x'2000'                                                       
                                                                                
 macro                                                                          
 supsws &problem=0,&prefix=no,&am=18,&arch=z                                    
 gblb using0                                                                    
 gblb &havepx Prefixing?                                                        
&havepx setb ('&prefix' eq 'yes')                                               
&org(1) setc 'x''200''','x''2000'''                                             
 punch 'sysclear'                                                       00060000
 punch 'archmode &arch'                                                 00060000
 org sske+x'1a0'                                                        00090000
 dc x'000&problem.000&am.0000000'                                       00100000
 dc ad(&org(&havepx+1))                                                 00110000
 org sske+x'1d0'                                                        00120000
 dc x'0002000180000000'                                                 00130000
 dc ad(x'deaddead') Program new PSW                                     00140000
 aif (&havepx).px                                                               
 org &sysect+x'200'                                                     00150000
 using &sysect,0                                                                
&using0 setb 1                                                                  
 mexit                                                                          
.px anop                                                                        
 org &sysect+x'41d0'                                                    00120000
 dc x'0002000180000000'                                                 00130000
 dc ad(x'deadbeaf') Program new PSW in prefix                           00140000
 org &sysect+x'2000' Get out of the prefix page                                 
 aif (not &using0).nodrop                                                       
 drop 0                                                                         
&using0 setb 0                                                                  
.nodrop anop                                                                    
 basr 12,0                                                                      
 using *,12                                                                     
 spx =a(x'4000') Load prefix                                                    
.x mend                                                                         
                                                                                
 macro                                                                          
 stop &rc=0                                                                     
 lpswe psw&sysndx                                                               
psw&sysndx dc 0d,x'0002000180000000',ad(&rc)                                    
 ltorg                                                                          
 mend                                                                           
                                                                                
* Macro to perform multiple key assignments                                     
                                                                                
 macro                                                                          
 dosskemf &addr,&r2hi=00000000,&p1key=F0                                        
 gblb &havepx Prefixing?                                                        
 lg  2,=ad(&addr)  Starting address                                     00170000
 lhi 3,x'f0'                                                            00180000
 sske 3,2,1                                                             00190000
 stop                                                                           
 punch 'runtest .1'                                                     00250000
 punch '*Compare'                                                               
 punch 'abs  0.8'                                                               
 punch '*Key 06'                                                                
 punch 'abs 1000.8'                                                             
 punch '*Key &p1key.'                                                           
 punch 'r ff000.8'                                                              
 punch '*Key F0'                                                                
 punch 'r ff000.8'                                                              
 punch '*Key F0'                                                                
 punch 'r 100000.8'                                                             
 punch '*Key 00'                                                                
 punch 'gpr'                                                                    
 punch '*Gpr 2 &r2hi.00100004'                                                  
 aif (not &havepx).x                                                            
 punch 'r    0.8'                                                               
 punch '*Key f0'                                                                
 punch 'r 1000.8'                                                               
 punch '*Key F0'                                                                
 punch 'abs 2000.8'                                                             
 punch '*Key F4'                                                                
 punch 'r 2000.8'                                                               
 punch '*Key F4'                                                                
 punch 'r 5000.8'                                                               
 punch '*Key F0'                                                                
.x mend                                                                         
                                                                                
* Test for instruction being privileged                                         
                                                                                
 punch '*Testcase sske#1'                                               00050000
 punch '* sske#1:  Test for sske being privileged.'                             
sske start 0                                                            00070000
 supsws problem=1                                                               
go ds 0h =x'200'                                                                
 lhi 2,x'2004'  Starting address                                        00170000
 lhi 3,x'f0'                                                            00180000
 sske 3,2                                                               00190000
 stop rc=x'bad'                                                         00200000
 punch '*Program 0002' Expect program check                             00240000
 punch 'runtest .1'                                                     00250000
 punch '*Done'                                                          00260000
                                                                                
* Test ability to set a key                                                     
 punch '*Testcase sske#2'                                               00050000
 punch '* sske#2:  Basic set key operation.'                                    
 supsws                                                                         
 org go                                                                         
 lhi 2,x'2004'                                                                  
 la  3,x'f0'                                                                    
 SSKE    3,2                                                                    
 stop                                                                           
 punch 'runtest .1'                                                     00250000
 punch '*Compare'                                                               
 punch 'r 2000.8'                                                               
 punch '*Key F0'                                                                
 punch 'gpr'                                                                    
 punch '*Gpr 2 2004'                                                            
                                                                                
* Test prefixing with single page frame                                         
* Make the fourth page the prefix.  Note that the prefix is two                 
* pages                                                                         
                                                                                
 punch '* sske#3:  Test prefixing with single page frame.'                      
 supsws prefix=yes                                                              
 lhi 2,x'1004'                                                                  
 la  3,x'f0'                                                                    
 SSKE    3,2                                                                    
 stop                                                                           
 punch 'runtest .1'                                                     00250000
 punch '*Compare'                                                               
 punch 'abs 1000.8'                                                             
 punch '*Key 00'                                                                
 punch 'r 1000.8'                                                               
 punch '*Key F0'                                                                
 punch 'abs 5000.8'                                                             
 punch '*Key F0'                                                                
 punch 'r 5000.8'                                                               
 punch '*Key 00'                                                                
                                                                                
* Set multiple keys.  Requires 1M page support                                  
                                                                                
* Setting  multiple keys without prefixing.  The low 12 bits of       *         
* R2 should remain unchanged.                                         *         
                                                                                
 punch '* sske#4:  Setting multiple keys without prefixing.'                    
 supsws                                                                         
 dosskemf x'2004',p1key=00                                              00170000
 punch 'r 2000.8'                                                               
 punch '*Key F0'                                                                
 punch 'r 5000.8'                                                               
 punch '*Key F0'                                                                
                                                                                
* Same  with prefixing.  The point being that this variation of       *         
* the instruction is not subject to prefixing,                        *         
                                                                                
 punch '* SSKE#5: Test prefixing with multiple page frames.'                    
 supsws prefix=yes                                                              
 dosskemf x'1004'  Starting address                                     00170000
                                                                                
* When  multiple-block  processing  occurs in the 24-bit or 31-       *         
* bit addressing modes, the leftmost bits which are not part of       *         
* the address in bit positions 32-63 of general register R2 are       *         
* set to zeros; bits 0-31 of the register are unchanged.              *         
                                                                                
 supsws prefix=yes,am=08 31 bit addressing mode                                 
 dosskemf  x'80001004',r2hi=ffffffff   Starting address                 00170000
                                                                                
 supsws prefix=yes,am=00 24 bit addressing mode                                 
 dosskemf x'ff001004',r2hi=ffffffff                                             
                                                                                
* Insert more here                                                              
                                                                                
 punch '*Done'                                                          00260000
 end                                                                    00270000
