Demo contest?

Member
Posts: 567
Joined: 2004.07
Post: #1
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?

It's not magic, it's Ruby.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
How about a UB in less than 24KiB, uncompressed Rasp
Quote this message in a reply
Moderator
Posts: 679
Joined: 2002.11
Post: #3
OneSadCookie Wrote:How about a UB in less than 24KiB, uncompressed Rasp

*commits seppuku*

My web site - Games, music, Python stuff
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #4
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?

It's not magic, it's Ruby.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
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...
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
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
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #7
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.

It's not magic, it's Ruby.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
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.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #9
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.

It's not magic, it's Ruby.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
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
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #11
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...

It's not magic, it's Ruby.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #12

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #13
Awesome, unknown. But it's 3.1MB, that's not < 24KiB Wink
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #14
Oooh. Lisajous curves. I threw something together a couple of weeks ago using some of those.

Lissajous worms

Not really a demo, but hey.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #15
Nice stuff Fax Smile

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Post Reply