Hi! Nice to meet you again! Combining assembly with pascal seems means
a lot to you. :-) Now, I'd like to explain how to use Math co-processor
inside your Pascal program. Borland provides an easy way to do it. This
is a pretty brief lesson. I cancel giving the introduction of protected
mode programming. I think that it is better to include it in the next lesson.
You can automatically use math co-processor (FPU) in Borland Pascal. BP will convert every lines that needs calculation into FPU instructions. Of course, BP is a smart compiler. If the calculations doesn't need to be converted, then it simply leaves the normal instruction intact.
Enabling FPU support is done by turning on the $N switch: {$N+}. BP will compile your program with FPU instruction as needed. When you run your compiled program (the EXE) form, it first look at the existence of FPU. If it exists, then FPU instruction can be applied successfully. If it doesn't then it does the emulation. So, you don't need to worry about the existence of FPU. However, if FPU is exist, then your program runs faster.
If you want your program use ONLY if the FPU exist, you can turn off
the $E switch. It is switched on in default. What it does is just
enabling the emulation. So that if the FPU does not exist, the program
can normally run (of course with slower pace). If you turn this off, if
the FPU does not exist, your program will refuse to run.
Testing CPU type in Pascal is pretty easy. It provides the function Test8086. You don't need to get around with the machine language or so. Just check the function Test8086. If it returns 0, then it is a 8086 CPU. If it is 1, then it is a 80286 CPU. If it is 2, then it is a 80386 or better CPUs.
Testing FPU type is similar to testing CPU. Just check the function
Test8087. If it is 0, then the computer has no FPU inside. Otherwise,
FPU is present.
That's all folks! This ends the second lesson. Shall we go to the next lesson? Or you still don't understand? Visit me!
Back to main page
Back to Pascal Tutorial Lesson 2 contents
Quiz? No quiz. I think you are pretty mature in programming! :-)
To Lesson 3 contents
My page of programming link
Contact me here
By: Roby Joehanes, © 1997, 2000