Skip to content

Instantly share code, notes, and snippets.

@eventhelix
Last active May 7, 2022 20:21
Show Gist options
  • Save eventhelix/8a1ab0b3347c25631e55252145b1a7b8 to your computer and use it in GitHub Desktop.
Save eventhelix/8a1ab0b3347c25631e55252145b1a7b8 to your computer and use it in GitHub Desktop.
example::double:
mov rax, rdi
mov rcx, qword ptr [rsi] ; Read the enum discriminator
test rcx, rcx ; Check the discriminator for 0
je .LBB0_5
cmp ecx, 1
jne .LBB0_3
movsd xmm0, qword ptr [rsi + 8]
addsd xmm0, xmm0
movsd qword ptr [rax + 8], xmm0
mov ecx, 1
mov qword ptr [rax], rcx
ret
.LBB0_5:
mov rcx, qword ptr [rsi + 8]
add rcx, rcx
mov qword ptr [rax + 8], rcx
xor ecx, ecx
mov qword ptr [rax], rcx
ret
.LBB0_3:
movsd xmm0, qword ptr [rsi + 8]
movsd xmm1, qword ptr [rsi + 16]
addsd xmm0, xmm0
addsd xmm1, xmm1
movsd qword ptr [rax + 8], xmm0
movsd qword ptr [rax + 16], xmm1
mov ecx, 2
mov qword ptr [rax], rcx
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment