Joined: 08 May 2006 Posts: 1113 Location: Dublin, Ireland
As this is an Assembler question, it would be more appropriate to put in the PL/1 & Assembler section.
TM is 'test under mask'.
In this case the mask is X'80' . The instruction, properly written as TM 0(R1),X'80' is checking the high-order bit which is at offset zero from the address in register 1 to see if it is set. Register 1 is used, by convention, to address parameters passed. The high-order bit is set to indicate the last parameter of a list.
BC is 'branch on condition' In this case, the branch is taken to X'260'
(decimal 608) bytes beyond the address in Register 12 if the condition is met.
BC 7 can be:
BNE (branch nor equal) or BNZ (branch not zeroes), neither of which seems appropriate. I'd expect either BO (branch if ones), BNO (branch if not ones), BM (branch if mixed) or BNM (branch if not mixed) after TM.
Joined: 30 Nov 2013 Posts: 891 Location: The Universe
As Mr. Carroll says, programmers use the Test under Mask instruction to test one or more bits specified in the instruction with the contents of a byte in storage. It is usually used to test one bit, but you can specify several bits. The condition code values TM sets seems, at first glance, to have been selected at random, though it makes a little more sense when they are matched with the condition code mask in the Branch on Condition instruction.
In the BC instruction you typically see BZ (e.g., all of the bits that were tested are 0), BO (all of the bits that were tested are 1), or sometimes BM (branch "mixed," some, but not all of multiple bits tested are 1). Less often you see the negative, BNZ (as used here) and so on.
Now I think it would be clearer if Principles of Operation showed the condition code setting as a bit constant 00, 01 or 11, rather than 0, 1, or 3 and the mask in the BC instruction as a bit setting (0000 through 1111 rather than 0 through 15). Each bit in the BC mask corresponds to one, and only 1, condition code setting.
00 (0) 1000 8 Z or E
01 (1) 0100 4 M
10 (2) 0010 2 P
11 (3) 0001 1 O
The letter codes make more sense when they follow most arithmetic operations or comparison operations: Z (zero), E (equal), M (minus), P (plus), O (overflow, for arithmetic instructions that can overflow the max value in a register). When the mask specifies more than 1 bit, the branch decision is ored. 7 means not zero (not equal), not minus, not plus or not overflow. Something like BNE sets mask 0111 (7) and so on.
This scheme breaks down for a few operations like the "logical" arithmetic operations or operations that define multiple outputs. Divide, for example, creates a quotient and a remainder. Should the quotient or remainder set the condition code? Some operations (like Divide) do not alter the condition code.