View previous topic :: View next topic
|
Author |
Message |
vinayknj
New User
Joined: 26 May 2008 Posts: 50 Location: Bangalore
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
learn the difference between a Load ( L ) and a Load Address ( LA ) |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
will load the address of the ADD1 variable into R2 - not its content. You want to
to get the value X'00000031' but you should really define ADD1 as
Garry.
[/code] |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
vinayknj
New User
Joined: 26 May 2008 Posts: 50 Location: Bangalore
|
|
|
|
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 |
|
|
nigelosberry
New User
Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
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 |
|
|
|