Your CPU has the FPU but fpc wants to use the registered version of processing math instructions instead of using the FPU.FMA is part of the SSE-based extensions, so if it all it would work on Win64 by default (which uses SSE by default), but not on other x86 targets (both 32-bit and 64-bit) as those use the x87 FPU by default.
- I wanted to utilize the FMA function (fused multiplication and addition) as used in the original code; the compiler however raised: "..Error: The function used, is not supported by the selected instruction set: FMA"; the CPU on my computer (as probably most) should allow the usage, yet there is no 'FMA' option in the fpu compiler settings.You need to enable the use of the FMA instruction set by setting the CPU type to CoreAVX2. Please note however that the other calculations are probably done on the x87 FPU except if you're on Win64.
- Is there an introduction how to use assembler within the pascal code? Is there any restrictions on which registers can be used; is the compiler capable of using more advanced instructions such as the equivalent of the above FMA command?The syntax for assembler blocks is mentioned here (https://www.freepascal.org/docs-html/current/ref/refse87.html#x170-19200013.3). As long as you mention the changed registers in the register list the compiler will handle them correctly. On x86 platforms you can use either Intel or AT&T syntax which you can change using the $ASMMODE (https://www.freepascal.org/docs-html/current/prog/progsu3.html#x10-90001.2.3) directive.
However the following code raises an error:Did you forget to close the bracket?
function fasterlog(a: single): single; assembler; // 6 digits acc asm mov a, %eax movss %xmm3, Result end ['rax';
However the following code raises an error:In first case a equal %xmm0, so code movl %xmm0, %eax is invalid.Whereas this one does not
function fasterlog(a: single): single; assembler; // 6 digits acc asm mov a, %eax movss %xmm3, Result end ['rax';What am I missing?
function fasterlog(a: single): single; // 6 digits acc begin asm mov a, %eax movss %xmm3, Result end ['rax']; end;
[…] And where would I find related information regarding the interplay of pascal and assembler? […]Jonas referred me to these resources (https://bugs.freepascal.org/view.php?id=35867#c117336) regarding interfacing Pascal procedure/function vs. assembly language.
@PacalDragonAs the name says that is the optimization processor. You need to set the code generation processor using -CpCOREAVX2.
Thanks for your reply;
I tried to set the the cpu optimization (-OpCOREAVX2) was that correct?; yet the compiler still complaines:
"Error: The function used, is not supported by the selected instruction set: FMA"