Can I use an EQU in z/OS HL/ASM for a value in a DC?

65 views Asked by At

I am trying to figure out the syntax to assign a computed constant to a constant. I want to assign the fixed value 13 to JACK. I tried as follows:

FRED EQU 6
JOE  EQU 7
JILL EQU FRED+JOE
JACK DC F(JILL)
     END

But I got an invalid delimiter. I can see that JILL is indeed 13, and if I make this

FRED EQU 6
JOE  EQU 7
JILL EQU FRED+JOE
JACK DC A(JILL)
     END

it 'works', but I want JACK to be a full word, not an address (I guess it's 4 bytes in either case, but it seems like 'false advertising')

2

There are 2 answers

0
WStanzl On BEST ANSWER

Your second method is valid, and there is nothing wrong with it.

EQUs are 'kind-of' addresses when you take into consideration that we use the LA Rx,EquLabel instruction - which is a Load Address (syntactically, at least) - to load its value, and we use EQU * for the current (relative) address in assembly code. Nevertheless, they are plain integer values in the end. We also use EQU to define aliases for register numbers as in R15 EQU 15.

A plain JACK DC A(Jill) does the same as defining a full-word.

N.b. You can also define other lengths using AL1, AL2, and AL3. The invalid delimiter in JACK DC F(JILL) is issued because DC F requires quotation marks as value delimiters, not parentheses, but the quotation marks keep the assembler from replacing the EQU label with its value, so we can't use an equ to define a fullword, or any other type except an address constant for that matter.

A(Label) - with parentheses instead of quotation marks - is kind of an "emergency exit" for cases like yours; I personally would still code FRED DC F'6' and JOE DC F'7', which is more straightforward.

3
BearGFR On

A(...) by default generates a 4-byte address, i.e. a full word. If you want to control the length explicitly though, you can: ala JACK DC AL4(JILL) Part of your issue is that the argument of an EQU assembler instruction is by definition an address, either absolute, relocatable, or complexly relocatable so the effective value of a resolved EQU instruction is also an address. Coding DC F'an address' won't work because it's a type mismatch. Reference: https://www-40.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3sc264940?OpenDocument