I can only find the old 32-bit only inline assembler page http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgAsm or i'm blind ?
Joshy
Docu about inline assembler 64-bit ?
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Docu about inline assembler 64-bit ?
No, there's nothing. I suppose we could add some links. x86-64.org seems to be down at the moment; it used to have some details.
Inline asm with fbc's C backend is still tricky though, it doesn't fully work in all cases due to the need to translate to gcc's format...
Inline asm with fbc's C backend is still tricky though, it doesn't fully work in all cases due to the need to translate to gcc's format...
Re: Docu about inline assembler 64-bit ?
hello dkl and D.J.Peters
I hope you don't mind chiming in, as it is a bit off topic, I found I can use inline asm in my Mac version of FB x64
but have found no way to access the variables, if you set the optimization to zero then you can access the variables
using the rbp register but there doesn't seem to be a method to calculate the correct offset making it unusable
below is an illustration
I could never understand how to use the gcc inline asm, don't have a high enough IQ
I hope you don't mind chiming in, as it is a bit off topic, I found I can use inline asm in my Mac version of FB x64
but have found no way to access the variables, if you set the optimization to zero then you can access the variables
using the rbp register but there doesn't seem to be a method to calculate the correct offset making it unusable
below is an illustration
Code: Select all
function mytest(byref x as double, byref y as double) as double
dim as double z
asm
".intel_syntax noprefix"
"fldpi"
"fstp qword ptr [rbp-16]"
".att_syntax prefix"
end asm
return z
end function
dim as double a,b,c
c=mytest(1,2)
? a,b,c
Re: Docu about inline assembler 64-bit ?
Parameters are stored in registers and also on the stack.
BUT there are differences on how Windows and Linux are managing them.
BUT there are differences on how Windows and Linux are managing them.
Re: Docu about inline assembler 64-bit ?
Check out the -asm intel example for accessing parameters here: CompilerOptasm
It also works on 64bit (C backend), with fbc 1.05.0 at least.
It also works on 64bit (C backend), with fbc 1.05.0 at least.
Re: Docu about inline assembler 64-bit ?
@SARG
yes I can access the arguments from registers but I must compile with zero optimization or it won't work and there's no sure way to access local variables because of the unknown offset, I am guessing that gcc aligns the memory for the local vars.
@dkl
I can't figure that out, it's a completely alien language to me.
yes I can access the arguments from registers but I must compile with zero optimization or it won't work and there's no sure way to access local variables because of the unknown offset, I am guessing that gcc aligns the memory for the local vars.
@dkl
I can't figure that out, it's a completely alien language to me.
Re: Docu about inline assembler 64-bit ?
I'm confused; what's so alien about this?
It's normal FB inline ASM.
Code: Select all
Dim a As Long = 1
Print a
Asm
inc dword ptr [a]
End Asm
Print a
Re: Docu about inline assembler 64-bit ?
I apologize for having intruded this thread with off-topic posts so I will stop after this post, you are of course right dkl, for Windows x64 and Linux x64 normal intel asm works ok, it's on the Mac that I am unable to use normal asm, but that's ok with me.
Re: Docu about inline assembler 64-bit ?
I do have the MSDN link for win64 calling conventions handy: https://msdn.microsoft.com/en-us/library/ms235286.aspx
Summary:
// Integer arguments are passed in registers RCX, RDX, R8, and R9.
// Floating point arguments are passed in XMM0L, XMM1L, XMM2L, and XMM3L.
// volatile: RAX, RCX, RDX, R8, R9, R10, R11
// nonvolatile RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15 are considered nonvolatile
// no red zone
// keep stack 16-byte aligned.
I believe the sysv ABI puts the parameters in RDI,RSI,RDX
Summary:
// Integer arguments are passed in registers RCX, RDX, R8, and R9.
// Floating point arguments are passed in XMM0L, XMM1L, XMM2L, and XMM3L.
// volatile: RAX, RCX, RDX, R8, R9, R10, R11
// nonvolatile RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15 are considered nonvolatile
// no red zone
// keep stack 16-byte aligned.
I believe the sysv ABI puts the parameters in RDI,RSI,RDX