Structured Assembler Language Translator

The structured assembler language translator "SALT" is a software tool that provides following functionalities to IBM Assembler programmers:

Programs produced by SALT will be:

SALT is not a compiler since it does not produce object code. The output of the translator is an Assembler program that should be submitted to the operating system for assembling and linking.

Native Assembler instructions and operating system macros can be freely intermixed with SALT statements. SALT can be used in the z/OS, z/VM and z/VSE environments.

A SALT program sample is included at the end of this section.


Program Structuring Statements

A SALT program starts with a MAIN BEGIN and is terminated with a MAIN END. On entry to the program, a chain of saveareas is provided, for use by modules called by the main routine.

A program module is contained within a MODULE BEGIN and a MODULE END statement. A module is invoked with the CALL statement. The module exits to the calling sequence by means of a RETURN statement. On return, a returncode may be provided. Module calls may be nested up to the depth specified on the MAIN BEGIN statement. The hardware registers are automatically saved on entry to the module and restored on its RETURN.

SALT provides a STATIC section where the program should define its read-only variables.

A DSA section is provided for the definition of read-write variables.


Conditional Statements

IF / ENDIF statement

Code contained within the IF and ENDIF statements is executed when the condition specified on the IF statement is true.

WHILE / ENDWHILE statement

Code contained within the WHILE and ENDWHILE statements is executed as long as the condition specified on the WHILE statement is true.

UNTIL / ENDUNTIL statement

Code contained within the UNTIL and ENDUNTIL statements is executed as long as the condition specified on the UNTIL statement is false.

REPEAT / ENDREPEAT statement

Code contained within the REPEAT and ENDREPEAT statements is executed until the value specified on the REPEAT statement is reached.

CASE /  WHEN / OTHERWISE / ENDCASE statement

Code written after a WHEN clause is executed when the condition on the WHEN statement is true. If not, the next WHEN clause is evaluated. The OTHERWISE clause is executed if all WHEN conditions are false.

Conditional statements may be nested: an IF block may be contained within a WHILE block and so on.

Specifying a condition


Assignment Statement

<expression> has the format <operand_1> <arithmetic_operator> <operand_2>


Macros

Macros are provided to invoke a number of following additional program functions:


Tracing facility

Builtin tracing allows to trace invocation of called modules and application "snap" requests. The facility is dormant and can be activated at run time by specifying the DEBUG keyword when invoking the generated program.


Example

SSPWDAY MAIN BEGIN

*---------------------------------------------------------------*
*     Compute the day of week for a given date. 
*      
*     Input  R1  : Address of the date in YYYYMMDD format 
*     Output R15 : Day Of Week from 0 to 6 
*                  (where 0 = Sunday, ... , 6 = Saturday)
*----------------------------------------------------------------*

*     set leap_year to 0 or 1
*     nnn = (((mm + 2) * 3055) / 100) + dd - 91
*     if nnn > (59 + ly) then nnn = nnn - 2 + leap_year
*     t = (yyyy / 100) - 6 - (yyyy / 400)
*     day_of_week = (nnn + ((yyyy * 5) / 4) - leap_year - t) // 7

*----------------------------------------------------------------*

    R2 = 0(R1)
    INPUT_DATE = 0(R2)

    YYYY = INPUT_YYYY
    MM   = INPUT_MM
    DD   = INPUT_DD

    CALL CHECK_LEAP_YEAR

    LEAP_YEAR = R15
    NNN = MM + 2 * 3055 / 100 + DD - 91
    WK1 = 59 + LEAP_YEAR
    IF NNN > WK1
        NNN = NNN - 2 + LEAP_YEAR
    ENDIF

    WK1 = YYYY / 400
    T = YYYY / 100 - 6 - WK1

    WK1 = YYYY * 5 / 4
    WK2 = NNN + WK1 - LEAP_YEAR - T / 7
    DAY_OF_WEEK = SALTREM
    R2 = DAY_OF_WEEK

    RETURN R2
    MAIN END

*--------------------------------------------------------*
CHECK_LEAP_YEAR MODULE BEGIN
*--------------------------------------------------------*

    R5 = 0
    R2 = YYYY / 4
    IF SALTREM = 0
       R5 = 1
    ENDIF
    R2 = YYYY / 100
    IF SALTREM = 0
       R5 = 0
    ENDIF
    R2 = YYYY / 400
    IF SALTREM = 0
       R5 = 1
    ENDIF
    RETURN R5

    MODULE END

*--------------------------------------------------------*

    STATIC BEGIN
    STATIC END

*--------------------------------------------------------*

    DSA BEGIN

INPUT_DATE    DS  CL8
*
              ORG INPUT_DATE
INPUT_YYYY    DS CL4
INPUT_MM      DS CL2
INPUT_DD      DS CL2
*
YYYY          DS F
MM            DS F
DD            DS F
LEAP_YEAR     DS F
NNN           DS F
T             DS F
DAY_OF_WEEK   DS F
WK1           DS F
WK2           DS F

    DSA END

    END