473,408 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Reverse biwise operation and xor?

I have a rather interesting code with 3 input variables that produce
result (this is a decoder and written by unknown author).

I have to get cd variable by konwing cl, fm and result of the
function...
is this possible?

Code:
#define MAKE_TAG_ID( cl, fm, cd)\
((((UL)(cl)) << ((TB -1) * 8)) | (((UL)(fm)) << ((TB -1) * 8)) |
(MAKE_TAG_ID_CODE (((UL)(cd)))))

And this is related code:

#define MAKE_TAG_ID_CODE(cd)\
( (cd < 31) ? (MAKE_TAG_ID_CODE1 (cd)):\
((cd < 128)? (MAKE_TAG_ID_CODE2 (cd)):\
((cd < 16384)? (MAKE_TAG_ID_CODE3 (cd)):\
(MAKE_TAG_ID_CODE4 (cd)))))
#define MAKE_TAG_ID_CODE1(cd) (cd << ((TB -1) * 8))
#define MAKE_TAG_ID_CODE2(cd) ((31 << ((TB -1) * 8)) | (cd << ((TB-2)
* 8)))
#define MAKE_TAG_ID_CODE3(cd) ((31 << ((TB -1) * 8))\
| ((cd & 0x3f80) << 9)\
| ( 0x0080 << ((TB-2) * 8))\
| ((cd & 0x007F) << ((TB-3)* 8)))

#define MAKE_TAG_ID_CODE4(cd) ((31 << ((TB -1) * 8))\
| ((cd & 0x1fc000) << 2)\
| ( 0x0080 << ((TB-2) * 8))\
| ((cd & 0x3f80) << 1)\
| ( 0x0080 << ((TB-3) * 8))\
| ((cd & 0x007F) << ((TB-4)*8)))

Thanx for any help
Jan 31 '08 #1
1 2113
In article <dd**********************************@q21g2000hsa. googlegroups.com>,
Mrki [MCAD] <ze***********@gmail.comwrote:
>I have a rather interesting code with 3 input variables that produce
result (this is a decoder and written by unknown author).
>I have to get cd variable by konwing cl, fm and result of the
function...
is this possible?
Not with that code, no.

Your Subject heading refers to 'xor', but there are no
xor operations in the code you show, only bitwise or.
>Code:
#define MAKE_TAG_ID( cl, fm, cd)\
((((UL)(cl)) << ((TB -1) * 8)) | (((UL)(fm)) << ((TB -1) * 8)) |
(MAKE_TAG_ID_CODE (((UL)(cd)))))
>And this is related code:
>#define MAKE_TAG_ID_CODE(cd)\
( (cd < 31) ? (MAKE_TAG_ID_CODE1 (cd)):\
((cd < 128)? (MAKE_TAG_ID_CODE2 (cd)):\
((cd < 16384)? (MAKE_TAG_ID_CODE3 (cd)):\
(MAKE_TAG_ID_CODE4 (cd)))))
>#define MAKE_TAG_ID_CODE1(cd) (cd << ((TB -1) * 8))
Consider the case of cd < 31. In that case, MAKE_TAG_ID_CODE1
is used, the result of which will be (cd << ((TB -1) * 8)) .
That will be inclusive-or'd with (((UL)(cl)) << ((TB -1) * 8))
and with (((UL)(fm)) << ((TB -1) * 8)) . Notice that
all three parts are left-shifted by the same amount, so the
"interesting" part of the value will be cl | fm | cd
Now in any bit position where cl | fm is 1, you cannot tell
the difference between cl | fm and cl | fm | cd
because 1 bitwise or'd with anything else is still 1 .

Thus, you cannot uniquely calculate cd knowing cl, fm, and
the result of the function -- not unless you have further information
to know that the bottom five bits of cl and fm are always 0.
--
"I was very young in those days, but I was also rather dim."
-- Christopher Priest
Jan 31 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

59
by: Raymond Hettinger | last post by:
Please comment on the new PEP for reverse iteration methods. Basically, the idea looks like this: for i in xrange(10).iter_backwards(): # 9,8,7,6,5,4,3,2,1,0 <do something with i> The...
19
by: John Keeling | last post by:
Dear all, I tried the test program below. My interest is to examine timing differences between insert vs. append & reverse for a list. My results on my XP Python 2.3.4 are as follows:...
14
by: ford_desperado | last post by:
Why isn't ALLOW REVERSE SCANS the default? Why do we have to - drop PK - create an index - recreate PK What are the advantages of indexes that do not allow reverse scans?
6
by: Zri Man | last post by:
I'm relatively new to DB2 and was reasonably amused to see the REVERSE SCAN availability for Indexes. My assumptions are as follows: DB2/UDB uses B-Tree for indexing by default and is likely...
24
by: Sathyaish | last post by:
This one question is asked modally in most Microsoft interviews. I started to contemplate various implementations for it. This was what I got. #include <stdio.h> #include <stdlib.h> #include...
4
by: Alessandro Riolo | last post by:
I've got a weird thing when reverse engineering a c# project which is declaring and then using an event of type CancelEventHandler as in the following snippet: ... public event...
41
by: rick | last post by:
Why can't Python have a reverse() function/method like Ruby? Python: x = 'a_string' # Reverse the string print x Ruby: x = 'a_string' # Reverse the string
4
by: ranjanmg1 | last post by:
I have a unsigned char.. i need to reverse it.. what the easiest way to do it?? i dont want to tap each bit save and restore etc etc.... Is it possible to perform some bitwise operation which...
15
by: rajash | last post by:
Thanks for the additional comments. Here is a solution to an exercise I had problems with. I still don't think it's really what's wanted as it uses a "state variable" n - but I can't see how to...
9
by: Mark Bryan Yu | last post by:
This set of codes works: But this doesn't: None Please explain this behavior. range(5) returns a list from 0 to 4 and reverse just reverses the items on the list that is returned by
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.