nasm infinite loop with FPU
Posted
by
Ben Ishak
on Stack Overflow
See other posts from Stack Overflow
or by Ben Ishak
Published on 2013-06-25T22:19:39Z
Indexed on
2013/06/25
22:21 UTC
Read the original article
Hit count: 262
i'm trying to create a small nasm program which do this operation in floating point
while(input <= 10^5) do
begin
input = input * 10
i = i - 1
end
the equivilant program in nasm is as following
section .data
input: resd 1
n10: dd 0x41200000 ; 10
_start:
mov eax, 200 ; eax = 200
; extract eax -> Floating Point IEEE 754
and eax, 0x7f800000
shr eax, 23
sub eax, 127
mov dword [input], eax ; input = eax = 200
mov edx, 0x49742400 ; 10^5
; %begin
mov ecx, 0 ; i = 0
jmp alpha
alpha:
fld dword [input]
cmp [input], edx ; input <= 10^5
jle _while
jmp log2
_while:
fld dword [n10] ; 10
fld dword [input] ; input
fmul st0, st1 ; input * 10
fst dword [input] ; input = input
dec ecx ; i = i - 1
jmp alpha
the _while
loop is iterating infinitely
ecx / i
gards always the same value = -4194304
(it is sepposed to be 0) and doesn't decrement
© Stack Overflow or respective owner