Using ORG like CNOP

44 views
Skip to first unread message

Charles Mills

unread,
Nov 27, 2016, 8:14:44 PM11/27/16
to ASSEMBL...@listserv.uga.edu
I have a DSECT where I want to define a fullword such that the next address
after the fullword will be on a doubleword boundary. I would like the
alignment to be independent of the preceding alignment (be change-proof).

CNOP 4,8 would do exactly what I want, but CNOP seems inappropriate in
non-executable code.

I naively coded ORG *,8,-4. As luck would have it the existing alignment was
six bytes into a doubleword and so that ended up effectively being ORG *-2.

How do I use ORG to accomplish what I want? Can I use something like what I
coded but always have it ORG forwards and never backwards? I could probably
figure this out but hoped there was someone here who knew the answer right
off.

Or should I shut up and use CNOP: "If it ain't broke, don't fix it."

Charles

Alan Atkinson

unread,
Nov 27, 2016, 8:21:18 PM11/27/16
to ASSEMBL...@listserv.uga.edu
I'm doing this from memory - I can't face logging in.
If I mess it up let me know and I'll pull one tomorrow from a listing.

IIRC something like org (*+7)/8 will do it.


Sent from my iPad

Charles Mills

unread,
Nov 27, 2016, 8:31:47 PM11/27/16
to ASSEMBL...@listserv.uga.edu
Yeah, I have done this in the past somehow with that kind of cleverness, but
it looks like the fancy new three-operand ORG instruction is intended for
exactly this problem.

(*+7)/8 can't be right -- you are dividing * by 8 which can't be right --
but yes, I get the idea.

Charles

Alan Atkinson

unread,
Nov 27, 2016, 8:44:54 PM11/27/16
to ASSEMBL...@listserv.uga.edu
Right I remember vaguely - one of those things one just copies and pastes - we use the csect in there to turn it into a displacement.

More like org csect + (((*-csect)+7)/8)

If that's not it I'll pull one tomorrow.
We use it to round stuff up to page boundaries all over.

Sent from my iPad

Charles Mills

unread,
Nov 27, 2016, 8:56:38 PM11/27/16
to ASSEMBL...@listserv.uga.edu
DS 0D, DS F solves the problem but wastes 8 bytes if the alignment is
already an even doubleword plus 1, 2, 3 or 4. I think ORG *-4, DS 0D, DS F
solves the problem perfectly, so perhaps what I want is ORG *-4,8,-4

Robert Netzlof

unread,
Nov 27, 2016, 9:09:25 PM11/27/16
to ASSEMBL...@listserv.uga.edu
I don't think I've ever done this, but how about:

ORG (*+7)/8*8

Suppose * happens to be 8m, a multiple of 8. Then, (*+7)/8 = m, so
(*+7)/8*8 = 8m, the original value.

Now suppose * is 8m +1. Then *+7 = 8m+8, (*+7)/8 = m+1, (*+7)/8*8 =
8m+8, a multiple of 8.
For * = 8m+2, *+7 = 8m+9, (*+7)/8 = m+1, so again (*+7)/8*8 = 8m+8
That will be the result for all the remaining possible values of *
from 8m+3 through 8m+7.

The "magic" falls out of the integer arithmetic division which yields
0 for 7/8, 1 for 8/8 through 15/8.

Bob Netzlof
--
Bob Netzlof a/k/a Sweet Old Bob

Mike Wallace

unread,
Nov 28, 2016, 12:50:24 AM11/28/16
to ASSEMBL...@listserv.uga.edu
for fullword, dont you want (*+3)/4 ?

aldo....@csebo.it

unread,
Nov 28, 2016, 3:16:25 AM11/28/16
to ASSEMBL...@listserv.uga.edu
When you use an address for service area "DSECT" the address can be
obtained in several ways:
outside past address
address content to another available area memory
address obtained by getmain, ceegtst etc.
Only in the third case, you have the chance to get an address that is
aligned.
In other cases one has to make do with what passes the monastery.

If the area is an area of ​​common use with other modules the definition
thereof must be agreed and defined prior to use.

If the area is local use and his address may not be aligned this can be
aligned properly.

L RegX,address_of_area
La Rebx,7(Regx)
. Srl Regx,3
Sll Regx,3 aligne double
Using area,Regx

dsect
area ds 0d
area1 ds f
area2 ds 0d
area2 ds c' im am dw aligned' define storage only

Aldo Crosio
tel: 051-4991812 /3488858416
fax: 051-6255762


CSE Consorzio Servizi Bancari
Società consortile a responsabilità limitata
Via Emilia n. 272
40068-San Lazzaro di Savena (BO)


Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni contenute nel presente messaggio, corredato dei relativi allegati, sono strettamente riservate ed a uso esclusivo dei destinatari. Qualora Le fosse pervenuto per errore, La invitiamo ad eliminarlo immediatamente, dandocene gentilmente comunicazione. Grazie.
------------ *** ------------ *** ------------ *** ------------

Paul Gilmartin

unread,
Nov 28, 2016, 8:27:03 AM11/28/16
to ASSEMBL...@listserv.uga.edu
On 2016-11-27, at 18:14, Charles Mills wrote:

> I have a DSECT where I want to define a fullword such that the next address
> after the fullword will be on a doubleword boundary. I would like the
> alignment to be independent of the preceding alignment (be change-proof).
>
How about?:
DS 1F
DS 0D
ORG *-4

> CNOP 4,8 would do exactly what I want, but CNOP seems inappropriate in
> non-executable code.
>
OTOH, it's what programmers will be comfortably familiar with.
That weighs heavily in its favor.

-- gil

Jonathan Scott

unread,
Nov 28, 2016, 8:46:15 AM11/28/16
to ASSEMBL...@listserv.uga.edu
Ref: Your note of 27 November 2016, 17:14:43 -0800

Here's a general solution which I mentioned on this list earlier
this year (in the thread "Friday Puzzle: CNOP 1,2"), which shows
how to use ORG for the general case:

MACRO
&LABEL ALIGN &BOUNDARY,&OFFSET
ORG *+&BOUNDARY-(&OFFSET),&BOUNDARY,&OFFSET-(&BOUNDARY)
&LABEL DS 0X
MEND ,

Note that unlike CNOP this macro expects boundary first then
offset, but you can of course invent your own macro the other way
round. In many cases, the ORG can be simplified a little, but
this rather complicated form works even when the current location
counter is less than the specified offset from the start of the
section or LOCTR.

Jonathan Scott
IBM Hursley, UK

Charles Mills wrote:
> I have a DSECT where I want to define a fullword such that the next address
> after the fullword will be on a doubleword boundary. I would like the
> alignment to be independent of the preceding alignment (be change-proof).
>
> CNOP 4,8 would do exactly what I want, but CNOP seems inappropriate in
> non-executable code.
>

aldo....@csebo.it

unread,
Nov 28, 2016, 8:46:42 AM11/28/16
to ASSEMBL...@listserv.uga.edu
Ds 0d is sufficient in data area.

Cnop introduces executable code for alignement ( ie “0700…”)
Each alignment imposed in compiling inside the "dsect" depend only from the
start of the "dsect" itself.

008C 5820 D0C9 000000C9 595 l 2,area+1
R:2 00000000 596 using dsectc,2
0090 41F0 2008 00000008 597 la 15,dwx
Dwx is aligned inside the dsect butt cover for dsect (reg 2) is not
aligned. So compyte address is not aligned (base unaligned displacement
aligned)

000000C8 1083 area ds 0d
area e allineata


00000000 00000000 00000008 2035 dsectk dsect
00000000 2036 dsectc ds 0f
00000000 2037 hha ds h
00000004 2038 wwa ds f
00000008 2039 dwx ds 0d

Paul Gilmartin

unread,
Nov 28, 2016, 9:32:48 AM11/28/16
to ASSEMBL...@listserv.uga.edu
On 2016-11-28, at 06:46, aldo....@CSEBO.IT wrote:

> Ds 0d is sufficient in data area.
>
But it doesn't leave room for the fullword.


On 2016-11-28, at 06:39, Jonathan Scott wrote:
>
>
> Here's a general solution which I mentioned on this list earlier
> this year (in the thread "Friday Puzzle: CNOP 1,2"), which shows
> how to use ORG for the general case:
>
> MACRO
> &LABEL ALIGN &BOUNDARY,&OFFSET
> ORG *+&BOUNDARY-(&OFFSET),&BOUNDARY,&OFFSET-(&BOUNDARY)
> &LABEL DS 0X
> MEND ,
>
> Note that unlike CNOP this macro expects boundary first then
> offset, but you can of course invent your own macro the other way
> round. In many cases, the ORG can be simplified a little, but
> this rather complicated form works even when the current location
> counter is less than the specified offset from the start of the
> section or LOCTR.
>
Does a transitory negative offset from LOCCTR cause problems?
Even if no code is generated there?

But I'll persist in preferring my:

DS 1F
DS 0D
ORG *-4

o Fewer keystrokes
o Easier (for me) to understand.

But does the new-fangled ORG support something really fancy,
such as alignment to a multiple of 5 bytes?

-- gil

Charles Mills

unread,
Nov 28, 2016, 11:09:35 AM11/28/16
to ASSEMBL...@listserv.uga.edu
Thanks all. I don't find any of the solutions totally obvious ("intuitive,"
simple to grasp) but I do have to agree with @Gil that "taking it one step
at a time" with a series of DS's comes closer to obvious.

I took Gil's solution and commented it with the potential offsets relative
to 8 of the location counter following each instruction, and it seems to do
the job.

* Initial 0 1 2 3 4 5 6 7
DS 1F 4 8 8 8 8 12 12 12
DS 0D 8 8 8 8 8 16 16 16
ORG *-4 4 4 4 4 4 12 12 12

But I do want to thank @Jonathan who did answer exactly the question I did
ask.

@Gil, the "new-fangled ORG" supports alignment to 5 or another "odd"
(strange!) boundary, but the offset must be relative to a power of 2. (You
can't effectively CNOP 2,5 but you can CNOP 5,8 or 5,16 etc.)

Charles

-----Original Message-----
From: IBM Mainframe Assembler List [mailto:ASSEMBL...@LISTSERV.UGA.EDU]
On Behalf Of Paul Gilmartin
Sent: Monday, November 28, 2016 6:33 AM
To: ASSEMBL...@LISTSERV.UGA.EDU
Subject: Re: Using ORG like CNOP

Reply all
Reply to author
Forward
0 new messages