The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: thomas_remkus on January 20, 2007, 11:45:18 PM

Title: CPU understands floating points
Post by: thomas_remkus on January 20, 2007, 11:45:18 PM
I thought that the CPU did not understand floating points but I read there is a FWORD and QWORD and these seem to be floaters just fine. There are also CPU operands that are available for floats. Am I nuts, does this really exist? I thought the CPU knew nothing for the float.
Title: Re: CPU understands floating points
Post by: BogdanOntanu on January 21, 2007, 12:34:19 AM
Some CPU's do know floating point numbers and some do not.

Intel CPU's and compatibles starting from 486 DX upwards can handle the floating point numbers and operations internally by a hardware subsystem called the FPU (Floating point Unit)

So yes x86 "new" architecture is able to handle floating point operations.

Z80 does not :D
Title: Re: CPU understands floating points
Post by: raymond on January 21, 2007, 01:17:15 AM
In the context of BogdanOntanu's answer, the CPU would also have a second subsystem generally referred to as the ALU which would handle the integer operations. Instructions are sent to the appropriate subsystem by the managing part of the CPU. Those two subsystems may share some common "hardware" such as for performing multiplications.

One semantic problem has been that the ALU subsystem is very often called the CPU based on the original chips which did not have the FPU integrated on it.

However, to answer Thomas, some "integer" operations can be performed on floats with the ALU IF you know what you are doing.

Raymond
Title: Re: CPU understands floating points
Post by: GregL on January 21, 2007, 01:18:08 AM
Just to add to what has been said.

Regarding Intel CPUs:

The 8088, 8086, 80286, 30386 and 80486SX required a separate 80x87 FPU chip to do floating point. There was also 80x87 emulation software, but it was really slow.

The 80486DX and all later CPUs have the FPU built-in, on the same chip.

I remember, in the mid '80s, getting and installing a separate 8087 chip, what a thrill that was, fast floating point.  :bg

I used MASM back then too. It was fun then, it's still fun now.







Title: Re: CPU understands floating points
Post by: MichaelW on January 21, 2007, 04:05:41 AM
And to add more, the emulation software was at one time a common component for high-level languages. For an idea of how much slower the emulators were than the FPU, this loop:

FOR i& = 1 TO 1000000
    pi# = 4 * (4 * ATN(1 / 5) - ATN(1 / 239))
NEXT

Compiled with Microsoft PDS 7.0, and running on a P3-500, will execute in about 1.5 seconds when compiled to use the FPU, and in about 7.2 seconds when compiled to use the emulator.

QuoteI remember, in the mid '80s, getting and installing a separate 8087 chip, what a thrill that was, fast floating point.

Not to mention the thrill of trying to plug a ~$1000 chip (a 25MHz 80387 IIRC) into a non-ZIF PGA socket.
Title: Re: CPU understands floating points
Post by: GregL on January 21, 2007, 10:40:42 PM
Quote from: MichaelWNot to mention the thrill of trying to plug a ~$1000 chip (a 25MHz 80387 IIRC) into a non-ZIF PGA socket.

Yeah, that was a thrill too.


thomas_remkus,

Raymond wrote an excellent FPU tutorial, here's a link to it: Simply FPU (http://www.ray.masmcode.com/tutorial/index.html)