Skip to content

Instantly share code, notes, and snippets.

@boki
Created February 17, 2011 14:05
Show Gist options
  • Save boki/831772 to your computer and use it in GitHub Desktop.
Save boki/831772 to your computer and use it in GitHub Desktop.
The generated asm for float f = 0; while (f != f + 1) { f += 1; }
;
; 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment