Then why is the USING with the DSECT instead of the code it belongs with?
-- Shmuel (Seymour J.) Metz http://mason.gmu.edu/~smetz3 עַם יִשְׂרָאֵל חַי נֵ֣צַח יִשְׂרָאֵ֔ל לֹ֥א יְשַׁקֵּ֖ר ________________________________________ From: IBM Mainframe Assembler List <[email protected]> on behalf of David Clark <[email protected]> Sent: Wednesday, February 11, 2026 12:52 PM To: [email protected] <[email protected]> Subject: Re: [External Sender] Re: Move data to a location prior to a given (based) address External Message: Use Caution >> 2) I suspect that you are confused on how USING works. No, I understand perfectly how USING works. It has also been coded that way for 40 years and works perfectly. Perhaps you misunderstand how I intended to actually use a negative reference? The following shows two ways I would possibly use it. IF TXTREQU,NE,C'S' IF NOT IN SCRIPTING MODE MVI TXTRETN,C'B' SIGNAL BUFFER LENGTH ERROR <==LEGACY CODE B RETURN GO RETURN TO CALLER <==LEGACY CODE ELSE ELSE--FOR SCRIPTING MVIY -1(R10),C'B' SAVE AS STRING RETURN CODE MVIY TXTSTRL-1,C'B' SAVE AS STRING RETURN CODE B SCRIPTXT TAKE THE SCRIPTING EXIT ENDIF ENDIF The following snippet, from the assembler listing, shows that either way generated the same machine code. Now, some might argue that, visually, the second one might confuse someone coming after me. After all, what I am doing with this line has nothing to do with TXTSTRL except that the byte I want to update is definitely the one immediately preceding it in the caller's storage. But, though the first line might require the next person to do more research, any objections to it? Alternatives? 000662 EBC2 AFFF FF52FFFFFF 887 MVIY -1(R10),C'B' 000668 EBC2 AFFF FF52FFFFFF 888 MVIY TXTSTRL-1,C'B' Sincerely, Dave Clark On Tue, Feb 10, 2026 at 8:48 PM Tony Harminc <[email protected]> wrote: > A few comments. > > 1) Rule number 1: Don't lie to the assembler. > > I think that even though you may get it to work, having the possibility of > a register pointing to different places in a DSECT is going to cause you > grief sooner or later. And certainly will cause grief to the next person > who works on the code. Usually you don't change the value of a register > that you've used in a USING statement. The typical use case for doing so is > when you step through a chain or array of identical data structures mapped > by a DSECT. I don't think that's what you are proposing here. > > 2) I suspect that you are confused on how USING works. In particular, while > it's not strictly wrong to have a USING in your DSECT, you should be aware > that a USING takes effect at its position in the source module, and ends > either at the end or when you issue a matching DROP or another USING that > replaces the earlier one. Positioning it as you have suggests that you > think that position is somehow related to addressing fields in that DSECT. > It's not. > > 3) There are three kinds of instruction that can effectively use negative > displacements. The most straightforward are the "modern" ones that have a > 20-bit signed displacement, and are mostly part of the long-displacement > facility, and mostly have mnemonics ending in Y. If, in your example, you > had R10 pointing to say TXTSSTRG, you could use this kind of instruction to > address fields both before and after that field. There are Y versions of > many of the classic RX instructions. But note that there are no 20-bit > versions of the SS ones like CLC and MVC. These are already 6 byte > instructions and there's nowhere to put a larger displacement field, let > alone two. > > Second are the relative instructions that also use a signed displacement to > address a field relative to the current instruction address. There is no > register involved with resolving the address, so these won't help you in > dealing with a DSECT or any fields that don't have an offset from your > instructions that isn't known at assembly (or in some cases binder) time. > > Third are the old original RX instructions such as L and LA. While their > addressing arithmetic is unsigned, the effect of specifying a negative > number as the displacement produces the same result as signed arithmetic > would, and so it is possible to effectively subtract a constant from the > sum of base+index+displacement if the index (or base) is negative. Again, I > doubt that this technique is going to be useful or easy to write (and > read). > > A negative offset isn't going to work on an MVC instruction, because there > is only a base register (or two), and that is needed to point to the data. > If an AI suggested this, well... don't pay too much attention. > > Overall I'm still not sure what you're trying to accomplish here. Can you > give a brief example of the two (or more?) kinds of calls to your routine? > > Tony H. > > >
