I have written below code in my test program to understand the AH instruction.
ADDIT LA R2,ADD1
WTO 'ADDITION(AH) OF X''31 WITH X''14 IS NOT X''45'''
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'
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
Joined: 14 Jan 2008 Posts: 2504 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.
By using the immediate instructions, you can save yourself two LTORG entries, as with immediate instructions, the value is part of the instruction itself.