Skip to content

Instantly share code, notes, and snippets.

@slimsag
Created August 25, 2014 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slimsag/294e1a93d3d0f920939f to your computer and use it in GitHub Desktop.
Save slimsag/294e1a93d3d0f920939f to your computer and use it in GitHub Desktop.
// avxSupport uses CPUID to check if the CPU supports AVX
// func avxSupport() bool
// Return: +0(FP)
TEXT ·avxSupport(SB),$0
MOVL $0x1, AX
CPUID
// AND ECX, 0x18000000
BYTE $0x81; BYTE $0xE1; BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x18;
// CMP ECX, 0x18000000
BYTE $0x81; BYTE $0xF9; BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x18;
JNE notSupported
MOVB $0x1, ret+0(FP)
RET
notSupported:
MOVB $0x0, ret+0(FP)
RET
@Andoryuuta
Copy link

Crap, this was 8 years ago? We're getting old. >:(

@slimsag
Copy link
Author

slimsag commented Apr 29, 2022

What the duck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment