Skip to content

Instantly share code, notes, and snippets.

@boki
Created February 17, 2011 14:05
Show Gist options
  • Select an option

  • Save boki/831772 to your computer and use it in GitHub Desktop.

Select an option

Save boki/831772 to your computer and use it in GitHub Desktop.

Revisions

  1. boki revised this gist Feb 17, 2011. 1 changed file with 58 additions and 0 deletions.
    58 changes: 58 additions & 0 deletions VC2010 f != f + 1, part II
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    ;
    ; cl.exe /Od (no optimization)
    ;

    ; float f = 0;
    fldz
    fstp DWORD PTR _f$[ebp]
    $LN2@wmain:
    ; while (f != f + 1) {
    fld DWORD PTR _f$[ebp]
    fadd QWORD PTR __real@3ff0000000000000
    fld DWORD PTR _f$[ebp]
    fucompp
    fnstsw ax
    test ah, 68 ; 00000044H
    jnp SHORT $LN1@wmain
    ; f += 1;
    fld DWORD PTR _f$[ebp]
    fadd QWORD PTR __real@3ff0000000000000
    fstp DWORD PTR _f$[ebp]
    ; }
    jmp SHORT $LN2@wmain
    $LN1@wmain:


    ;
    ; cl.exe /Ox (maximum optimization)
    ;

    ; float f = 0;
    fldz
    fstp DWORD PTR _f$[esp+4]
    ; while (f != f + 1) {
    fldz
    fld ST(0)
    fld1
    fadd ST(1), ST(0)
    fld ST(1)
    fucomp ST(3)
    fnstsw ax
    fstp ST(2)
    test ah, 68 ; 00000044H
    jnp SHORT $LN9@wmain
    $LN2@wmain:
    ; f += 1;
    fstp DWORD PTR _f$[esp+4]
    fld DWORD PTR _f$[esp+4]
    fld ST(0)
    fadd ST(0), ST(2)
    fld ST(0)
    fucomp ST(2)
    fnstsw ax
    fstp ST(1)
    test ah, 68 ; 00000044H
    jp SHORT $LN2@wmain
    $LN9@wmain:
    ; while (f != f + 1) {
    fstp ST(0)
  2. boki revised this gist Feb 17, 2011. 1 changed file with 0 additions and 19 deletions.
    19 changes: 0 additions & 19 deletions VC2010 f != f + 1
    Original file line number Diff line number Diff line change
    @@ -1,19 +0,0 @@
    ; float f = 0;
    fldz
    fstp DWORD PTR _f$[ebp]
    $LN2@wmain:
    ; while (f != f + 1) {
    fld DWORD PTR _f$[ebp]
    fadd QWORD PTR __real@3ff0000000000000
    fld DWORD PTR _f$[ebp]
    fucompp
    fnstsw ax
    test ah, 68 ; 00000044H
    jnp SHORT $LN1@wmain
    ; f += 1;
    fld DWORD PTR _f$[ebp]
    fadd QWORD PTR __real@3ff0000000000000
    fstp DWORD PTR _f$[ebp]
    ; }
    jmp SHORT $LN2@wmain
    $LN1@wmain:
  3. boki created this gist Feb 17, 2011.
    19 changes: 19 additions & 0 deletions VC2010 f != f + 1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    ; float f = 0;
    fldz
    fstp DWORD PTR _f$[ebp]
    $LN2@wmain:
    ; while (f != f + 1) {
    fld DWORD PTR _f$[ebp]
    fadd QWORD PTR __real@3ff0000000000000
    fld DWORD PTR _f$[ebp]
    fucompp
    fnstsw ax
    test ah, 68 ; 00000044H
    jnp SHORT $LN1@wmain
    ; f += 1;
    fld DWORD PTR _f$[ebp]
    fadd QWORD PTR __real@3ff0000000000000
    fstp DWORD PTR _f$[ebp]
    ; }
    jmp SHORT $LN2@wmain
    $LN1@wmain: