**What is the error here?**

segment .data percent dd 100 num_interations dd 30 num_eflags_zeros dd 0 num_eflags_ones dd 0 iteration_num db 0 segment .text global manipulate_zf manipulate_zf: cmp byte [iteration_num], 0 jnz skip_basic finit ; initialize fpu fild dword [esp+4] ; load probability on the fpu stack st0 fidiv dword [percent] ; divide probability by 100 and store it in st0 fimul dword [num_interations] ; multiply (probability/100) * 30 and store it in st0. fist dword [num_eflags_zeros] ; Round this number , convert it to an integer and save it in memory. mov eax, [num_interations] ; eax = 30 sub eax, [num_eflags_zeros] ; eax = 30 - num_eflags_zeros ie; eax = num_times eflags.zf = 1 mov [num_eflags_ones], eax mov byte [iteration_num], 1 skip_basic: pushfd zf_0: cmp dword [num_eflags_zeros], 0 jz zf_1 and dword [esp], 0 dec dword [num_eflags_zeros] mov eax, 0 jmp done zf_1: cmp dword [num_eflags_ones], 0 jz done or dword [esp], 0x40 dec dword [num_eflags_ones] mov eax, 1 done: popfd ret ; return to the calling C procedure

MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

And moved to the Assembly forum.