If you had made an effort to read a description of the fdiv instruction (in the tutorial link I gave you before or any other tutorial if you didn't like that one), you would probably have learned that FPU instructions only work with memory variables or values already in an FPU register. THE FPU CANNOT USE IMMEDIATE NUMBERS.

Raymond
Posted on 2003-09-29 22:48:36 by Raymond
Yes I know:), but then I don't know:(.
I mean I know that memory variables would work.
But then again, what is a memory variable?
Could you please show me how to use one or give me a tutorial/refference?

Sorry for being so foolish. I am new to assembly. Still I need advance assembly code. So please overcome your maddness about me and try explaining what to do when to do etc....


Julian.
Posted on 2003-09-30 13:21:27 by JulianS
From what what little i have read on the fpu.. from what i understand is when you push a value into the FPU it rotates to the next FPU so you can push a value onto it.. there are 8 FPU 0 - 7 so you would have to rotate it 7 more times to get back to the value you want to work with... thats the understanding i got.. hopes to be right :)
Posted on 2003-09-30 13:49:14 by devilsclaw
devilsclaw you need to assume that I know nothing. Cause I actually don't know alot.
So how do you rotate the number? And how do you push something into the stack? By using FILD?
Let's say I push it into the stack and get to rotate the number but then I'll still have to use memory variables, that I don't know what is? How to make them, or how to use them.
So please tell what they are.

Look, I appreciate all of your help, but this thread has been going on for a week now.
The way to help me, end this thread and save alot of time is by one of you explaining me in detail how to make the DIVML, MULML, ADDML and SUBML macros by using FP opcodes. Explaining correctly how to make each of these macros right and why. This includes that the "wonderfull" person who does this, tests the results in Masm and make them error free. Thank you.

Julian
Posted on 2003-09-30 15:34:06 by JulianS
JulianS

The main problem is that we don't really know what you are exactly trying to achieve.

You started this thread by stating that your macros were to process DWORDS which are integers (NO DECIMAL DIGITS). You then stated that you wanted results with 2 decimal digits for your division macro. If you later want to use the latter result to perform some other arithmetic operation, it would mean that you should also want to have 2 decimal places with ALL your "macros", otherwise, the entire process seems illogical.

If you have MASM32v8, the FPULIB folder contains all the source code for all the functions. Many of the functions were written to accept operands as either floating point variables in memory or already on the FPU, or integers in memory variables or CPU registers, or even immediate integer values. If you need to accept such different data formats with your "macros", you will have ample examples in the said source code. You will also realize that building "macros" to handle those different situations could become quite complex.

Writing the "Simply FPU" tutorial was also a lenghty process. Explaining how the FPU functions in a few lines would be impossible. However, I am still willing to clarify details which may not be sufficiently explained.

Raymond
Posted on 2003-09-30 23:25:57 by Raymond
You mentioned that DWORDs are integers.
What are Doubles(Doubles usually supports 4 decimals) then?
I mean do I only need to change the DWORDS to TWORDS or QWORDS to archive the results I want?


Some thoughs on FP::)

It would make sense to use FP, cause if I am getting this right, then FP stands for "Float Point"(A "Float" is almost the same as "Double").
But on the other side, FP just converts your number to a TWORD or something and then make the calculations and convert back.
So what's so special about FP? I mean you'll get the same results. Maybe I just mistake FP for FPU. However this is what you are supposed to help me figure out.


Julian
Posted on 2003-10-01 09:51:16 by JulianS
Hey Julian,

First fact that you need to know is that if you want to deal with decimal places, you *must* use fpu. But if decimal place is of no importance to you, then stick to use dword (and all those integer opcodes).

Float != Double, they are different data type. It is just like saying "A WORD is the almost the same as a DWORD"

If you want to learn fpu, the best is to start reading up Ray's tutorial "Simply FPU". Like what Ray said, I think it is irritating when the questions you ask could be found in the tutorial. Anyway QWORD is just simply 64bit data. So REAL8 = QWORD.

Frankly speaking, all I can say is that, try to walk before you attempt to fly.
Posted on 2003-10-01 10:04:16 by roticv
JulianS,

Study very carefully Chap. 2 of the "Simply FPU" tutorial which deals with data types (at the following site if you don't already have the entire tutorial):

http://www.masmforum.com/website/tutorials/fptute/fpuchap2.htm

Then, if you have more questions pertaining to that subject, I will be glad to attempt clarifying them.

Raymond
Posted on 2003-10-01 12:22:42 by Raymond
From reading that chapter I belive it could work if I just forgot all about the FPU/FP opcodes and changing all my DWORDs into REAL8.
I tried it and it compiled without errors. But would it output the right results?

Julian.
Posted on 2003-10-02 05:04:21 by JulianS
You should now have some understanding of what type of data can be used with FPU instructions. Each of the FPU instructions can then use only a specific group of those data types which all get converted internally to the REAL10 format before being processed.

Although the FPU can use either integer data or floating point data according to the instruction, the CPU does not have that flexibility.

Now you should learn that the CPU math instructions such as ADD, SUB, MUL, DIV and their variants only work with the integer number format. They CANNOT work correctly with numbers in the floating point format. The floating point data format was designed for specific use by the FPU.

I'm very surprised to hear that your macros were compiled without error when passing 64-bit REAL8 values as parameters to be used by CPU instructions requiring 32-bit values. Which assembler/compiler are you using???

Raymond
Posted on 2003-10-02 10:13:40 by Raymond
Raymond - I am using Masm32.

Everybody -

Here is my next message for you if any of you don't help me get results in any way:


Okay. Talking for several days about the same topic without results has made me just alittle :mad:

So I simply give up, and use the FPU functions instead of using the FP opcodes. Thats well pretty:
:stupid:



But in case any of you care enough to help me instead of trying to drag on for weeks then this would be my next message:


Thanks alot. I appreciate all of your work.


and in the end of that message I will tell you my little secret. In other words: You'll get to know why you should even bother talking to me.


So, if any of you diden't understand this message then let me put it in nice words:

Lose-Win

I've put it that way cause I think you will lose. Of course that's up to Posted on 2003-10-03 08:18:45 by JulianS
Okay. Talking for several days about the same topic without results has made me just alittle :mad:

So I simply give up, and use the FPU functions instead of using the FP opcodes. Thats well pretty:
:stupid:

The reason why I want you to do all the coding that's cause I really don' know alot of assembly, I started 3 months ago, and I really don't need assembly for most tasks.

The reason why I need assembly is mostly for my Posted on 2003-10-04 03:39:20 by JulianS