Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Bitwise manipulation in cobol when migrating from Assembler

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

New User


Joined: 05 Jul 2007
Posts: 3
Location: chennai

PostPosted: Thu Jul 05, 2007 6:05 pm    Post subject: Bitwise manipulation in cobol when migrating from Assembler
Reply with quote

hi friends,

I am doing migration work from assembler code to cobol,how to do bitwise manipulation is cobol.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jul 05, 2007 9:58 pm    Post subject:
Reply with quote

Hello and welcome to the forums,

Is this bit manipulation internal to the code or is there data in one or more files that contain bit settings? If the bits are only used internally, i'd look at converting them to bytes instead - much easier to work with. If there are bit settings in your data, you can expand and compress it by working on one byte at a time and using powers of 2 to construct 8 on/off switches.

Keep in mind that all of the values from zero to 255 can be represented in 1 byte. If you want to de-compose a byte, move it to the low-order byte of a 2-byte comp field. If the the value is >127, the high-order bit is marked "on". Subtract 127 and see if the remaining value is >63. If it is, the next bit is marked "on" and so forth.

If you want to build a byte from individual settings, use the same 8 on/off switches and create the "total" by adding 128, 64, 32 etc for the corresponding "on" bits. Use the same 2-byte comp field - make sure you zero it before starting to accumulate.

There may be a more elegant way to do this, but this method has worked on many compilers for many years.
Back to top
View user's profile Send private message
sathyashree

New User


Joined: 05 Jul 2007
Posts: 3
Location: chennai

PostPosted: Mon Jul 09, 2007 11:19 am    Post subject:
Reply with quote

hi dick,


Thank for ur valuable solution....

I am new to assembler,so i want to work on it more,ur answer

was helpful for me.

Thank u friend.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2007 12:19 pm    Post subject:
Reply with quote

You're welcome icon_smile.gif

We're here if there are questions.
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 RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us