Skip to content
🌋️
Alchemy
Theme: Weyard
Theme: Modern
Mode: Auto
Mode: Light
Mode: Dark
Alchemy
Source
Reference
Loading...
Searching...
No Matches
mulq16.h
Go to the documentation of this file.
1
#ifndef ALCHEMY_MULQ16_H
2
#define ALCHEMY_MULQ16_H
3
4
/// @file
5
/// MulQ16, the 16.16 fixed-point multiply.
6
7
#include "
types.h
"
8
9
/// Multiplies 16.16 fixed-point values, returning the middle 32 product bits.
10
/// Emits IwramMulQ16's three instructions (smull, lsl, orr) at the call site.
11
CAMELOT_ASM
(
"smull with RdLo and RdHi in any two registers, even over its "
12
"inputs, where mulsidi3 "
13
"pairs them (RdHi = RdLo + 1) apart from the inputs and "
14
"smulsi3_highpart discards "
15
"RdLo; its orr takes a fresh output reload register beside two "
16
"dying inputs and "
17
"nothing is scheduled across it, as only asm statements do"
)
18
static __inline__
s32
MulQ16
(
s32
left,
s32
right) {
19
u32
low;
20
s32
high;
21
s32
result;
22
23
__asm__
volatile
(
"smull %1, %0, %3, %2"
24
:
"=r"
(high),
"=r"
(low)
25
:
"r"
(left),
"r"
(right));
26
high <<= 16;
27
__asm__
volatile
(
"orr %0, %1, %2, lsr #16"
28
:
"=r"
(result)
29
:
"r"
(high),
"r"
(low));
30
return
result;
31
}
32
33
#endif
MulQ16
static __inline__ s32 MulQ16(s32 left, s32 right)
Multiplies 16.16 fixed-point values, returning the middle 32 product bits.
Definition
mulq16.h:18
types.h
The integer types, TRUE, UNUSED and the fixed-address macros.
s32
signed int s32
Definition
types.h:14
u32
unsigned int u32
Definition
types.h:15
CAMELOT_ASM
#define CAMELOT_ASM(proof)
Definition
types.h:46
include
system
mulq16.h