Thanks for your fast answer.
Well it can be decide wheather I wanna use 32 or 64 bit integers, I just declare them as integer*8 or integer*4 and can also set the -i8 flag to the compiler for default 64bit integers. But usually in my calculations, we use 64 bit architecture.
Yes, you remember right, fortran always passes the variables by reference, so the address of them instead of their values, which sometimes can be very useful.
But i think that might cause problems when you want to interface it with an assembly source.
You were also right with the external functions.
I am using Arch Linux.
I know a little bit of assembly, as I am studying electrical engeneering, so I understood what you did.
My code now is:
thats fortran.f:
program testassembly
implicit none
integer*8 summ,a,b
a=3
b=4
write(6,*)summ(a,b)
end
thats to compile:
nasm -f elf64 summ.asm
gfortran -o run summ.o fortran.f -g
and thats assembly:
global summ_
summ_:
push rbp
mov rbp, rsp
mov rax, [rbp + 8] ; address of first parameter
mov rcx, [rbp + 16] ; address of second parameter
mov rax, [rax] ; first parameter
mov rcx, [rcx] ; second parameter
add rax, rcx ; add 'em up
; return result in eax?
mov rsp, rbp
pop rbp
ret
I have search for 64 bit arch. and figured out that the registers (eax,ebx etc...) were renamed to rax,rbx so just a change in the first letter to r.
If I do ./run it gives me segmentation fault all the time. I think something is wrong with the address, so I`m asking for your help guys!
Thank you.
Bence