flat assembler
Message board for the users of flat assembler.
Index
> Main > how to load unsigned integer into fpu? Goto page 1, 2 Next |
Author |
|
asmcoder 21 Dec 2008, 18:06
[content deleted]
Last edited by asmcoder on 14 Aug 2009, 14:54; edited 1 time in total |
|||
21 Dec 2008, 18:06 |
|
LocoDelAssembly 21 Dec 2008, 18:13
Quote:
On FPU it is! |
|||
21 Dec 2008, 18:13 |
|
jack2 21 Dec 2008, 18:38
I found this snippet on the web
Code: ;esp points to unsigned int64 fild qword ptr [esp] test byte ptr [esp+7], 80h jz _ret fadd dword __pow_2_64 _ret: ret __pow_2_64: db 0, 0, 0x80, 0x5F any better way? too bad there's no fuild |
|||
21 Dec 2008, 18:38 |
|
revolution 21 Dec 2008, 23:28
There is no other way. What you found "on the web" is as good as it gets.
|
|||
21 Dec 2008, 23:28 |
|
bitRAKE 22 Dec 2008, 00:49
Ah, the decadence - to branch senselessly...
Code: push $3FFF + 63 push -1 fld tbyte [rsp] Code: push $3FFF + 63 push -1 push -1 fld tbyte [esp] (need to correct the stack of course) |
|||
22 Dec 2008, 00:49 |
|
revolution 22 Dec 2008, 00:52
Hardly the same thing! You are pushing a fixed value.
|
|||
22 Dec 2008, 00:52 |
|
bitRAKE 22 Dec 2008, 00:55
Whatever, PUSH works with memory and registers, too - silly.
|
|||
22 Dec 2008, 00:55 |
|
revolution 22 Dec 2008, 00:56
Not if the value is below 2^63.
|
|||
22 Dec 2008, 00:56 |
|
bitRAKE 22 Dec 2008, 00:58
Your processor must work differently than mine.
(See Vol.1 8-19, Figure 8-13) |
|||
22 Dec 2008, 00:58 |
|
revolution 22 Dec 2008, 01:02
You need to properly shift the mantissa and adjust the exponent if the number is does not have the high most bit set. Else you get a malformed float.
|
|||
22 Dec 2008, 01:02 |
|
revolution 22 Dec 2008, 01:03
If you want to quote Intel manuals then look two pages further in at table 8-3. You get an unnormal for values <2^63
|
|||
22 Dec 2008, 01:03 |
|
bitRAKE 22 Dec 2008, 01:11
So, it doesn't work on your processor?
|
|||
22 Dec 2008, 01:11 |
|
revolution 22 Dec 2008, 01:14
Your code above will work because it is a fixed value (2^64-1). But for the general case it will produce unsupported FPU values for numbers < 2^63.
|
|||
22 Dec 2008, 01:14 |
|
bitRAKE 22 Dec 2008, 01:15
Yet, it works on your processor.
|
|||
22 Dec 2008, 01:15 |
|
revolution 22 Dec 2008, 01:17
What is it? The general case or the fixed value?
|
|||
22 Dec 2008, 01:17 |
|
bitRAKE 22 Dec 2008, 01:19
The general case works.
|
|||
22 Dec 2008, 01:19 |
|
bitRAKE 22 Dec 2008, 01:20
Okay, it just appears to work.
|
|||
22 Dec 2008, 01:20 |
|
revolution 22 Dec 2008, 01:21
Are you sure it works on all CPUs? Have you tested AMD, Intel, Via, Cyrix, Harris, etc.?
|
|||
22 Dec 2008, 01:21 |
|
revolution 22 Dec 2008, 01:32
Very well, I tested it. CPU: Intel Pentium M.
Code: include 'win32ax.inc' start: push $3FFF + 63 push -1 push -1 fld tbyte [esp] push $3FFF + 63 push (1 shl 31)-1 push -1 fld tbyte [esp] fadd st0,st1 ;<---- gives an invalid FPU operation exception (I) .end start |
|||
22 Dec 2008, 01:32 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.