Page 1 of 1

difference between TM and CLI

PostPosted: Mon Mar 05, 2012 9:51 pm
by nareshv_99
hi..
can some tell me the difference between TM and CLI instruction or when to use TM and CLI ?

Thanks!

Re: difference between TM and CLI

PostPosted: Mon Mar 05, 2012 10:11 pm
by BillyBoyo
Have you looked in the Principles of Operation ("the POP") for the first part of your question? Knowing that should help with the second part, at least a little.

Re: difference between TM and CLI

PostPosted: Mon Mar 05, 2012 10:31 pm
by nareshv_99
i know the syntax and usage of TM and CLI but i didn't get the difference between them.
TM VAR1,VAR2
BO JMPE
WTO 'not equal..'
B SKIP
JMPE WTO 'equal..'
B SKIP
..
..
VAR1 DC C'123'
VAR2 EQU C'123'


the same validation can be done using CLI too.. so I just wanted to know the difference usage between them.
Thanks!

Re: difference between TM and CLI

PostPosted: Mon Mar 05, 2012 11:09 pm
by BillyBoyo
nareshv_99 wrote:[...]the same validation can be done using CLI too.. [...]


Did you use the POP, or just "know" the syntax? Test under Mask, Compare Logical Immediate. The names are pretty different. Are you saying that all usage of TM can be replaced by CLI (or vice versa)?

Please, consult the POP. Note down differences. Note down similarities. Post them here.

Re: difference between TM and CLI

PostPosted: Mon Mar 05, 2012 11:22 pm
by steve-myers
Well, your program is all wrong. TM and CLI operate on one byte of data using one data byte in the instruction.

CLI DATA,C'X'

compares the first byte of DATA with X.

With TM the data in the instruction is a mask.

TM DATA,C'X'
BO EQUAL

is not the same as

CLI DATA,C'X'
BE EQUAL

The C'X' mask in the TM instruction is B'11100111' (I think, I'm not certain), and the BO would branch if DATA contains, for example, B'11111111' since all the 1 bits in the mask match the corresponding 1 bit in the data. Until you learn the instruction better, stick with using just 1 bit in the mask, and just use BO and BZ after the TM. For example -

TM DCBOFLGS,DCBOFOPN

tests one bit, the DCBOFOPN bit, in DCBOFLGS. This is roughly equivalent to

if (dcboflgs & dcbofopn)

in C.

Now think about this -

TM DATA,255-C' '

What would you use this test for?

Re: difference between TM and CLI

PostPosted: Mon Mar 05, 2012 11:50 pm
by nareshv_99
thanks for providing valuable info.
please consider below scenarios.

TM VAR1,VAR2
BO JMPE

or

CLI VAR1,VAR2
BE JMPE

VAR1 DC X'80'
VAR2 EQU X'80'

so in this case result of both CLI and TM are same rt?

TM VAR1,VAR2
BO JMPE

or

CLI VAR1,VAR2
BE JMPE

VAR1 DC X'88'
VAR2 EQU X'80'

so in this case after executing TM, control will be jumped to JMPE but where as after executing CLI, control won't be jumped to JMPE.

could you correct me if i'm wrong ?

Re: difference between TM and CLI

PostPosted: Tue Mar 06, 2012 12:59 am
by steve-myers
Neither the CLI or TM in your code will assemble. The second operand of both CLI and TM is data that becomes part of the instruction. The CLI you had properly becomes CLC VAR1,VAR2. There is nothing comparable for the TM instruction. I don't think you read or understood my first post.

Re: difference between TM and CLI

PostPosted: Tue Mar 06, 2012 8:09 am
by steve-myers
Sorry, I read your last post wrong. My boo boo.

In the first group, you are correct: the conditional branch after your TM will branch because all of the 1-bits in the VAR2 mask match a 1-bit in VAR1, and the conditional branch after the CLI will branch because all the bits in VAR1 match all the bits in VAR2. Almost all my production program do the TM you have in this group, though I almost always write the code as TM DATA,X'80'.

In the second group, you are correct: the branch after your TM will branch to JMPE because all the 1-bits in the VAR2 mask are present in VAR1. The branch after your CLI will not branch to JMPE: the value of the VAR2 symbol is not equal to the contents of VAR1.