xoreaxeaxeax / movfuscator

The single instruction C compiler
Other
9.29k stars 394 forks source link

Binary representation of constants is unsupported: 0b10101 #36

Open ErezBinyamin opened 4 years ago

ErezBinyamin commented 4 years ago

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 commented 2 years ago

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