here is the assember source
public funct
.code
funct PROC
push rbp
mov rbp, rsp ; Setup stack frame
; RSP aligned to 16 bytes at this point
push rbx
mov [rbp+16],rcx ; 32 byte shadow space is just above the return address
; at RBP+16 (this address is 16 byte aligned). Rather
; than use a temporary variable in the data section to
; store the value of RCX, we just store it to the
; shadow space on the stack.
fild QWORD ptr[rbp+16] ; Load and convert 64-bit integer into st(0)
fldpi ; st(0) => st(1), st(0) = pi
fmulp ; st(1)=st(1)*st(0), st(1) => st(0)
fstp REAL4 ptr [rbp+16] ; Store result to shadow space as 32-bit float
movss xmm0, REAL4 ptr [rbp+16] ; Store single scalar (32-bit float) to xmm0
; XMM0 = return value for 32(and 64-bit) floats
; in 64-bit code.
pop rbx
mov rsp, rbp ; Remove stack frame
pop rbp
ret
funct ENDP
END
and here what ml64 generates with ml64 /Fl /Sa mod.asm:
Microsoft (R) Macro Assembler (AMD64) Version 8.00.40310.39 08/20/17 09:53:34
mod.asm Page 1 - 1
public funct
00000000 .code
00000000 funct PROC
00000000 55 push rbp
00000001 48/ 8B EC mov rbp, rsp ; Setup stack frame
; RSP aligned to 16 bytes at this point
00000004 53 push rbx
00000005 48/ 89 4D 10 mov [rbp+16],rcx ; 32 byte shadow space is just above the return address
; at RBP+16 (this address is 16 byte aligned). Rather
; than use a temporary variable in the data section to
; store the value of RCX, we just store it to the
; shadow space on the stack.
fild QWORD ptr[rbp+16] ; Load and convert 64-bit integer into st(0)
mod.asm(17) : error A2222: x87 and MMX instructions disallowed; legacy FP state not saved in Win64
fldpi ; st(0) => st(1), st(0) = pi, 3.14159...
mod.asm(18) : error A2222: x87 and MMX instructions disallowed; legacy FP state not saved in Win64
fmulp ; st(1)=st(1)*st(0), st(1) => st(0)
mod.asm(19) : error A2222: x87 and MMX instructions disallowed; legacy FP state not saved in Win64
fstp REAL4 ptr [rbp+16] ; Store result to shadow space as 32-bit float
mod.asm(20) : error A2222: x87 and MMX instructions disallowed; legacy FP state not saved in Win64
00000009 F3/ 0F 10 45 movss xmm0, REAL4 ptr [rbp+16] ; Store single scalar (32-bit float) to xmm0
10
; XMM0 = return value for 32(and 64-bit) floats
; in 64-bit code.
0000000E 5B pop rbx
0000000F 48/ 8B E5 mov rsp, rbp ; Remove stack frame
00000012 5D pop rbp
00000013 C3 ret
00000014 funct ENDP
END
Microsoft (R) Macro Assembler (AMD64) Version 8.00.40310.39 08/20/17 09:53:34
mod.asm Symbols 2 - 1
Procedures, parameters, and locals:
N a m e Type Value Attr
funct . . . . . . . . . . . . . P 00000000 _TEXT Length= 00000014 Public
0 Warnings
4 Errors
please can someone tell me how I can use x87 floating point in 64-bit mode
(this is just an example, I have some sophisticated calculations in assembly,
which I want to move to 64-bit)
Thanks,
Walter