IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

TM and Registers


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
josephineyeow

New User


Joined: 12 Mar 2020
Posts: 11
Location: USA

PostPosted: Fri Jul 10, 2020 7:32 pm
Reply with quote

Been some 20+ years since I last worked with Assembler (and not much at that).
Need help with understanding -
TM X'0'(R1),X'80'
BC X'7',X'260'(,R12)

No labels other than CSECT

Trying to understand so I can rewrite assembler in Cobol (i'm more of a Cobol programmer)
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Mon Jul 13, 2020 2:32 pm
Reply with quote

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.

Garry.
Back to top
View user's profile Send private message
josephineyeow

New User


Joined: 12 Mar 2020
Posts: 11
Location: USA

PostPosted: Mon Jul 13, 2020 8:58 pm
Reply with quote

Thanks Gary. Thought I'd posted on the Assembler forum. My senior moment.
Your explanation really clarifies it. Had been going through website after website which left me more confused and addled. icon_biggrin.gif
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Tue Jul 14, 2020 4:17 pm
Reply with quote

Glad to have been of help icon_smile.gif Thanks for letting us know.

Garry.
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Wed Jul 15, 2020 12:20 am
Reply with quote

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.
Code:
Condition   BC
  Code     Mask
  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.

I hope that helps.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2011
Location: USA

PostPosted: Wed Jul 15, 2020 4:28 pm
Reply with quote

Just a friendly reminder.
Nowadays all said above about BC instructions is also applicable to more convenient (in most cases) JUMP instructions (or BRC instructions in full notation):

J (or BRC B'1111') - unconditional Jump
JNOP (or BRC B'0000') - No Operation in new format
JE/JZ (or BRC B'1000') - Jump on Zero / on Equal
. . . . . . .
etc.

Please refer to Branching with extended mnemonic codes
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Jul 15, 2020 9:36 pm
Reply with quote

Quote:
going through website after website

I hope that you also tried the manual 'zArchitecture Principles of Operation' icon_wink.gif . Not very easy reading, but it does contain a discription of all instructions.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Floating Point Registers PL/I & Assembler 1
No new posts Query regarding registers . PL/I & Assembler 6
No new posts Counting registers using DFSORT DFSORT/ICETOOL 1
No new posts Limit the number of registers copied ... DFSORT/ICETOOL 2
Search our Forums:

Back to Top