1 /// -*- mode: asm; asm-comment-char: ?/ -*-
3 /// Random-number support for x86
5 /// (c) 2019 Straylight/Edgeware
8 ///----- Licensing notice ---------------------------------------------------
10 /// This file is part of Catacomb.
12 /// Catacomb is free software: you can redistribute it and/or modify it
13 /// under the terms of the GNU Library General Public License as published
14 /// by the Free Software Foundation; either version 2 of the License, or
15 /// (at your option) any later version.
17 /// Catacomb is distributed in the hope that it will be useful, but
18 /// WITHOUT ANY WARRANTY; without even the implied warranty of
19 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 /// Library General Public License for more details.
22 /// You should have received a copy of the GNU Library General Public
23 /// License along with Catacomb. If not, write to the Free Software
24 /// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 ///--------------------------------------------------------------------------
31 #include "asm-common.h"
37 ///--------------------------------------------------------------------------
38 /// Quick random generation.
40 FUNC(rand_quick_x86ish_rdrand)
41 // Enter with a pointer to the random context in the first argument.
42 // Return zero on success, or -1 on error.
49 #if CPUFAM_AMD64 && ABI_SYSV
53 #if CPUFAM_AMD64 && ABI_WIN
59 // Try to fetch a random number.
75 mov dword ptr [esp + 12], 32
76 mov dword ptr [esp + 8], 4
80 #if CPUFAM_AMD64 && ABI_SYSV
86 #if CPUFAM_AMD64 && ABI_WIN
100 #if CPUFAM_AMD64 && ABI_SYSV
103 #if CPUFAM_AMD64 && ABI_WIN
109 ///----- That's all, folks --------------------------------------------------