XTRAN Example — Analyze Year 2000 (Y2K) Impact on MACRO-11


This example shows how XTRAN rules can analyze MACRO-11 code in order to identify symbols and contexts that may be a problem in terms of the Year 2000 (Y2K).  The approach is not specific to MACRO-11; similar XTRAN rules can easily be written for other computer languages, including other assemblers, 3GLs, and 4GLs.  Click for a C / C++ / Java / C# example and for a PL/M example.

Of course, Y2K has come and gone, but this is an excellent example of XTRAN's analysis power, so we decided to keep it on our Web site.

This example comprises 162 non-comment lines of XTRAN's rules language, which we call "meta-code".

Our meta-code reports each symbol name, text string, and comment that includes any of the strings year, yr, or yy (case-insensitively).  It also reports any integer or date $EDMSG format spec it can find.


Rules

XTRAN's rules language, "meta-code", is proprietary and requires a Nondisclosure Agreement.  However, the following is an English paraphrase of the meta-code used in this analysis.  It is functionally equivalent to the actual meta-code used.  NOTE that these rules are COPYRIGHT 2016 by XTRAN, LLC and may not be copied or used in any way without our permission.

For each symbol referenced in module
    If it contains "YEAR", "YR", or "YY"
        Report it
For each statement in module
    If it's a call to $EDMSG
        If previous statement loads R1 with address of format string
            Get format string via address loaded into R1
            If format string contains decimal spec
                Report it
            If format string contains date spec
                Report it
    For each of statement's operands
        If it's a text string
            If it contains "YEAR", "YY", or "YR"
                Report it
    For each of statement's comments
        If it contains "YEAR", "YY", or "YR"
            Report it
Close report file


Process Flowchart

Here is a flowchart for this process, in which the elements are color coded:

process flowchart

Input to XTRAN

 1 DOYR::  MOV     R1,VAR1
 2         CMP     R1,YRVAR        ;NEW YEAR?
 3         BLE     OLDYR           ;IF NOT
 4         MOV     R1,YRVAR        ;YES, UPDATE
 5 OLDYR:  TST     NEW
 6         BGT     10$
 7         MOV     R1,NEW          ;MAYBE NEW YR
 8 10$:
 9         MOV     #EDMBUF,R0
10         MOV     #EDMST1,R1
11         MOV     #EDMAB1,R2
12         CALL    $EDMSG
13         MOV     #EDMBUF,R0
14         MOV     #EDMST2,R1
15         MOV     #EDMAB2,R2
16         JSR     PC,$EDMSG
17         RTS     PC
18 EDMST1: .ASCIZ  /Year = %D/     ;$EDMSG CTL STRING
19 EDMST2: .ASCIZ  /Date = %Y/     ;$EDMSG CTL STRING
20 EDMAB1: .WORD   95.             ;$EDMSG ARG: YY
21 EDMAB2: .WORD   94.             ;$EDMSG ARGS: YY,MM,DD
22         .WORD    12.
23         .WORD    31.
24 EDMBUF: .BLKB   100.            ;$EDMSG O/P BUFFER


Output from XTRAN

*** Possible year symbols ***

DOYR
OLDYR
YRVAR

*** Possible year text strings and comments ***

module.mac(2):  Comment may be about year:  "NEW YEAR?"
module.mac(7):  Comment may be about year:  "MAYBE NEW YR"
module.mac(12):  $EDMSG format spec may be for year:  "Year = %D"
module.mac(16):  $EDMSG 2-digit year date format spec:  "Date = %Y"
module.mac(18):  Text string may be about year:  "Year = %D"
module.mac(20):  Comment may be about year:  "$EDMSG ARG: YY"
module.mac(21):  Comment may be about year:  "$EDMSG ARGS: YY,MM,DD"