I would call it obscure. Coding instruction as DC, and not even honoring 
instruction boundaries, serves no purpose exceptmaking it harder to read.

--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3
עַם יִשְׂרָאֵל חַי
נֵ֣צַח יִשְׂרָאֵ֔ל לֹ֥א יְשַׁקֵּ֖ר




________________________________________
From: IBM Mainframe Assembler List <[email protected]> on behalf 
of Martin Ward <[email protected]>
Sent: Tuesday, February 17, 2026 1:21 PM
To: [email protected] <[email protected]>
Subject: Clever code to celebrate


External Message: Use Caution


Some "clever code" for everyone to "celebrate".
When I saw it, I have to confess, I *didn't* think
"Why didn't I think of that?"(!)

The module starts with a block of data, followed by some code
(do you think that this will be dead code therefore?):

A00000   DC    X'000047F0'
          DC    X'F01447F0'
          DC    X'F01047F0'
          DC    X'F00C47F0'
          DC    X'F00847F0'
          DC    X'F004'
          STM   14,12,12(13)
          L     0,0(0,1)

The entry points, XXXX, YYYY, XXXX1, XXXX2 and YYYY1, are defined
as EQUates which are offsets into this data block:

XXXX     EQU   A00000+2
YYYY     EQU   XXXX+4
XXXX1    EQU   YYYY+4
XXXX2    EQU   XXXX1+4
YYYY1    EQU   XXXX2+4

So when you call "XXXX" you start executing the data two bytes
after the address A00000. This happens to be the hex data X'47F0F014'
which is, of course, the object code for a branch instruction.
The instruction will branch to the address at X'0014' off R15.
Since R15 is the address of the entry point, this will branch
to address X'00016' which is the STM instruction.

It copies R15 to R1, does a BALR on R15 (to get a single base address
for the USING), then compares R1 with the address A00028
to get an offset into a jump table, which it loads and branches to.

The jump table code blocks just set R3 to 0, 1, 2, 3 or 4 and
branch to A00062.

I mean, you could just copy the savearea chaining and set R3
for each entry point, but that would be boring!

To see if R3 equals 2, we could do CH R3,=H'2' but that is too boring!

So we do:

          CH    3,A001EA

where A001EA is defined as:

A001EA   EQU   A001E8+2

and A001E8 is, naturally, a table of two halfwords:

A001E8   DC    X'00010002'

Wasn't that clever!

--
                        Martin

Dr Martin Ward | Email: [email protected] | http://www.gkc.org.uk/
G.K.Chesterton site: http://www.gkc.org.uk/gkc | Erdos number: 4


Reply via email to