# area64.s - to calculate the area of a circle
.section .text
.def @function #WINDOWS
//.type area , @function #LINUX
#
.globl area 
# declare the function name as a global label,
# so other programs can access it
area:
#
pushq %rbp
movq %rsp, %rbp # bp=sp 
subq $4, %rsp # = -4(%rbp) , so stack pointer has the result in st(0) instead st(1)
#
fldpi # pi value is loaded into the FPU stack
#
filds 8(%rbp) # loads a doubleword integer 2 positions after initial base pointer 
//value references the first parameter placed on the stack by the calling program
//After the area result is calculated it is placed in the local variable data: fstps -4(%ebp)
#
fmul %st(0), %st(0) # mul st(0) st(0) and store the result in st(0)
#
fmulp %st(0), %st(1) # pop st(0), mul st(0) st(1) and store the result in st(1), and pop st(0)
#
fstps -4(%rbp) 
//to create a singleprecision floating-point value
//retrieveing the value from st(0)  
#
movq -4(%rbp), %rax 
# value is placed into the EAX register, where it is retrieved by the main program.
#
movq %rbp, %rsp # replaces bp=sp
popq %rbp
ret

