iDevGames Forums
Demo contest? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Community Zone (/forum-4.html)
+--- Forum: Contests (/forum-19.html)
+--- Thread: Demo contest? (/thread-2988.html)

Pages: 1 2


Demo contest? - Duane - Oct 17, 2007 05:36 PM

Anyone up for a demo contest? Just create something really visually appealing.


But wait, there's more! Let's have a size restriction, just for the heck of it, and make it something that's really restrictive. Anyone up for it?


Demo contest? - OneSadCookie - Oct 17, 2007 06:57 PM

How about a UB in less than 24KiB, uncompressed Rasp


Demo contest? - stevejohnson - Oct 17, 2007 09:33 PM

OneSadCookie Wrote:How about a UB in less than 24KiB, uncompressed Rasp

*commits seppuku*


Demo contest? - Duane - Oct 18, 2007 04:42 PM

well hell, I know I'm entering a text app, so I'm not even linking to anything I don't think.

Ok, how about we have a size limit OVER the universal binary base?


Demo contest? - OneSadCookie - Oct 18, 2007 05:22 PM

I believe that the 24KiB UB binary is achievable, but my ASM-fu is weak and has so far thwarted my attempts so far to get there...


Demo contest? - OneSadCookie - Oct 18, 2007 07:09 PM

OK, I've done it, even if I don't understand why the x86 half has to look like this...

hello.x86.s:
Code:
.cstring
L_HELLO:
    .ascii "Hello, world!\n\0"


    .text
.globl start
start:
    pushl $14
    pushl $L_HELLO
    pushl $1
    movl $4, %eax
    call L_syscall
    addl $12, %esp
    pushl $0
    movl $1, %eax
    call L_syscall

L_syscall:
    int $0x80
    ret

hello.ppc.s:
Code:
.cstring
L_HELLO:
    .ascii "Hello, world!\n\0"
    
    
    .text
.globl start
start:
    li r0, 4
    li r3, 1
    lis r4, ha16(L_HELLO)
    addi r4, r4, lo16(L_HELLO)
    li r5, 14
    sc
    li r3, 0
    li r0, 1
    sc

to build:
Code:
as -arch ppc hello.ppc.s -o hello.ppc.o
as -arch i386 hello.x86.s -o hello.x86.o
ld -arch ppc hello.ppc.o -o a.out.ppc
ld -arch i386 hello.x86.o -o a.out.x86
lipo a.out.ppc a.out.x86 -create -output a.out

The results:
Code:
CookieJar:Desktop keith$ ls -l a.out*
-rwxr-xr-x  1 keith  staff  16436 19 Oct 14:57 a.out
-rwxr-xr-x  1 keith  staff   4148 19 Oct 14:57 a.out.ppc
-rwxr-xr-x  1 keith  staff   4148 19 Oct 14:57 a.out.x86
CookieJar:Desktop keith$ ./a.out
Hello, world!
CookieJar:Desktop keith$ /usr/libexec/oah/translate a.out
Hello, world!

Most of the executables is zeroes (for padding) so they compress really well:
Code:
CookieJar:Desktop keith$ gzip a.out*
CookieJar:Desktop keith$ ls -l *.gz
-rwxr-xr-x  1 keith  staff  544 19 Oct 14:57 a.out.gz
-rwxr-xr-x  1 keith  staff  324 19 Oct 14:57 a.out.ppc.gz
-rwxr-xr-x  1 keith  staff  328 19 Oct 14:57 a.out.x86.gz



Demo contest? - Duane - Oct 19, 2007 03:40 PM

yea, I easily got a universal, nonlinked 4120 byte file.

By the way, I believe that if you compile and run the ppc version, you'll find it's returning 4 and NOT 1.

I think I can use c, but the inline assembly doesn't work correctly (for ppc); it complains of an undefined r2 when I attempt to reference c symbols from the assembly blocks.


Demo contest? - OneSadCookie - Oct 20, 2007 01:44 AM

Nayr Wrote:yea, I easily got a universal, nonlinked 4120 byte file.

Don't know what you mean by that. If you mean your .o file was that large, that's completely not the point; it's the linking step that adds the bloat. Coincidentally, my nonuniversal apps are 4120 bytes on Tiger.

Quote:By the way, I believe that if you compile and run the ppc version, you'll find it's returning 4 and NOT 1.

Don't know what you mean by that... it should exit with status 0. Unfortunately for me, on Tiger, it crashes when run in Rosetta. Don't know what's up with that.

Quote:I think I can use c, but the inline assembly doesn't work correctly (for ppc); it complains of an undefined r2 when I attempt to reference c symbols from the assembly blocks.

Well, I don't know what that issue would be... AFAIK, inline assembly works fine for plenty of people... but if you can convince GCC to produce a universal binary below 28KB you're doing better than I did.


Demo contest? - Duane - Oct 20, 2007 02:15 PM

excuse me, I meant a 4120 universal binary.

And, on ppc at the very least, the next instruction after a 'sc' is ignored; usually you use a 'nop,' but you could use any instruction if you truly want to confuse the reader of your code.


Demo contest? - OneSadCookie - Oct 20, 2007 02:27 PM

Nayr Wrote:excuse me, I meant a 4120 universal binary.

Given that the single-architecture executables are 4120 bytes each, I don't believe you Rasp

Quote:And, on ppc at the very least, the next instruction after a 'sc' is ignored; usually you use a 'nop,' but you could use any instruction if you truly want to confuse the reader of your code.

Ah, that explains that. I guess Rosetta on Leopard is buggy Rasp


Demo contest? - Duane - Oct 20, 2007 03:55 PM

Heh, this is my first time creating a universal binary, and I misused lipo. (I created a universal object file, but for some reason it only linked the ppc file :/)

the universal is now 16408 bytes... Why does it quadruple in size? surely it still uses two segments, making it 8192 bytes plus some...


Demo contest? - unknown - Oct 21, 2007 12:53 AM

http://fax.twilightcoders.net/files/blinkenlights.zip

great fun! ;D


Demo contest? - OneSadCookie - Oct 21, 2007 01:46 AM

Awesome, unknown. But it's 3.1MB, that's not < 24KiB Wink


Demo contest? - Skorche - Oct 21, 2007 10:59 AM

Oooh. Lisajous curves. I threw something together a couple of weeks ago using some of those.

Lissajous worms

Not really a demo, but hey.


Demo contest? - Najdorf - Oct 21, 2007 11:07 AM

Nice stuff Fax Smile