0
votes

I need to know the result of the following sequence of Mainframe Assembler instructions:

LA 0,1
LA 1,2
MR 0,0

Is it:

(a) R0=0, (b) R0=1, (c) R0=2, (d) S0C6

3
It is not a puzzle. It is a simple assembly homework. What seems to be the problem? How far have you got? Where did you get stuck? Show us what you have done so far, please. - Margaret Bloom
Does this mini reference correlate to your knowledge? geraldine.fjfi.cvut.cz/~oberhuber/data/mainframe/prezentace/pmf/… I don't see anything like LA 0,1 . First argument should be a register. - akg
akg: Nice link! Yes, both arguments are registers. "0" is Register 0 and "1" is Register 1. - dstaudacher
@akg The first argument (0) is a register. That reference sheet assumes that Rx type register equates have been set up, which is not always the case. - Steve Ives
@akg the use of Rn to indicate a register is purely conventional, for the programmer, in 360/370/z/Arch assembler. Assuming the R0 is EQUated to 0 (really messes expectations if it EQUates to something else), the use of the R-notation is identical to the use of a plain number. - Bill Woodger

3 Answers

2
votes

The answer will be (a) R0 = 0

According to the POP, the multiplicant is in bit positions 32-63 of R1 (the odd register of the even-odd register pair 0/1). As is the multiplier in case of the MR instruction.

The result interestingly is placed in R0 (the even register of the even-odd register pair 0/1) which contains 0.

Nice puzzle and not obvious.

2
votes

The answer is "(a)". Register 0 will have a value of 0 after the multiply.

Explanation for "MR x,y" when "x" and "y" are the same register: It doesn't actually multiply the register by itself (although you'd naturally think it does) because the first operand (multiplicand) is actually in R₁+1 while the second (multiplier) is in R₂:

See Principles of Operation,7.5.52 MULTIPLY

...The multiplicand is taken from general register R₁+1.

So, when MR specifies the same register for both operands, the values for the multiplicand and multiplier can actually be totally different!

In IBM's Principles of Operation manuals, the convention for register naming uses a subscript equal to the position of the register in the instruction. So, "MR R₁,R₂" (sub1,sub2) just means the instruction specifies two registers, with "R₁" the first and "R₂" the second. Some instructions, like BXH and BXLE, even specify three registers, in which case the third is designated R₃.

But "R₁" isn't necessarily "Register 1". In fact, for MR, it must not be, since the first operand specifies an "even register of an even-odd pair", the "odd" part being "R₁+1". And quite surprisingly, the value in "R₁" itself plays no part in the calculation! It only serves to specify the 64-bit register pair into which the 64-bit result is is placed. Regardless of whether it contains a zero value, a non-zero value, or even a negative value, it will not change the outcome of the instruction!

So, while "MR 0,0" would appear to calculate the square of an identity, it actually calculates the product of two separate values: one in R₁+1 and the other in R₂, which may be totally different! Here's a direct link to the MR instruction specification in the ESA/390 Principles of Operation. ESA/390 was a 32-bit architecture which makes the descriptions easier to understand than those in the z/OS (64-bit) manuals: [PoP]http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DZ9AR001/7.5.52

And thanks to IBM's stubborn insistence on upward compatibility, the effective result of every machine instruction defined here is exactly the same today as it was then, indeed for every machine instruction since System/360 (1964).

-2
votes

LA 0,1 LA 1,2 MR 0,0 Is it:

(a) R0=0, (b) R0=1, (c) R0=2, (d) S0C6

R0 will be 0