Post by ***@yahoo.com.au [hercules-os380]I believe there is some issue with the BXLE
instruction or something similar that it breaks
down when memory operands are on some
sort of boundary.
From the z/Arch POP on BXLE I see:
Since the addition and comparison operations performed during the execution of these instructions treat the operands as 32-bit signed binary integers, the value following 2 - 1 is not 2, which cannot be represented in that format, but -2. The instruction does not provide an indication of such overflow. Consequently, some common looping techniques based on the use of these instructions do not work when a data area ends at address 2 - 1. This problem is illustrated in a BRANCH ON INDEX LOW OR EQUAL example in Appendix A, âNumber Representation and Instruction-Use Examples.â A similar caution applies in the 64-bit addressing mode when data is at the end of a 64-bit address space and BRANCH ON INDEX HIGH (BXHG) or BRANCH ON INDEX LOW OR EQUAL (BXLEG) is used.
I am surprised that the 64-bit version is at
the end of the 64-bit address space instead
of at the end of the signed 64-bit integer,
ie 2**63 - 1. Given that the POP also says:
For purposes of the addition and comparison, all operands and results are treated as 32-bit signed binary integers for BXH and BXLE or as 64-bit signed binary integers for BXHG and BXLEG.
And in Appendix A they show:
LA 6,GROUP Load first address
LA 8,4 Load increment 4
LA 9,GROUP+39 Load compare value
LOOP NI 3(6),X'FE' AND immediate
BXLE 6,8,LOOP Test end of loop
The technique shown in Example 2 does not work, however, on an ESA/370 system when it is in the 31-bit addressing mode and the data is located at the rightmost end of a 31-bit address space. In this case, the compare value would be set to 2-1, which is the largest possible 32-bit signed binary value. The reason the technique does not work is that the BXLE and BXH instructions treat their operands as 32-bit signed binary integers. When the address in general register 6 reaches the value 2-4, BXLE increments it to a value that is interpreted as -2, rather than 2, and the comparison remains low, which causes looping to continue indefinitely.
This situation can be avoided by not allowing data areas to extend to the rightmost location in a 31-bit address space or by using other technique
So I think that even in AM32, I will have a problem
at the 2 GiB location rather than the 4 GiB
location.
But why does the 2 GiB issue disappear
(I believe) in AM64, even for the 32-bit BXLE
instruction?
BFN. Paul.