OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
assembly.h
Go to the documentation of this file.
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: RCSL 1.0/RPSL 1.0
3 *
4 * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
5 *
6 * The contents of this file, and the files included with this file, are
7 * subject to the current version of the RealNetworks Public Source License
8 * Version 1.0 (the "RPSL") available at
9 * http://www.helixcommunity.org/content/rpsl unless you have licensed
10 * the file under the RealNetworks Community Source License Version 1.0
11 * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
12 * in which case the RCSL will apply. You may also obtain the license terms
13 * directly from RealNetworks. You may not use this file except in
14 * compliance with the RPSL or, if you have a valid RCSL with RealNetworks
15 * applicable to this file, the RCSL. Please see the applicable RPSL or
16 * RCSL for the rights, obligations and limitations governing use of the
17 * contents of the file.
18 *
19 * This file is part of the Helix DNA Technology. RealNetworks is the
20 * developer of the Original Code and owns the copyrights in the portions
21 * it created.
22 *
23 * This file, and the files included with this file, is distributed and made
24 * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
25 * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
26 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
27 * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
28 *
29 * Technology Compatibility Kit Test Suite(s) Location:
30 * http://www.helixcommunity.org/content/tck
31 *
32 * Contributor(s):
33 *
34 * ***** END LICENSE BLOCK ***** */
35
36/**************************************************************************************
37 * Fixed-point MP3 decoder
38 * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
39 * June 2003
40 *
41 * assembly.h - assembly language functions and prototypes for supported platforms
42 *
43 * - inline rountines with access to 64-bit multiply results
44 * - x86 (_WIN32) and ARM (ARM_ADS, _WIN32_WCE) versions included
45 * - some inline functions are mix of asm and C for speed
46 * - some functions are in native asm files, so only the prototype is given here
47 *
48 * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y), returns top 32 bits of 64-bit result
49 * FASTABS(x) branchless absolute value of signed integer x
50 * CLZ(x) count leading zeros in x
51 * MADD64(sum, x, y) (Windows only) sum [64-bit] += x [32-bit] * y [32-bit]
52 * SHL64(sum, x, y) (Windows only) 64-bit left shift using __int64
53 * SAR64(sum, x, y) (Windows only) 64-bit right shift using __int64
54 */
55
56#ifndef _ASSEMBLY_H
57#define _ASSEMBLY_H
58
59#include <Library/BaseLib.h>
60
61static __inline int MULSHIFT32(int x, int y)
62{
63 return (INT32) (RShiftU64 (MultS64x64 (x, y), 32));
64}
65
66static __inline int FASTABS(int x)
67{
68 int sign;
69
70 sign = x >> (sizeof(int) * 8 - 1);
71 x ^= sign;
72 x -= sign;
73
74 return x;
75}
76
77static __inline int CLZ(int x)
78{
79 int numZeros;
80
81 if (!x)
82 return (sizeof(int) * 8);
83
84 numZeros = 0;
85 while (!(x & 0x80000000)) {
86 numZeros++;
87 x <<= 1;
88 }
89
90 return numZeros;
91}
92
93typedef INT64 Word64;
94
95static __inline Word64 MADD64(Word64 sum, int x, int y)
96{
97 sum += MultS64x64 (x, y);
98 return sum;
99}
100
101static __inline Word64 SHL64(Word64 x, int n)
102{
103 return (Word64)LShiftU64 (x, n);
104}
105
106static __inline Word64 SAR64(Word64 x, int n)
107{
108 return (Word64)RShiftU64 (x, n);
109}
110
111#endif /* _ASSEMBLY_H */
UINT16 y
Definition BmfFile.h:84
UINT16 x
Definition BmfFile.h:83
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
Definition UserMath.c:86
INT64 EFIAPI MultS64x64(IN INT64 Multiplicand, IN INT64 Multiplier)
Definition UserMath.c:106
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
Definition UserMath.c:76
INT64 Word64
Definition assembly.h:93