Page 1 of 2

Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 11:30 am
by anbullavan
Hi everybody,

I'am a newbie to PL/1 and I'm now trying to execute some sample programs to understand the concepts of PL/1. I'm trying to do a simple program to understand the pointer concept. My aim is to display the value of a variable and the address location it is stored. Below the code. When i'm executing the below program it abends with SOC4 Protection exception error. I understand this is because of iam trying to display a Hexa variable using PUT list( Var A). Can somebody here guide me on how I can acheive my expected result.

Please excuse me this is a very Noob question. :-)

MAINSUB:PROC OPTIONS(MAIN) REORDER;                                                     
DCL A POINTER;                                       
DCL B CHAR(10) BASED(A);                             
DCL SYSPRINT FILE STREAM OUTPUT PRINT;               
B = '500';                                           
PUT SKIP LIST('A =',A);                             
PUT SKIP LIST('B =',B);       
END MAINSUB;

Re: Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 11:55 am
by BillyBoyo
The value of your pointer (A) will be zero or some random value, so highly likely to be outside storage that you can access. You then assign to B. S0C4.

It is important to learn how to find which instruction in your program has caused an abend. It prevents idle speculation about instructions which have not been reached yet.

If you want to delete/comment-out "B = '500'" and the PUT for B, you may find that your program will run, and you can see the value of A.

Re: Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 12:06 pm
by anbullavan
Hi Billy , thanks for your time and response. Yes , when i commented out the B= 500 and PUt for B , I was able to see the Value of PTR A and it is as you said Zero.

Re: Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 12:23 pm
by BillyBoyo
For your code to work, you'll need A to be "pointing" to some storage which belongs to you.

Re: Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 1:35 pm
by anbullavan
Billy,

DCL B CHAR(10) BASED(A); --> Doesn't mean that A pointer is pointing to B ??? My understanding was that.. Please correct me.

Re: Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 1:52 pm
by BillyBoyo
No, that is not the case. Not according to the manual as I read it. Nor according to what you have written so far. Where did you get that idea?

Re: Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 5:08 pm
by anbullavan
BillyBoyo wrote:No, that is not the case. Not according to the manual as I read it. Nor according to what you have written so far. Where did you get that idea?


Hi Billy,

Sorry it was my fault that I didnt read the concept well. I made the following changes in the code, and now I'm able to display the variable and the address where it is stored . Thanks for giving your time and making me understand .. Correct me if I missed something here.

MAINSUB:PROC OPTIONS(MAIN) REORDER;                 
INC LBSLATPZ                                       
DCL A POINTER;                                     
DCL 1 BGROUP,                                       
    3 BFUNC CHAR(03) INIT ('KAR');                 
A = ADDR(BGROUP);                                   
DCL SYSPRINT FILE STREAM OUTPUT PRINT;             
PUT SKIP LIST('A =',A);                             
PUT SKIP LIST('B =',BFUNC);   
END MAINSUB; 


Output

A =                     000394E0                                     
B =                     KAR                               

Re: Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 5:23 pm
by prino
You are absolutely clueless about pointers, aren't you?

Re: Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 5:42 pm
by anbullavan
prino wrote:You are absolutely clueless about pointers, aren't you?


Yes Prino.. I will read and come back to you.. :D

Re: Displaying an hex Value.

PostPosted: Mon Apr 02, 2012 9:11 pm
by dick scherrer
Hello,

You are absolutely clueless about pointers, aren't you?
Yup, as TS mentioned in the initial post. . .
I'am a newbie to PL/1 and I'm now trying to execute some sample programs to understand the concepts of PL/1. I'm trying to do a simple program to understand the pointer concept.