Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary representation of constants is unsupported: 0b10101 #36

Open
ErezBinyamin opened this issue Feb 7, 2020 · 1 comment
Open

Binary representation of constants is unsupported: 0b10101 #36

ErezBinyamin opened this issue Feb 7, 2020 · 1 comment

Comments

@ErezBinyamin
Copy link

Not an urgent issue, but something that seems like it may be an easy fix.

Source Code:

const gal8 min_poly  = 0b11101,     // Minimal polynomial x^8 + x^4 + x^3 + x^2 + 1
generator = 0b10;        // Generator of Galois field

movcc output:

galois.c:14:    `0b11101' is a preprocessing number but an invalid integer constant
galois.c:15:    `0b10' is a preprocessing number but an invalid integer constant

I'm just a cryptography student trying to obfuscate my algorithms for a ctf I'm working on. The problem is easily fixed when I make the change to decimal representation, but... it'd be nice to have more readable source code that is compatible with movcc.

working source:

const gal8 min_poly  = 39,     // Minimal polynomial x^8 + x^4 + x^3 + x^2 + 1
          generator = 2;        // Generator of Galois field

I have never contributed to a github project before, but I would be happy to take a look at the source, attempt an edit, and submit a pull request if you do that sort of thing..

@raenye
Copy link

raenye commented Nov 22, 2021

The front end lcc follows ANSI C, whereas binary constants (0b prefix) are non-standard and certainly not ANSI.
These will become part of the C standard only in C23; meanwhile they only exist as extensions in gcc or llvm.

Further information: https://en.cppreference.com/w/c/language/integer_constant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants