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

Assembler test under mask question


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

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Tue Apr 06, 2021 6:55 am
Reply with quote

Hi experts,

I am looking at the following assembler and i am not sure how exactly the TM instruction is working.


Code:
           L     R2,0(R1)                GET A(ABEND CODE)     
           LH    R1,0(R2)               GET ABEND CODE       
           TM    0(R2),X'F0'           GOOD CODE             
           BZ    ABEND                  YES                   
           LA    R1,4095                ELSE SET DEFAULT     
  ABEND    ABEND  (R1),DUMP                                   
  *        SYMBOLIC REGS,R10=YES                             
           YREGS   


I see the content in register
Code:
R2  ==> 800B719E
and
Code:
R1  ==> 00000000


So for the mask 'F0' --> 11110000 , is it looking for R2 --> 800B?
When i ran the program , the control BZ is go to ABEND which i think R2 should be all zero? but i don't see R2 is all zero so i am confusing..which part of R2 the mask is used on?

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

Active Member


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

PostPosted: Tue Apr 06, 2021 8:46 am
Reply with quote

Reg 2 is the address of the data to test. It is not the data to test. The data to test is at B719E.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2119
Location: USA

PostPosted: Tue Apr 06, 2021 5:49 pm
Reply with quote

The data to “test under mask” is one single byte addressed by R2, with zero offset from R2 value.

The (uncommented) logic looks like:
- get ABEND code from a halfword addresses by R2 into R1
- verify that the code at location R2 is less or equal to X’0FFF’ = 4095
- if not like this, then replace it in R1 with 4095

For clarity the better way would be
Code:
 LH R1,0(R2)
 CHI R1,4095
 JLE *+8
 LHI R1,4095
 ABEND ...
Back to top
View user's profile Send private message
steve-myers

Active Member


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

PostPosted: Tue Apr 06, 2021 7:37 pm
Reply with quote

The instruction is testing the first 4 bits of the nominal ABEND code. If any bits are on the code is invalid and valid user ABEND code is loaded into reg 1.

Sergeyken's code does not do this. Consider the case when the high order bit is on. For example X'FFFF'. The LH sets reg 1 to X'FFFFFFFF' What's going to happen with the CHI/JLE?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2119
Location: USA

PostPosted: Tue Apr 06, 2021 7:46 pm
Reply with quote

steve-myers wrote:
The instruction is testing the first 4 bits of the nominal ABEND code. If any bits are on the code is invalid and valid user ABEND code is loaded into reg 1.

Sergeyken's code does not do this. Consider the case when the high order bit is on. For example X'FFFF'. The LH sets reg 1 to X'FFFFFFFF' What's going to happen with the CHI/JLE?

Agreed.
Better to use
CL R1,=F’4095’
JLE *+8
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Tue Apr 06, 2021 7:59 pm
Reply with quote

Thank you for your replay. now i understand.
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 Question for file manager IBM Tools 7
No new posts Build dataset list with properties us... PL/I & Assembler 4
No new posts question for Pedro TSO/ISPF 2
No new posts Finding Assembler programs PL/I & Assembler 5
No new posts How Can I Recall a Migrated Data Set ... PL/I & Assembler 3
Search our Forums:

Back to Top