Float to Double
Float to Double
I want to convert a float to double without using user library.. I had seen an ASM code that do that, but I lost it and I can't refind it... Does someone have it ?
Re: Float to Double
; *Polo wrote:I want to convert a float to double without using user library.. I had seen an ASM code that do that, but I lost it and I can't refind it... Does someone have it ?
; * Converts a Float to a Double
; *
Structure dblout
p1.l
p2.l
EndStructure
Procedure DoublePart1(flt.f)
Global _input.f:_input.f=flt
Global _dblout.dblout
!FLD dword[v__input]
!FST qword[v__dblout]
ProcedureReturn _dblout\p1
EndProcedure
Procedure DoublePart2(flt.f)
Global _input.f:_input.f=flt
Global _dblout.dblout
!FLD dword[v__input]
!FST qword[v__dblout]
ProcedureReturn _dblout\p2
EndProcedure
GiveDouble (DoublePart1(100),DoublePart2(100))
The value is max. 32 bit.
MFG
WolfgangS
WolfgangS' projects http://www.schliess.net
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
I don't see GiveDouble as a standard PB funciton. But here is what I use:Polo wrote:Thanks, but what is this GiveDouble() function ?
Code: Select all
Structure Double
Hi.l
Lo.l
EndStructure
Procedure MakeDouble(LONG.f, ADDRESS.l)
!FLD dword [ Esp ]
!MOV dword Eax, [ Esp + 4 ]
!FSTP qword [ Eax ]
EndProcedure
Procedure.l DrawImage(Left.f, Top.f, Width.f, Height.f)
dLeft.Double
dTop.Double
dWidth.Double
dHeight.Double
MakeDouble(Left.f, @dLeft)
MakeDouble(Top.f, @dTop)
MakeDouble(Width.f, @dWidth)
MakeDouble(Height.f, @dHeight)
ProcedureReturn CallFunctionFast(FPDrawImage, dLeft\Hi, dLeft\Lo, dTop\Hi, dTop\Lo, dWidth\Hi, dWidth\Lo, dHeight\Hi, dHeight\Lo)
EndProcedure
It shows you how to use the procedures.Polo wrote:Thanks, but what is this GiveDouble() function ?
WolfgangS' projects http://www.schliess.net
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..also
also...Polo wrote:Thanks, it works !
Here is a CatchDoubleReturn example:
Code: Select all
Procedure.f CatchDoubleReturn(*x.Double)
!MOV dword EAX,[ESP]
!FST qword [EAX]
!MOV dword EAX,[ESP]
!FLD qword [EAX]
EndProcedure
Code: Select all
Procedure.f GetHTMLTextHeight(Width.f, HTMLText.s)
dWidth.Double
MakeDouble(Width.f, @dWidth)
CallFunctionFast(FPGetHTMLTextHeight, dWidth\Hi, dWidth\Lo, HTMLText)
ProcedureReturn CatchDoubleReturn(dummy.Double)
EndProcedure
- np
it's really a shame you should have to go through all that trouble, just to use a double variable...
Let's hope new variable types are high on Fred's priority-/todo-list..
Let's hope new variable types are high on Fred's priority-/todo-list..

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
I think it is.. along with letting there be up to 40 parameters on aLarsG wrote:it's really a shame you should have to go through all that trouble, just to use a double variable...
Let's hope new variable types are high on Fred's priority-/todo-list..
procedure.. the parameters are being changed to meet some req's
of the iSED library ..
- np
* see, Fred just does a search now an then, for the key word Fred..
lol .. then he reads whats being said..

fred Fred FRED ... maybe I'll just make a library for them .. I'm sure
theres one out there already.. but I kinda like to know whats in em..
<eg> libs are easy to make now, with El's new app ..TailBite
-
- Addict
- Posts: 1126
- Joined: Wed Oct 15, 2003 12:40 am
- Location: Sweden
- Contact:
Re: ..
Ehhhh - didn't know that... What is the limit now?NoahPhense wrote:along with letting there be up to 40 parameters on a
procedure..
Hmmm - in a Digital Flight Simulator I programmed a couple of years ago we had over 600 parameters in the main call - no use of PB there I'll guess...


(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
Re: ..
Yeah, it's being moved up. SedTech said it was currently at 20techjunkie wrote:Ehhhh - didn't know that... What is the limit now?NoahPhense wrote:along with letting there be up to 40 parameters on a
procedure..
Hmmm - in a Digital Flight Simulator I programmed a couple of years ago we had over 600 parameters in the main call - no use of PB there I'll guess...
parameters per procedure.
But, if I 'truly' had a need for 40 this very second. I could make it work.
I would just create the procedure to accept string delimited data, then
parse it just after it came into the procedure, assigning the data back
to their appropriate variable types.. 40, 60, 300, would work. But then
we would probably run into a line length issue anyhow, with the assembler.
I try not to worry about issues or hurdles if you will, until they are in my
face. And usually when that happens, I've always gotten a solution, or
created one..

As for 600 parameters, that's just sick..

- np
-
- Addict
- Posts: 1126
- Joined: Wed Oct 15, 2003 12:40 am
- Location: Sweden
- Contact:
Re: ..
Well, it simulated a real aircraft and data for the engine was real engine data - impossible to simulate... As I remember, we had about 15000 variables in the system + the derivate of all variables... So - it was a big system, but it worked very well... in realtime...NoahPhense wrote:As for 600 parameters, that's just sick..

About PB - if it is a limit of 20 parameters, that's real bad - I'm just lucky that I haven't broke the limit... *counting* Ehhhh - 18 parameters in that procedure... *LOL*

(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
-
- Enthusiast
- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
Re: ..
Well, you two could use Structures to pass Parameters to Procedures. This is recommended (at least by me) anyway, as it is faster and has more structure (no pun intended).techjunkie wrote:Well, it simulated a real aircraft and data for the engine was real engine data - impossible to simulate... As I remember, we had about 15000 variables in the system + the derivate of all variables... So - it was a big system, but it worked very well... in realtime...NoahPhense wrote:As for 600 parameters, that's just sick..![]()
About PB - if it is a limit of 20 parameters, that's real bad - I'm just lucky that I haven't broke the limit... *counting* Ehhhh - 18 parameters in that procedure... *LOL*
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
Re: ..
True, care for a quick example?freedimension wrote:Well, you two could use Structures to pass Parameters to Procedures. This is recommended (at least by me) anyway, as it is faster and has more structure (no pun intended).techjunkie wrote:Well, it simulated a real aircraft and data for the engine was real engine data - impossible to simulate... As I remember, we had about 15000 variables in the system + the derivate of all variables... So - it was a big system, but it worked very well... in realtime...NoahPhense wrote:As for 600 parameters, that's just sick..![]()
About PB - if it is a limit of 20 parameters, that's real bad - I'm just lucky that I haven't broke the limit... *counting* Ehhhh - 18 parameters in that procedure... *LOL*

- np