Yes, I know SR 2,2 stores binary 0s in register 2, but since the very next instruction loads 32 bits of something into the register, why set it to 0s first? The first computer I worked with was the IBM 7040. It did not have a Load instruction. It had a CLear and Add (CLA) instruction; CLA did exactly what the name says.tetra wrote:...
SR 2,2 - It's like doing the zero in register 2
There are times when something similar is appropriate. For example
This Insert Characters under Mask instruction replaces bits 16 through 31 of the 32-bit register 2 with the 2 bytes at SUM, so it is appropriate to set bits 0 through 15 before the ICM instruction. Your thought about a "macro" is interesting, but incorrect. For example
&NAME LOADREG &R,&ADDR
&NAME SR &R,&R
+ SR 2,2
+ L 2,SUM
IBM macros often expand into dubious code. One macro, for example, generates
+ MVC something(2,1),=FL2'0'
Many years ago the PUT and GET macros generated
+ L 15,48(1)
Suddenly, for no obvious reason, it changed to
+ SLR 15,15
+ ICM 15,7,49(1)
The L instruction was dubious enough. It really should have been
+ L 15,48(,1)
The L instruction in the old macro directs the hardware to add the contents of "index" register 1 to what amounted to binary 0s to compute the address; on some of the slower machines of that era this was slower than the more correct form I showed, which uses a base register but no "index" register.
Then why the "new" expansion, which is still used today? After all, it uses 2 instructions rather than 1, and the ICM instruction is slower than the L instruction. The reason: in future (MVS/XA) systems, it allowed the macro to run correctly when the hardware was running AMODE 31. For a time there was sometimes a debate about whether SLR reg,reg was "better" than SR reg,reg. Part of the debate hinged on the fact SR could get an overflow interruption and SLR does not have a potential overflow interruption, but this is not an issue with SR reg,reg: no matter what is in the register the result will be binary 0s. I think some people claimed SLR was faster, though even on very slow machines the difference, if any, was minuscule. In the 1960s, IBM published instruction times for all their machines, something it no longer does.