Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how to do bit operations from CHAR

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

New User


Joined: 08 Mar 2016
Posts: 13
Location: Taiwan

PostPosted: Wed May 13, 2020 8:27 pm    Post subject: how to do bit operations from CHAR
Reply with quote

I have to implement a function Like that

CHAR AB
HEX  C1 C2
BIT  11000001 11000010

CHAR CD
HEX  C3 C4
BIT  11000011 11001000

Then BIT1 and BIT2 do XOR

11000001 11000010
11000011 11001000
==============
00000010 00001010

the result must convert bit to hex string
020A

my solution

1. using function HEX convert Char to HEX String
2. Substr(Hex_string,1,1) then call select when
when('0') bit1 = bit1 | '00000000'B;
when('1') bit1 = bit1 | '00010000'B;
when('2') bit1 = bit1 | '00100000'B;
...
3. Substr(Hex_string,2,1) then call select when
when('0') bit1 = bit1 | '00000000'B;
when('1') bit1 = bit1 | '00000001'B;
when('2') bit1 = bit1 | '00000010'B;
...
4. once convert CHAR to BIT(8) , do BIT1 xor BIT2 => BIT3
5. using function convert BIT to hex String HEX(BIT3)

I haven't tried to write the code yet, but I think it probably works, and I just want to make sure is there any easy way to do it or some internal functions can do it easily.
 
 
Back to top
View user's profile Send private message

sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 806
Location: Maryland

PostPosted: Wed May 13, 2020 10:37 pm    Post subject:
Reply with quote

You have a complete mess in your mind regarding datatypes used in PL/I (and probably, regarding the whole IBM environment).

First of all, PL/I doesn't support datatype HEX as you tried to demonstrate. So, the rest of your discussion becomes useless, so far.

Quote:
Data attributes
Data attributes describe computational data, program-control data, and program characteristics.

AREA
BINARY
BIT
CHARACTER
COMPLEX
DECIMAL
DIMENSION
ENTRY
FILE
FIXED
FLOAT
FORMAT
GRAPHIC
HANDLE
LABEL
LOCATES
NONVARYING
OFFSET
ORDINAL
PICTURE
POINTER
PRECISION
REAL
RETURNS
SIGNED
STRUCTURE
TASK
TYPE
UNSIGNED
UNION
VARYING
VARYING4
VARYINGZ
WIDECHAR
WIDEPIC


Likely, you may need to use the bitwise XOR in this manner
Code:
UNSPEC(CHARS1) ¬ UNSPEC(CHARS2)

or maybe something else, depending on your actual requirements.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1207
Location: Vilnius, Lithuania

PostPosted: Thu May 14, 2020 1:06 am    Post subject:
Reply with quote

Code:
dcl (a,b,c) char(2);

unspec(c) = bool(unspec(a), unspec(b), '0110'b);


Next time RTFM, and if you're not an expert, don't post here. And for what it's worth, the HEX builtin does not do what you apparently think it does!
Back to top
View user's profile Send private message
Martylin

New User


Joined: 08 Mar 2016
Posts: 13
Location: Taiwan

PostPosted: Thu May 14, 2020 1:24 pm    Post subject:
Reply with quote

icon_lol.gif icon_lol.gif icon_lol.gif icon_lol.gif

I doing too complex, thanks
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 how to convert Hex String t char hex Martylin PL/I & Assembler 6 Fri Jun 05, 2020 7:45 pm
No new posts Insert System Runtime in HEADER In SY... Rick Ryan SYNCSORT 9 Tue May 26, 2020 9:01 pm
No new posts comparasion between BIN FIXED(63) an... javen777 PL/I & Assembler 10 Wed Apr 22, 2020 5:11 pm
No new posts Code char set conversion from IBM-420... thelefthandofdarkness IBM Tools 4 Thu Jul 26, 2018 3:03 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us