On Fri, 3 Sept 2021 at 20:12, Ulrich Weigand wrote: > "Paul Edwards" wrote on 03.09.2021 13:35:10: > > > Specifically, if you try to run AMODE64 with Pmode equals > > > SImode, the compiler will not be aware that the hardware > > > uses the high 32 bits of base and index registers, and > > > will not necessarily keep them zero. > > The compiler naturally keeps them zero. The > > instructions that are used to load registers > > do not pollute the high-order 32 bits. > > While this is true for most instructions, the compiler will not > restrict itself to using only those. (As just one obvious > example, the compiler may use "lay" with a negative displacement, > which will set the high bits of a GPR in AMODE64.) > > (And, b.t.w. not the -m31 DImode, which is a pair of 32-bit > GPRs, but rather the -m64 DImode, which is a single 64-bit GPR.) > Hi all. Turns out I have been asking the wrong question for several years. I was going to generate a peephole (an idea from the author of UDOS, now KinnowOS) to detect when a negative index was being used, and force an addition instead of an index, when I realized that it wasn't just literals that could use a negative value. That is when I realized that negative numbers were perfectly valid/normal for indexing, and that it is the OS/hardware that needs to adapt to this reality when transitioning from 32-bit hardware to 64-bit hardware. As such, I have updated z/PDOS-32 to use DAT to map the 4 GiB to 8 GiB region to 0 to 4 GiB, so that negative indexing works fine. You can download this from http://pdos.org (down the bottom). So would it be possible now to update gcc to make -m32 and -m31 and -m24 all work, as they all generate the exact same code, regrardless of whether you are running as AM24 on S/370, AM31 on S/390 or AM32 on Hercules/380 or AM64 with DAT set appropriately on z/Arch. Thanks. Paul.