Now we can write a short program to test our macros.

ABSTEST2 START 0                                      
WAITPSW  DC    X'0000000000',AL3(BEGIN)               
*                                                     
*                                                     
         ORG   ABSTEST2+2048                          
*                                                     
BEGIN    BALR  R12,0         SET BASE REGISTER        
         USING *,R12                                  
*                                                     
         LA    R13,SAVEA     FIRST SAVE AREA

We start by loading a PSW at location zero.  Our PSW will start executing at lable BEGIN.  Because the lower byes in memory are used for communication between the CPU  and the operating system software we need to load  our executable program in higher memory.  Using the ORG statement we will being our program at 2K (2048).

We begin by establishing register 12 as a base register and placing our initial save area address into register 13.

         @PRINT 'HELLO, WORLD'   PRINT "HELLO WORLD"                  
         @PRINT DASH,LEN=L'DASH  PRINT A LINE OF DASHES               
*                                                                     
LOOP     DS    0H                                                     
         @CARD INBUF             READ A CARD                          
         LTR   R15,R15           CHECK FOR GOOD READ                  
         BNZ   LOOPEND                                                
         @PRINT INBUF,LEN=L'INBUF    PRINT THE CARD                   
         B     LOOP              LOOP BACK FOR ANOTHER CARD           
*                                                                     
*                                                                     
LOOPEND  DS    0H                                                     
         @PRINT DASH,LEN=L'DASH  PRINT A LINE OF DASHES               
         @PRINT ' '              PRINT BLANK                          
         @PRINT ' '                         LINES                     
*                                                                     
*                                                                     
         L      R5,=A(BEGIN)                                          
         @DUMP  (R5),128         DUMP SOME STORAGE
*
         LPSW   DONE

Now we use our @CARD macro to read from the card reader.  We check the return code in register 15 to see if a card was read.  If not we branch out of the loop.  If a card was read we print using the @PRINT  macro and then loop back an attempt to read another card.

After reading the last card we print a line of dashes an two blank lines.  We then test the @DUMP macro by dumping 128 bytes of our executable program.  We then load a wait state PSW to end execution.

          @PRINT GEN=YES                                            
          @CARD  GEN=YES                                            
          @DUMP  GEN=YES                                            
          @ERR  ,                                                   
          @REGS ,                                                   
 *                                                                  
 *******************************************************************
 *                                                                  
 DASH     DC     C'-------------------------------------------------
 *                                                                  
 *                                                                  
          DS     0D                                                 
 DONE     DC     X'0002000000',X'99FACE'                            
 *                                                                  
 SAVEA    DS     18F                                                
 *                                                                  
 INBUF    DS    CL80                                                
 *                                                                  
          END   ,

Now we include the GEN=YES forms of our @CARD, @PRINT and @DUMP macros to generate the subroutine code.  We also use the @ERR and @REGS macros to define our error codes and registers.

Our data areas include a line of dashes, a PSW with the wait bit set, a save area and an input buffer.

[Next – ABSTEST2 Assembly Listing]