›› Defining data

Index



Define constants (DC)

The define constant instruction define a piece of storage with a initial value. The word constant is misleading because this value can be changed at any time. This storage area will take up space in your program


Instruction format

label     DC     dtl'c'

The d defines a duplication factor and this is optional. If left out this will be assumed to be 1. You can use a 0 for the duplication value. For datatypes H, F and D this will for boundry alignement. The bytes skipped in the rocess to get the alignment correct will be set to zero.

The t defines the type of data the storage area will contain.

l Allows you to define an explicit length. Using a length value causes no boundary alignment to occur.

Some of the valid storage types are:

Duplication factor

The duplication factor allow you to tell the assembler to define multiple of the data items you defined. This is optional and if you leave this off the assembler will assume you specified 1. This duplication factor need to be a unsigned numeric value.

F - Fullword

This value is a signed, binary integer and the assembler will convert this value into a 32 bit two's complement value.
The range of numbers storable in a fullword is -2147483648 to +2147483447. This is -2^31 and +2^31.

Padding is on the left with zeros and truncation is not allowed.


H - Halfword

This is the same as a fullword but half the bits. It uses 16 bits or a halfword as the name implies. The maximum values to store in a halfword is -32768 and +32767. This is -2^15 and +2^15.

Padding is on the left with zeros and truncation is not allowed.


X - Hex

Data is allocated on a byte boundary and the minimum number of bytes required to store the value will be used. The data is stored as unsigned hex integer. 2 digits can fit into one byte. If you specify an uneven number of digits the assembler will pad your value on the left with a zero. The maximum number of characters you can store in this data type is 256 bytes. Valid data are hex digits 0-9 and A-F.

Padding is on the left with zeros and truncation will also be on the left.


B - Binary

Allow you to define your data in binary format. If you do not define the data on a 8 bit (1 byte) multiple the assembler will pad your data on the left with zeros.


C - Character data

Defines and valid EBCDIC character data. If you need to define special characters single quote and ampersand you have to define them twice '' or &&.

Padding and truncation is done on the right and the storage area is byte aligned.


P - Packed Decimal data

In packed format each byte represent 2 numbers and the last digit indicates the sign. The number range is from 1 - 31 digits

Padding and truncation is done on the left. Padding is with hexadecimal zeros.The storage area is byte aligned.


Z - Zoned Decimal data

Each byte consists of two pieces. The left half (4 bits) of the byte represent the zone and the right half (4 bits) represent the number.

Padding and truncation is done on the left. Padding is with hexadecimal zeros.The storage area is byte aligned and the data range is 1 to 16 bytes.


A - Address Constant

This is also known as a A-CON. This storage area consist of an absolute or relocatable expression. On difference with A_CON definitions is the constant (c) value is defined in parentheses instead of quotes.

Padding and truncation is done on the left. Padding is with hexadecimal zeros.The storage area is fullword aligned and is 1 to 4 bytes long. No alignment is done if explicit length are specified.


V - Address Constant

This is also known as a V-CON. This storage area will consist of an symbol. As with A_CON's the constant (c) value is defined in parentheses instead of quotes.

The instruction format looks like this: dVln(symbol)

Padding and truncation is done on the left. Padding is with hexadecimal zeros.The storage area is fullword aligned and is 1 to 4 bytes long. No alignment is done if explicit lengths are specified.

This data type is typically used when dealing with sub programs and is used to define a external address. More or sub programs in another section but the next example will show how to define a literal V-CON with the entry point of a sub program and branch to this sub program sitting the return address to R14.

          L      R15,=V(SUBPGM) /* Entry of SUBPGM stored in R15    */
          BALR   R14,R15        /* Go to address in R15 and set R14 */
                                /* to the return address.           */

FCONST1   DC     F'18'       /* Define a fullword containing         */
                             /*     00000012                         */
FCONST2   DC     F'-5'       /* Area will contain FFFFFFFB           */
                             /* The two's complement of +5 is stored */
FCONST2   DC     FL3'32'     /* Define a two's complement 3 byte no  */
                             /* boundary aligned binary integer      */
                             /* value. The storage area consist of   */
                             /* '000020'                             */
BCONST1   DC     B'1010'     /* 00001010 will be stored              */
XCONST1   DC     X'ABCDE'    /* This data stored is 0ABCDE. The 0    */
                             /* was added to complete the uneven byte*/
XCONST2   DC     X'C1E2E2C5D5C2D4C5E1' /* Also store 'ASSEMBLER'      */
XCONST3   DC     XL3'678'    /* Define 3 bytes and the storage will  */
                             /* contain '000678'                     */
HCONST1   DC     H'12'       /* '000C' will be in this storage area  */
HCONST2   DC     3H'12'      /* '000C000C000C' will be stored in     */
                             /* this area                            */
CCONST1   DC     C'ASSEMBLER'/* Define storage area containing the   */
                             /* word 'ASSEMBLER'                     */
CCONST2   DC     CL5'DOG'    /* Storage will consist of '  DOG'      */
CCONST3   DC     CL3'BIGDOG' /* Storage will consist of 'BIG'.       */
                             /* Because the explicit length were     */
                             /* specified truncation occurred.       */							  
ACONST1   DC     A(ACONST1)  /* Store the address of ACONST1 in this */
                             /* storage area.                        */
ACONST2   DC     A(*)        /* Use the address in the location      */
                             /* counter and store it in this area.   */
                             /* This is the same as A(CONST2).       */
ACONST3   DC     A(HOME+4)   /* Add 4 to the address where HOME is   */
                             /* and store the address in ACONST3     */
ACONST4   DC     AL3(HOME+8) /* Add 8 to the address where HOME is   */
                             /* and store the address in ACONST4 but */
                             /* the address will only be 3 bytes long*/



Define storage (DS)

The instruction format is very similar to the define constant instruction. The major difference is with DS you define or reserve the storage but the storage area does not get initialized to a initial value at definition time. If you do supply a constant value it would not be used. As with DC the duplication value can be set to zero to force boundary alignment. The bytes skipped will not be set to zero.

Instruction format

label     DS     dtl'c'

Refer to the define storage section for a description of the data types.

FSTG1     DS     F            /* Reserve a fullword (4 bytes)        */
FSTG2     DS     2F           /* Reserve 2 fullwords                 */
HSTG1     DS     50H          /* Reserve 50 halfwords                */
XSTG1     DS     5X           /* 5 bytes reserved with no boundary   */
                              /* alignment                           */
BSTG1     DS     5B           /* Same as above but will describe the */
                              /* data content to humans more clearly */
                              /* Do this to make later debugging     */
                              /* easier.                             */
XTG1     DS     X'1111'       /* The assembler will determine the    */
                              /* length of the constant define the   */                              
                              /* storage area with 2 bytes BUT the   */                              
                              /* area will but be initialized to this*/                              
                              /* values.                             */                              
ALIGN    DS     0F            /*                                     */
         DS     X'12345678'   /* Define a data area the size of a    */
                              /* fullword and force boundry alignment*/
                              /* of a fullword by using a zero       */
                              /* duplication factor.                 */


 

Links