# Guide 这是用汇编指令 **RdRand** 实现的硬件随机数,发布出来的目的一是为了好保存,二是抛砖引玉哈。 > NOTE: 适用于12年后的Intel和15年后的AMD处理器 ### 看下引用哈,本来还有个RdSeed随机种子,我没写嘿嘿 > RDRAND is available in Ivy Bridge processors and is part of the Intel 64 and IA-32 instruction set architectures. AMD added support for the instruction in June 2015. RDSEED is similar to RDRAND and provides higher level access to the entropy hardware. The RDSEED generator and processor instruction rdseed are available with Intel Broadwell CPUs and AMD Zen CPUs. ### 以下是Go代码 文件名为RdRand_amd64.go ```go package RdRand func Rand(min, max uint64)uint ``` ### 下面是汇编代码 文件名为RdRand_amd64.s #### **第一次用这种汇编形式写,如果有误请指出,谢谢** ```go TEXT ·Rand(SB),$0-24 BYTE $0x48; BYTE $0x0f; BYTE $0xc7; BYTE $0xf0 // RdRand RAX MOVQ max+8(FP), CX SUBQ min+0(FP), CX INCQ CX XORQ DX,DX DIVQ CX ADDQ min+0(FP),DX MOVQ DX, ret+16(FP) RET ``` ### 保存,然后调用就行了