%define x1 qword [EBP + 8] %define x2 qword [EBP + 16] %define y1 qword [EBP + 24] %define y2 qword [EBP + 32] %define d dword [EBP + 40] %include "asm_io.inc" segment .text global _distance _distance: push ebp mov ebp, esp push ebx fld x1 ; stack = x1 fsub x2 ; stack = (x1-x2) fmul st0 ; stack = (x1-x2)2 fld y1 ; stack = y1 (x1-x2)2 fsub y2 ; stack = (y1-y2) (x1-x2)2 fmul st0 ; stack = (y1-y2)2 (x1-x2)2 fadd st1 ; stack = d2 (x1-x2)2 fsqrt ; stack = d (x1-x2)2 mov ebx, d fst qword [ebx] ; write d to memory pop ebx pop ebp ret