flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
Ali.Z 01 Jun 2022, 23:47
Ali.Z wrote:
nvm, I should have defined it as dq so fasm treats it as a dp-fp value. _________________ Asm For Wise Humans |
|||
![]() |
|
revolution 02 Jun 2022, 01:48
Code: mov eax,3.1415926 ; always SP for 32-bit destinations mov rax,3.14159265358979323 ; always DP for 64-bit destinations dt 3.1415926535897932384626 ; always EP for 80-bit destinations |
|||
![]() |
|
Ali.Z 02 Jun 2022, 09:24
thanks, also its good to know that fasm supports ep-fp values.
_________________ Asm For Wise Humans |
|||
![]() |
|
AsmGuru62 02 Jun 2022, 22:53
push 45.887 -- works in 32-bit code, but fails in 64-bit code.
Anyone knows how to solve it? |
|||
![]() |
|
macomics 02 Jun 2022, 23:51
Code: .value = dword 45.887 push .value ; single precision Code: macro fpush val { local .value .value = dword v push .value } fpush 45.887 ; single precision Code: mov rax, 45.887 push rax ; double precision |
|||
![]() |
|
AsmGuru62 03 Jun 2022, 20:37
Not bad. Thanks.
|
|||
![]() |
|
revolution 03 Jun 2022, 20:46
Code: .value = dword -45.887 push .value ; single precision Code: push .value ; single precision processed: push .value error: value out of range. |
|||
![]() |
|
revolution 03 Jun 2022, 20:53
Or an alternative is this:
Code: use32 push -45.887 push 45.887 use64 |
|||
![]() |
|
macomics 03 Jun 2022, 23:34
revolution wrote: Or an alternative is this: Code: virtual dd -45.887 load dword .value at $ - 4 end virtual push .value revolution wrote:
Code: use32 push 45.887 ; 68 4A 8C 37 42 push -45.887 ; 68 4A 8C 37 C2 use64 |
|||
![]() |
|
revolution 04 Jun 2022, 03:48
You can only push immediate values in the range 0xffffffff80000000 to 0x000000007fffffff.
So 0x00000000c2378c4a is out of range. Just as fasm says. In 32-bit mode the encoding is exactly the same, and all 32-bit values can be pushed, but it ignores the implicit sign extension. So when you pop it later it gives 0xffffffffc2378c4a which isn't the value pushed, but the lower 32-bits are the same. |
|||
![]() |
|
macomics 04 Jun 2022, 09:14
So I say it's a bug. A real number (always signed) is converted to an unsigned bit sequence. Intel just didn't give a damn about it and general-purpose registers don't care about it.
Code: macro fpush value { local .value .value = dword value push .value or (( -1 * ( .value shr 31 ) shl 32 ) } |
|||
![]() |
|
revolution 04 Jun 2022, 09:50
It would be not good if this were to happen.
Code: push 0x00000000ffffffff pop rax ; rax = 0xffffffffffffffff |
|||
![]() |
|
macomics 04 Jun 2022, 10:05
revolution wrote: It would be not good if this were to happen. Intel has reached the point where even addresses began to be counted in the additional code of integers. |
|||
![]() |
|
revolution 04 Jun 2022, 11:13
The CPU can't know if your constant is real or int. It is all just bits to the CPU.
So it would be very wrong for the CPU change the data to something else. If you allow that, you get this also. Code: push 0x00000000ffffffff pop rax ; rax = 0xffffffffffffffff push 0xffffffffffffffff pop rax ; rax = 0xffffffffffffffff |
|||
![]() |
|
macomics 04 Jun 2022, 11:52
I'm not talking about the CPU. This fasm1 loses the sign in their bit sequence when translating real numbers. And controlling the length and the immediate value is already the task of the programmer.
Code: push 0x00000000ffffffff ; error (unsigned, out of range -0x80000000 .. 0x7FFFFFFF) push 0xffffffffffffffff ; it is possible to issue a warning about the implicit conversion of a bit into a sign or error (unsigned, out of range -0x80000000 .. 0x7FFFFFFF) push 0x80000000 ; error (unsigned, out of range -0x80000000 .. 0x7FFFFFFF) push -0x80000000 ; [rsp] = 0xFFFFFFFF80000000 push -1 ; [rsp] = 0xFFFFFFFFFFFFFFFF push -45.887 ; [rsp] = 0xFFFFFFFFC2378C4A push 45.887 ; [rsp] = 0x0000000042378C4A |
|||
![]() |
|
revolution 04 Jun 2022, 12:07
-45.887 is not 0xFFFFFFFFC2378C4A
It also is not 0xFF...FFC2378C4A for any number of leading F's except zero. That is a different value. |
|||
![]() |
|
macomics 04 Jun 2022, 12:44
revolution wrote: That is a different value. The same thing happens if you write like this Code: mov eax, -45.887 ; rax = 0xFFFFFFFFC2378C4A |
|||
![]() |
|
revolution 04 Jun 2022, 12:46
macomics wrote:
Code: mov eax, -45.887 ; rax = 0x00000000C2378C4A All 32-bit writes are zero extended. |
|||
![]() |
|
macomics 04 Jun 2022, 12:53
Quote: REX.W + C7 /0 id MOV r/m64, imm32 MI Move imm32 sign extended to 64-bits to r/m64. |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.