I wanted the length aligned on the odd byte, so the immediately following (labeled) string was on a halfword boundary and could therefore be referenced using a LARL.
Just realized my expression was doing DIVISION by 2 instead of the MODULO 2 I wanted. I was calling it a (conceptual) CNOP, since it was an attempt to force alignment on one boundary within another boundary. I sometimes use CNOP within dsects to do this. Thanks for spotting the [now obvious] flaw in my code. Robert Ngan CeleritiFinTech Services -----Original Message----- From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@LISTSERV.UGA.EDU] On Behalf Of Tony Harminc Sent: Friday, August 19, 2016 15:31 To: ASSEMBLER-LIST@LISTSERV.UGA.EDU Subject: Re: Friday puzzle: CNOP 1,2 On 19 August 2016 at 14:47, Ngan, Robert <rn...@csc.com> wrote: > I'm writing a macro to build length prefixed character strings. The length is one byte, and the actual string is referenced by LARL so it needs to be halfword aligned. The string needs to be halfword aligned, or the length byte does? > So I coded (what would be a CNOP 1,2 - if it was valid): I don't see how CNOP comes into this. CNOP (Conditional No OPeration) is used to pad an instruction stream with NOPRs (X'0700'); it makes no sense for data. (Not that it's *wrong* to generate unneeded 0700s, but that's why there is no sense to CNOP 1,2.) > DC (1-(*-&SYSECT)/2)X'00' Simulate a CNOP 1,2 > > However, this generates ASMA067S Illegal duplication factor. You're on the right track here, I think, but I think your calculation is not quite right. How about: DC (1-((*-&SYSECT)-(*-&SYSECT)/2*2))X'00' Or just use DS: DS (1-((*-&SYSECT)-(*-&SYSECT)/2*2))X Or you could use something similar with an ORG. I'm not clear if you want the length to be generated as a byte before the data (on the odd boundary), and if so where the label should be. This seems to produce reasonable results, assuming you want the label on the halfword aligned data: TEST CSECT PRINT DATA MACRO &name CSTRING &data &dat SETC DEQUOTE('&data') &len SETA DCLEN('&dat') DS (1-((*-&SYSECT)-(*-&SYSECT)/2*2))X DC FL1'&len' &name DC C'&dat' MEND DataA CSTRING 'Some data' DataB CSTRING 'Some more data' DataC CSTRING '12345' DataD CSTRING '1234' DataE CSTRING '1' DataF CSTRING NoQuotes DataG CSTRING 'O''Connor' END This is somewhat but not completely robust wrt the operand - it can be quoted or not as you like. Of course if you want the label on the odd-byte-aligned length byte, just move it. You could also do tricks to give the label the right length attribute. &name EQU *,&len+1 would give it the length of the string plus the length byte. etc. etc. Tony H. CSC - This is a PRIVATE message - If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind the Company to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.