IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Bitwise manipulation in cobol when migrating from Assembler


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Thu Jul 05, 2007 9:58 pm
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
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

Moderator Emeritus


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

PostPosted: Mon Jul 09, 2007 12:19 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top