fredag den 25. december 2015

Language Environment in Assembler (2)

Callable Services

I assumed that the term Language Environment is referring to the different programming languages that are available for you on z/OS. It is probably so but, on the other hand, there are several services you can call that makes your program independent of human languages. There are several more but let me show you some of them:
  • CEE3LNG - Set national language
  • CEE3MCS - Get default currency symbol
  • CEE3MDS - Get default decimal separator
  • CEE3MTS - Get Default thousands separator


Along with the human language specialities are the geographical specialities, - most important is the current time.
  • CEEDYWK - Calculate day of week from Lilian date
  • CEEFMDA - Get default date format
  • CEEFMDT - Get default date and time format
  • CEEFMTM - Get default time format
  • CEEFTDS - Format time and date into character string
  • CEEGMT - Get current Greenwich Mean Time
  • CEEGMTO - Get offset from Greenwich Mean Time to local time
  • CEELOCT - Get current local date or time


All these services are callable services but, as opposed to CEEENTRY and CEETERM, there are no assembler macro equivalent. I do not know why. These services must be called as regular programs with a parm and a BALR.
I have made two macroes that will do most of the job for you. You can find the at the bottom of this blog article.


I will show you an example of a macro to get the current time. The other are called in a similar way.
        CEELOCT MF=(E,TS),RESULT=TIMESTAMP
TS       CEELOCT MF=L
TIMESTAMP DS    CL17


MACROES

All macroes must have the List and Execute for in order to make the programs, using them, can be reentrant.

CEELOCT - Get current local date or time

This macro does not use all possibilities in the the call to CEELOCT. It returns 17 byte in an area in the form of YYYYMMDDHHMISSMIL.

Excecute form

CEELOCT [TYPE=[TIMESTAMP],]MF=(E,[label_on_list])      
                         RESULT=label_to_CL17


TYPE= Type of result. Only TIMESTAMP is available right now
MF= E is Execute form of the macro
RESULT= Label of a 17 bytes area where the result is placed


Example

         CEELOCT MF=(E,TS),RESULT=TIMESTAMP
+         LA    1,TS_LILIAN                 
+         ST    1,TS_PARM                   
+         LA    1,TS_SECONDS                
+         ST    1,TS_PARM+4                 
+         LA    1,TIMESTAMP                 
+         ST    1,TS_parm+8                 
+         LA    1,TS_fc                     
+         ST    1,TS_parm+12                
+         OI    TS_PARM+12,X'80'            
+         LA    1,TS_PARM                   
+         L     15,=V(CEELOCT)              
+         BALR  14,15                      


List form

prefix CEELOCT MF=L
prefix used as prefix for labels in the macro so you can use it more than once

Example

TS       CEELOCT MF=L
+TS_PARM       DS  4F             
+TS_LILIAN     DS  F               
+TS_SECONDS    DS  D              
+TS_FC         DS  XL12           
+***********************************
TIMESTAMP     DS  CL17     


CEEMOUT

This is very similar to WTO. It writes a text to SYSOUT and not to any log (yet)

Excecute form

CEEMOUT label of text,MF=(E,label of list form)
label of text The text must be prefixed with a halfword containing the length of text
label of list form address of the CEEMOUT listform

Example

         CEEMOUT MOUT,MF=(E,PARM)
+         LA    1,MOUT             
+         ST    1,PARM             
+         LA    1,=A(2)            
+         St    1,PARM+4           
+         MVC   PARM+8,=X'80000000'
+         LA    1,PARM             
+         L     15,=V(CEEMOUT)     
+         BALR  14,15


List form

label of list form CEEMOUT MF=L
Label of list form is used as the label for four fullwords that are used as a parameter list.


You must also define the area that will be written to SYSOUT.

Example

PARM     CEEMOUT MF=L
+PARM     DS    4F

MOUT     DS     0F    
MOUTL    DS     H     
MOUTT    DS     0CL70

CEELOCT macro

This is the macro that you can copy directly into your maclib and use it
        MACRO        
&LABEL   CEELOCT &TYPE=TIMESTAMP,&MF=,&RESULT=
.******************************************************
.** Interface to LE subroutine CEELOCT -
.** Get current local date or time
.** [label]  CEELOCT [TYPE=TIMESTAMP,] MF=([E|L],
.**                                   [label_on_list]        
.**                  RESULT=label_to_CL17
.*****************************************************
        AIF   ('&TYPE' EQ 'TIMESTAMP').TIMESTAMP
        MNOTE 8,'Wrong type'
        ANO   .END
.*****************************************************
.TIMESTAMP ANOP               
        AIF   ('&MF(1)' EQ 'E').EXECUTE
        AIF   ('&MF(1)' EQ 'L').LIST
        MNOTE 8,'Wrong MF'
        AGO   .END
.*****************************************************
.EXECUTE ANOP
        LA    1,&MF(2)._LILIAN    
        ST    1,&MF(2)._PARM   
        LA    1,&MF(2)._SECONDS  
        ST    1,&MF(2)._PARM+4
        LA    1,&RESULT    
        ST    1,&MF(2)._parm+8    
        LA    1,&MF(2)._fc  
        ST    1,&MF(2)._parm+12      
        OI    &MF(2)._PARM+12,X'80'     
        LA    1,&MF(2)._PARM        
        L     15,=V(CEELOCT)       
        BALR  14,15    
        AGO   .END       
.*****************************************************
.LIST    ANOP        
&LABEL._PARM    DS  4F        
&LABEL._LILIAN  DS  F       
&LABEL._SECONDS DS  D       
&LABEL._FC      DS  XL12
.****************************************************
        AGO   .END
.END     ANOP
        MEND


CEEMOUT macro

You can copy this macro directly into your maclib and use it.
        MACRO                          
&LABEL   CEEMOUT &TEXT,&MF=             
        GBLC  &PARM                    
        AIF   ('&MF(1)' EQ 'E').EXECUTE
        AIF   ('&MF(1)' EQ 'L').LIST   
        MNOTE 8,'Wrong MF'             
        AGO   .END                     
.LIST    ANOP                           
&LABEL   DS    4F                       
        AGO   .END                     
.EXECUTE ANOP                           
        LA    1,&TEXT                  
        ST    1,&MF(2)                 
        LA    1,=A(2)                  
        St    1,&MF(2)+4               
        MVC   &MF(2)+8,=X'80000000'    
        LA    1,&MF(2)                 
        L     15,=V(CEEMOUT)           
        BALR  14,15                    
.END     ANOP                           
        MEND

Ingen kommentarer:

Send en kommentar