Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

AH instruction

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
vinayknj

New User


Joined: 26 May 2008
Posts: 50
Location: Bangalore

PostPosted: Thu May 26, 2011 7:19 pm    Post subject: AH instruction
Reply with quote

Hi,

I have written below code in my test program to understand the AH instruction.

Code:
ADDIT    LA R2,ADD1 
         AH R2,=H'20'                                         
         CH R2,=H'69'                                         
         BE  ADDSUC                                           
         WTO 'ADDITION(AH) OF X''31 WITH X''14 IS NOT X''45'''
         B  DISP                                             
ADDSUC   WTO 'ADDITION(AH) OF X''31 WITH X''14 IS X''45'''   
DISP     WTO 'DATA IN R2 AFTER AH INSTRUCTION'               
BACK     RETURN (14,12),RC=0
ADDLEN   DC H'04'       
ADD1     DC X'00000031' 
       END


I could see that the result of AH instruction is not X'45' as it is not going to ADDSUC label.

Please tell me what s wrong with the above code. Thanks
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Thu May 26, 2011 7:22 pm    Post subject: Reply to: AH instruction
Reply with quote

learn the difference between a Load ( L ) and a Load Address ( LA )
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 995
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu May 26, 2011 7:26 pm    Post subject:
Reply with quote

Code:
LA   R2,ADD1
will load the address of the ADD1 variable into R2 - not its content. You want to
Code:
L R2,ADD1 
to get the value X'00000031' but you should really define ADD1 as
Code:
ADD1   DC F'49'


Garry.
[/code]
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu May 26, 2011 7:30 pm    Post subject: Reply to: AH instruction
Reply with quote

You are loading the address of ADD1 into R2, whereas, you need to load the contents. So, change your LA to an L. To ensure alignment (avoid those pesky alignment "warning" messages), you can keep the LA, followed by L R2,0(,R2). This will load the contents located at 0(,R2) into R2 itself. Then all will be fine.

Also, you can change your AH and CH to AHI and CHI.

AHI R2,20
CHI R2,69

By using the immediate instructions, you can save yourself two LTORG entries, as with immediate instructions, the value is part of the instruction itself.

Bill
Back to top
View user's profile Send private message
vinayknj

New User


Joined: 26 May 2008
Posts: 50
Location: Bangalore

PostPosted: Fri May 27, 2011 12:40 pm    Post subject: AH instruction
Reply with quote

Thanks everyone. I was able to execute as desired after changing to L instead of LA. Thanks for making me clear on L and LA.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Fri May 27, 2011 3:05 pm    Post subject: Re: AH instruction
Reply with quote

vinayknj wrote:
Thanks everyone. I was able to execute as desired after changing to L instead of LA. Thanks for making me clear on L and LA.


Using L in place of LA and vice-versa is a type of error that is really difficult to notice when you are quickly browsing through your program.
It unnecessarily wastes programmer's time.

Pay special attention when you are "copy-pasting" someone else's code in your program. L and LA are 2 very similar looking but functionally different instructions.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Interpret instruction not working in ... spoorni CLIST & REXX 2 Fri Feb 07, 2014 10:22 pm
No new posts Displaying the value set by the EXIT ... Ricardo Viegas CLIST & REXX 12 Tue Dec 03, 2013 5:17 am
No new posts Data studio(for zos) instruction manual srilata83 DB2 2 Fri Jan 18, 2013 10:37 am
No new posts AL1(XXX) usage in DC instruction yugendran PL/I & Assembler 1 Thu Dec 06, 2012 3:59 pm
No new posts Assembler compare instruction Arunkumar Chandrasekaran PL/I & Assembler 3 Thu Jul 19, 2012 11:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us