I've been watching this discusson with interest... But - no-one has mentioned the "clobber" list of GCC-style in-line ASM (which the IBM compiler seems to mimic.)
For GCC, and the Dignus GCC-style in-line ASM, the clobber list can include a specification of "memory". Which indicates that memory is altered by the in-lne ASM; that in-line BALR should also indicate other registers that are altered (e.g. R14 & R15) by the text that will be copied to the generated output. The compilers don't look at the text in any way (if you consider the intracacies of HLASM macro preprocessing, for example, the compilers really _can't_ look at the text.) It's only in the input/output/clobber specifications that the developer can communicate the intent of the in-line ASM to the compiler. Specifying the proper items in the clobber-list will cause our compiler to retain the in-line asm (since the code appropriately indicates some things are "changed") when it should, and allow it to safely eliminate it when it can. But - early this morning I perused the IBM __asm documentation, and while it seems to use the clobber-list in the examples, it doesn't seem to document it... so?? I'm not sure what the IBM compiler does with that info, or if it supports the clobber-list. And - following some of the other comments; our compiler takes the more conservative approach. With our traditional in-line ASM source we take a total "black box of unknown voodoo" approach and are *very* conservative with it. With GCC-style, we can do a little bit better and only note the changes indicated in the __asm() specifications. Proper specifications (including correct clobber items) will let the compiler know exactly how to treat the in-line ASM. As far as the standards, the various C standards describe an "asm" extension, which may or may not be provided in any implementation. But, any C implementation can add its own keywords, as long as they conform to the standard conventions of beginning with two underscores or an underscore and a capital letter. Hence, the "__asm" statement is an extension outside the scope of the standard. It's up to the implementaton. If IBM doesn't support GCC's clobber-list, then I'd suggest that be added as an RFE and then this problem would be solved. For more information about GCC's approach to this, see: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html For more information about the Dignus compiler's approach, see: http://www.dignus.com/dcc/sysc.pdf starting at page 112. - Dave Rivers - -- [email protected] Work: (919) 676-0847 Get your mainframe programming tools at http://www.dignus.com
