The Dink Network

Reply to Re: Decompilers needed

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
April 10th 2008, 02:28 AM
wizardb.gif
Phoenix
Peasant He/Him Norway
Back from the ashes 
Because I am a geek, hur, I just checked this. (Why not get the facts on the table?

These are the two files I used to test:

===== wh.c =====
void loop(void) {
int i = 0;
while(1)
i++;
}

===== fl.c =====
void loop(void) {
int i = 0;
for( ;; )
i++;
}

I "compiled" both to assembler using the command "gcc -O0 -S <file>.c", which gave me these two files: (I've removed unnecessary, unrelated crud)

===== wh.s =====
loop:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $0, -8(%ebp)
.L2:
movl $0, -4(%ebp)
movl -8(%ebp), %eax
addl %eax, %eax
addl %eax, -4(%ebp)
jmp .L2

===== fl.s =====
loop:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $0, -8(%ebp)
.L2:
movl $0, -4(%ebp)
movl -8(%ebp), %eax
addl %eax, %eax
addl %eax, -4(%ebp)
jmp .L2

If you see any difference between the two outputs, then congratulations. You see something I don't. So, to all of you discussing this, it's settled. They both result in the exact same code, case closed, it's entirely up to personal preference.