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

AH instruction


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu May 26, 2011 7:22 pm
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

Senior Member


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

PostPosted: Thu May 26, 2011 7:26 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu May 26, 2011 7:30 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. Assembler - Packed Decimals - PACK in... PL/I & Assembler 3
No new posts Using L' to get length of instruction PL/I & Assembler 1
No new posts LA instruction in assembler PL/I & Assembler 4
No new posts The Test under Mask (TM) Instruction PL/I & Assembler 7
No new posts Control-M restart instruction CA Products 2
Search our Forums:

Back to Top