Skip to content

Instantly share code, notes, and snippets.

@six519
Created March 15, 2023 04:38
Show Gist options
  • Save six519/2bc3f91036a662ddb894542e9809e6e9 to your computer and use it in GitHub Desktop.
Save six519/2bc3f91036a662ddb894542e9809e6e9 to your computer and use it in GitHub Desktop.
Floating Point Operation Sample Code In Assembly Linux x64
;floating point operation sample code
;just practicing programming in assembly language (Ferdinand Silva)
global main
extern printf
section .text
main:
call float_operation
mov rdi, str
sub rsp, 8 ;align stack (double is 8 bytes)
mov al, 1 ;count of xmm passed to printf (1 register which is xmm0)
call printf
add rsp, 8 ;cleanup stack
jmp exit
float_operation:
movsd xmm0, [flt]
mulsd xmm0, xmm0 ;multiply flt to itself
ret
exit:
mov rax, 0x3c
mov rdi, 0
syscall
section .data
str: db "The value is: %f", 0xa, 0
flt: dq 6519.765
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment