News for hackers. Stuff that matters.
Re:Main is usually a function, so when is it not? (2015) by _kst_ on Monday June 14, 2021 @02:55PM (#27506678)
One of the winners of the 1st International Obfuscated C Code Contest (1984) used this technique.

https://www.ioccc.org/1984/mullender/mullender.c

https://www.ioccc.org/1984/mullender/hint.text

    short main[] = {
            277, 04735, -4129, 25, 0, 477, 1019, 0xbef, 0, 12800,
            -113, 21119, 0x52d7, -1006, -7151, 0, 0x4bc, 020004,
            14880, 10541, 2056, 04010, 4548, 3044, -6716, 0x9,
            4407, 6, 5568, 1, -30460, 0, 0x9, 5570, 512, -30419,
            0x7e82, 0760, 6, 0, 4, 02400, 15, 0, 4, 1280, 4, 0,
            4, 0, 0, 0, 0x8, 0, 4, 0, ',', 0, 12, 0, 4, 0, '#',
            0, 020, 0, 4, 0, 30, 0, 026, 0, 0x6176, 120, 25712,
            'p', 072163, 'r', 29303, 29801, 'e'
    };
Re:Main is usually a function, so when is it not? (2015) by alin23 on Monday June 14, 2021 @02:58PM (#27506705)
That’s already mentioned in the third paragraph but it’s nice of you to also include the bytecode in the comment.

> Apparently in 1984, a strange program won the IOCCC where main was declared as a short main[] = {...} and somehow this did stuff and printed to the screen!

Re:Main is usually a function, so when is it not? (2015) by ianhanschen on Monday June 14, 2021 @03:23PM (#27507030)
Barely mentioned, and the author makes us all die inside when they say "Too bad it was written for a whole different architecture and compiler so there is really no easy way for me to find out what it did."
Re:Main is usually a function, so when is it not? (2015) by _kst_ on Monday June 14, 2021 @04:32PM (#27507915)
As the hint explains, it's a combination of PDP-11 and VAX machine code, set up so that either system will run its own code and ignore the foreign code.

You can extract a few ASCII strings from the data. As the hint says: "Can you guess what is printed? We knew you couldn't! :-)"

The ASCII strings I found were "vax", "pdp", "str", "write", and " :-)".

Re:Main is usually a function, so when is it not? (2015) by cptnapalm on Monday June 14, 2021 @10:13PM (#27510569)
So not only did they write something baffling, they also wrote it so that it was semi-portable.
Re:Main is usually a function, so when is it not? (2015) by andrewmcwatters on Monday June 14, 2021 @07:22PM (#27509636)
I wonder what strange and interesting things in the computing world we’ve simply lost by forgetting and from moving on.