I'd like to do it anyway.OK. The Radius parameter is passed through the register xmm0. And you want it to push it to the FPU stack. Your example doesn't even compile!
[…] The Radius parameter is passed through the register xmm0. And you want it to push it to the FPU stack. Your example doesn't even compile!Essentially, yes. That's why I'm asking. How do I interpret xmm0?
The two questions remain.
- Why, or how do I access record fields, without calculating them on my own?
- How am I supposed to interpret or accept parameters within my assembler function?
[…]
[…] fst [rax].TSomeRec.Square […] fst [rax].TSomeRec.Cube […]
0x4001d1 <SPHERE+17> mov rax,QWORD PTR [rbp-0x10]
gdb(1) reports rax to be 0x0.
For some weird reason my @result is zero (nil) now, causing a 216 RTE.Need the source. My example works.
Need the source.It's just the six lines that are different.
My example works.Even your example doesn't for work me:
Free Pascal Compiler version 3.0.4+dfsg-11 [2017/12/30] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling project1.pas
project1.pas(2,2) Warning: APPTYPE is not supported by the target OS
project1.pas(18,3) Error: Asm: [pextrq mem??,mem??,imm??] invalid combination of opcode and operands
project1.pas(20,3) Error: Asm: [fmul mem??] invalid combination of opcode and operands
project1.pas(22,3) Error: Asm: [fst mem??] invalid combination of opcode and operands
project1.pas(23,3) Error: Asm: [fmul mem??] invalid combination of opcode and operands
project1.pas(24,3) Error: Asm: [fst mem??] invalid combination of opcode and operands
project1.pas(40) Fatal: There were 5 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode
Even your example doesn't for work me:This is weird. Everything works in Windows:
...>d:fpc.exe project1.lpr
Free Pascal Compiler version 3.0.4 [2018/02/25] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling project1.lpr
Linking project1.exe
38 lines compiled, 0.0 sec, 37984 bytes code, 1876 bytes data
...>type project1.lpr
{$MODE OBJFPC}
{$APPTYPE CONSOLE}
program Project1;
type
TSomeRec = record
Square: ValReal;
Cube: ValReal;
end;
function Calc(const Param: ValReal): TSomeRec;
{$IFDEF CPUX86_64}
assembler;
{$ASMMODE INTEL}
var
LRadius: ValReal;
asm
pextrq LRadius,Param,0
fld LRadius
fmul LRadius
mov rax, @Result
fst [rax].TSomeRec.Square
fmul LRadius
fst [rax].TSomeRec.Cube
end;
{$ELSE}
begin
Result.Square := Sqr(Param);
Result.Cube := Sqr(Param) * Param;
end;
{$ENDIF}
var
X: TSomeRec;
begin
X := Calc(1.5);
Writeln('Square=', X.Square:0:4, ' Cube=', X.Cube:0:4);
Readln;
end.
Your example compiled with warnings:project1.lpr(29,2) Warning: fmulp without operand translated into fmulpPResult is 1.0294370807283034E+005
project1.lpr(32,2) Warning: fmulp without operand translated into fmulpP
project1.lpr(33,2) Warning: fmulp without operand translated into fmulpP
project1.lpr(35,2) Warning: fmulp without operand translated into fmulpP
project1.lpr(37,2) Warning: "fdivrp" without operand translated into "fdivrp %st,%st(1)"
project1.lpr(52,0) Warning: Object file "project1.o" contains 32-bit absolute relocation to symbol ".data.n_tc_$p$functiondemo$_$sphere$real$$bodyattributes_$$_four".
project1.lpr(52,0) Warning: Object file "project1.o" contains 32-bit absolute relocation to symbol ".data.n_tc_$p$functiondemo$_$sphere$real$$bodyattributes_$$_three".
[…] Your example compiled with warnings: […]Those auto-completion warnings are fine, but the last two are not.
Result is 1.0294370807283034E+005Uhm, I hope not. Did I …? Err, after ning the first fild instruction the stack top has 4 loaded, has it not?
(gdb) info register st0
st0 4 (raw 0x40018000000000000000)
Anyway, that's a different story.[…]is supposed to read
[…] mov rax, @Result […]
[…]Yeah, of course: the pointer is followed. What I see is the default value. >sigh<
For some weird reason my @result is zero (nil) now, […] After nextingCode: [Select]0x4001d1 <SPHERE+17> mov rax,QWORD PTR [rbp-0x10]
gdb(1) reports rax to be 0x0.