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 // Common register allocation.
44 #if CPUFAM_AMD64 && ABI_SYSV
47 #if CPUFAM_AMD64 && ABI_WIN
51 FUNC(rand_quick_x86ish_rdrand)
52 // Enter with a pointer to the random context in the first argument.
53 // Return zero on success, or -1 on error.
59 #if CPUFAM_AMD64 && ABI_SYSV
62 #if CPUFAM_AMD64 && ABI_WIN
67 // Try to fetch a random number.
83 mov dword ptr [SP + 12], 32
84 mov dword ptr [SP + 8], 4
88 #if CPUFAM_AMD64 && ABI_SYSV
94 #if CPUFAM_AMD64 && ABI_WIN
108 #if CPUFAM_AMD64 && ABI_SYSV
111 #if CPUFAM_AMD64 && ABI_WIN
119 ///----- That's all, folks --------------------------------------------------