lol wtf TETRIS!!!

Developer discussion of experimental fixes, changes, and improvements.

Moderators: Nexuiz Moderators, Moderators

Postby Alien » Mon Aug 10, 2009 2:32 pm

Why should it generate entirely different machine code?
Alien
Forum addon
 
Posts: 1212
Joined: Tue Apr 22, 2008 7:12 am

Postby Mizu Kitsune » Mon Aug 10, 2009 4:11 pm

compilers for any language (including Assembly) handle "else" and "else if" differently when compiling.
+The Dude+
[-Project 2501-]
Mizu Kitsune
Alien trapper
 
Posts: 362
Joined: Sat Apr 11, 2009 7:51 pm
Location: Maridia

Postby Alien » Mon Aug 10, 2009 5:32 pm

This is not a question of else if {} and else {} but between else if {} and else { if {}}
Alien
Forum addon
 
Posts: 1212
Joined: Tue Apr 22, 2008 7:12 am

Postby mand1nga » Tue Aug 11, 2009 1:04 am

best thread ever
mand1nga
Alien trapper
 
Posts: 321
Joined: Mon May 12, 2008 12:19 am

Postby Mizu Kitsune » Tue Aug 11, 2009 4:31 am

Alien wrote:This is not a question of else if {} and else {} but between else if {} and else { if {}}

what i just explained. else if {} is handled differently than else { if {}} is when compiled.

[quote=mand1nga]best thread ver[/quote]
^_^
+The Dude+
[-Project 2501-]
Mizu Kitsune
Alien trapper
 
Posts: 362
Joined: Sat Apr 11, 2009 7:51 pm
Location: Maridia

Postby Alien » Tue Aug 11, 2009 7:15 am

Really?
Code: Select all
>more else1.c
int main(void)
{
    if (1) {}
    else
    {
        if (1) {}
    }
    return 0;
}

>more else2.c
int main(void)
{
    if (1) {}
    else
        if (1) {}

    return 0;
}

>icl else1.c
-out:else1.exe
else1.obj

>icl else2.c
-out:else2.exe
else2.obj

>fc else1.exe else2.exe
Comparing files else1.exe and ELSE2.EXE
000000E8: [color=red]9F A2[/color]

>pedump else1.exe
Dump of file ELSE1.EXE

File Header
  Machine:                      014C (i386)
  Number of Sections:           0003
  TimeDateStamp:                4A8117[color=red]9F[/color] -> Tue Aug 11 10:02:55 2009
  PointerToSymbolTable:         00000000
  NumberOfSymbols:              00000000
  SizeOfOptionalHeader:         00E0
  Characteristics:              0103
    RELOCS_STRIPPED
    EXECUTABLE_IMAGE
    32BIT_MACHINE
  .
  .
  .

>pedump else2.exe
Dump of file ELSE2.EXE

File Header
  Machine:                      014C (i386)
  Number of Sections:           0003
  TimeDateStamp:                4A8117[color=red]A2[/color] -> Tue Aug 11 10:02:58 2009
  PointerToSymbolTable:         00000000
  NumberOfSymbols:              00000000
  SizeOfOptionalHeader:         00E0
  Characteristics:              0103
    RELOCS_STRIPPED
    EXECUTABLE_IMAGE
    32BIT_MACHINE
  .
  .
  .


TimeDateStamp: 4A81179F -> Tue Aug 11 10:02:55 2009
TimeDateStamp: 4A8117A2 -> Tue Aug 11 10:02:58 2009
Alien
Forum addon
 
Posts: 1212
Joined: Tue Apr 22, 2008 7:12 am

Postby morfar » Tue Aug 11, 2009 7:44 am

Nexuiz is written in qc. And I heard there are several bugs in the compiler.
So there might indeed be a difference in machine code.

@Alien: Why did you write else and if on different lines? Should it not be "else if" on 1 line?
morfar
Site Admin
 
Posts: 938
Joined: Tue Feb 28, 2006 6:08 pm
Location: The Island

Postby ai » Tue Aug 11, 2009 10:00 am

Ixion wrote:@Alien: Why did you write else and if on different lines? Should it not be "else if" on 1 line?

There are several if statements.

1.
Code: Select all
if (bla)
{
blu;
}
return 0;


2.
Code: Select all
if (bla)
{
blu;
}
else
{
blo;
}
return 0;


3.
Code: Select all
if (bla)
{
  blu;
}
else if
{
  blo;
}
else
{
ble;
}
return 0;


Got your memory back? I know you know this.
ai
Forum addon
 
Posts: 2131
Joined: Sun Mar 05, 2006 3:54 pm
Location: Behind you

Postby Alien » Tue Aug 11, 2009 11:55 am

Code: Select all
else3.c:

int main(void)
{
    if (1) {}
    else

         ;;;;;;  {}
        ;;  ;;;; {}
             ;;; {}
            ;;;  {}
           ;;    {}
           ;;    {}

           ;;    {}


        if (1) {}

    return 0;
}



else4.c:

int main(void)
{
    if (1) {}
    else if (1) {}

    return 0;
}

>fc else3.exe else4.exe
Comparing files else3.exe and ELSE4.EXE
000000E8: 99 94


Basically, punctuation marks are read and used only by lexical analysis tool which is usually part of compiler suite.

Image
Alien
Forum addon
 
Posts: 1212
Joined: Tue Apr 22, 2008 7:12 am

Postby ai » Tue Aug 11, 2009 3:25 pm

My explanation is a lot easier to understand. Only a programming guru or system analyzer would understand what you just said, and understand the diagram you posted, and if you are a programmer or system analyzer you'd probably already know how if, else works. :P
ai
Forum addon
 
Posts: 2131
Joined: Sun Mar 05, 2006 3:54 pm
Location: Behind you

PreviousNext

Return to Nexuiz - Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron