News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Re: Latest build environment for ML64.

Started by hutch--, September 25, 2016, 04:09:15 PM

Previous topic - Next topic

hutch--

Not sure what you are after Alex, if you know the name of the function, you could look it up on MSDN. Tell us a bit more of what you are after and we may be able to help you.

rrr314159

There aren't any FPU functions in the API, I believe. Even in previous Windows there weren't, but at least some of them used FPU. Today it's been replaced by SSE for "official" Windows floating point. Maybe you're thinking of Raymond's FPU functions?
I am NaN ;)

MichaelW

The CRT contains FPU functions, very well developed and reliable.
Well Microsoft, here's another nice mess you've gotten us into.

Gunther

Quote from: MichaelW on September 28, 2016, 06:36:25 AM
The CRT contains FPU functions, very well developed and reliable.

That's right and it has good reasons. In some cases one should use the good old FPU, if accuracy is required.

Gunther
You have to know the facts before you can distort them.

Alex81524

Hi! I'm interested in the analogue of the function FpuFLToA for output using MessageBox. My website http://blogs.kpi.kharkov.ua/v2/asm/lektsii-sp/

rrr314159

Quote from: MichaelW on September 28, 2016, 06:36:25 AM
The CRT contains FPU functions, very well developed and reliable.

Well you live and learn. I wonder what they're for? I always use fpu instructions directly. Since we usually want max speed it seems counter-productive to use a Windows function instead.

[EDIT] come to think of it perhaps you mean the floating point conversion functions. I was thinking of functions like fadd - actual fpu instructions.
I am NaN ;)

jj2007

Quote from: Alex81524 on September 29, 2016, 03:10:34 AM
Hi! I'm interested in the analogue of the function FpuFLToA for output using MessageBox. My website http://blogs.kpi.kharkov.ua/v2/asm/lektsii-sp/

There are several ways of printing a REAL10 in 32-bit Masm, but beware of precision problems.

include \masm32\MasmBasic\MasmBasic.inc      ; download
include \Masm32\fpulib\Fpu.inc
includelib \Masm32\fpulib\Fpu.lib

.data?
MyR8      REAL8 ?
MyR10     REAL10 ?
buffer    db 20 dup(?)

  Init
  fldpi
  PrintLine Str$("MBasic\tPI= %Jf", ST(0))
  Print cfm$("FpuFLto\tPI=")
  invoke FpuFLtoA, 0, 19, offset buffer, SRC1_FPU or SRC2_DIMM or STR_REG
  PrintLine offset buffer
  fst MyR8
  printf("CRT\tPI= %1.18f\n", MyR8)
  fstp MyR10
  PrintLine cfm$("real10$\tPI= "), real10$(MyR10)
  MsgBox 0, Str$("MasmBasic PI= %Jf\n", MyR10), "Hi", MB_OK
EndOfCode


Output:MBasic  PI= 3.141592653589793238
FpuFLto PI= 3.141592653589793
CRT     PI= 3.141592653589793100
real10$ PI= 3.141593

MichaelW

Quote from: rrr314159 on September 29, 2016, 04:46:42 AM
Quote from: MichaelW on September 28, 2016, 06:36:25 AM
The CRT contains FPU functions, very well developed and reliable.

Well you live and learn. I wonder what they're for? I always use fpu instructions directly. Since we usually want max speed it seems counter-productive to use a Windows function instead.

[EDIT] come to think of it perhaps you mean the floating point conversion functions. I was thinking of functions like fadd - actual fpu instructions.

Quote from: rrr314159 on September 25, 2016, 06:57:10 PM
There aren't any FPU functions in the API, I believe. Even in previous Windows there weren't, but at least some of them used FPU. Today it's been replaced by SSE for "official" Windows floating point. Maybe you're thinking of Raymond's FPU functions?

I took "FPU functions" to mean FPU-related functions, and the CRT includes substantially more of such functions than just the conversion functions.

Well Microsoft, here's another nice mess you've gotten us into.

rrr314159

Well that's reasonable. I was thinking of functions like the ones in Raymond's library.
I am NaN ;)

Mikl__

Hi, all!
This is not a complete program
; GUI #
include win64a.inc
$max equ 60; <-- This number may be increased

magic1  equ 4D10h;lg(2)*65536=19728,3...
magic2  equ 35269h;log2(10)*65536=3,32192809488736234780*65536=217705,8796265381788254208..
.code
WinMain proc
local buffer[100]:BYTE
fninit
fldpi
fstp x
lea rdx,buffer
lea rcx,x
call Eprst
        invoke MessageBox,NULL,&buffer,&MsgCaption,MB_OK
invoke ExitProcess,NULL
WinMain endp
;----------------------------------- 
Eprst proc lpReal10:qword,lpDest:qword
local old_rsi:qword
local old_rdi:qword
local iExp:dword
local x[3]:dword

mov lpReal10,rcx
mov lpDest,rdx
;save registers rsi, rdi
mov old_rdi,rdi
mov old_rsi,rsi

mov rdi,rdx;lpDest - in rdi pointer to buffer
xor edx,edx
mov rax,[rcx]; in rax mantiss
mov qword ptr x,rax
movzx ecx,word ptr [rcx+8]; in edx sign end exp
        mov x+8,ecx
cmp ecx,8000h
mov byte ptr [rdi],'-'
        sbb esi,esi
and esi,0Dh
sub [rdi],esi
and ecx,7FFFh
        sub ecx,16382
cmp ecx,4
ja shift0
jmp table1[rcx*8]
shift4::
test x+4,60000000h
jz a6
fld tabs[12]
fmul
add iExp,4
fstp tbyte ptr x
mov rax,qword ptr x
        shld rdx,rax,1
shl rax,1
jmp shift0
a6:: shld rdx,rax,cl
        shl rax,cl
shift0::mov [rdi+1],dl
or word ptr [rdi+1],',0'
mov esi,10
k=3
rept 18
mul rsi
mov [rdi+k],dl
k=k+1
endm

mul rsi
mov [rdi+k],dl
mov rdx,'00000000'
or [rdi+3],rdx
        or [rdi+11],rdx
or qword ptr [rdi+19],'E000'
finish: mov rdi,old_rdi
mov rsi,old_rsi
leave
ret
Eprst endp
MsgCaption      db "Iczelion's tutorial #2b",0
x dt ?
table1 dq shift0,a6,a6,a6,shift4
dt 1.0e$max
dw 0
irp k,<59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,\
       38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,\
       16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1>
dt 1.0e&k
dw 0
endm
tabs dt 1.0
dw 0
irp k,<1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,\
       26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,\
       48,49,50,51,52,53,54,55,56,57,58,59,$max>
dt 1.0e-&k
dw 0
endm
end