Hello, I'm working on yet another arbitrary precision integer library. I wanted to implement multiplication but I got stuck when _m_pmulhw
in <mmintrin.h>
just didn't work. there is very little documentation on MMX instructions. When I test it out, it just gives me gibberish when I multiply two UINT64_MAXs.
uint_fast64_t mulH(const uint_fast64_t &a, const uint_fast64_t &b) {
return (uint_fast64_t)_m_pmulhw((__m64)a,(__m64)b);
}
uint_fast64_t mulL(const uint_fast64_t &a, const uint_fast64_t &b) {
return (uint_fast64_t)_m_pmullw((__m64)a,(__m64)b);
}
int main() {
uint64_t a = UINT64_MAX;
uint64_t b = UINT64_MAX;
std::cout << std::bitset<64>(mulH(a,b)) << std::bitset<64>(mulL(a,b));
}
output: 00000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000010000000000000001
I don't know why it's not working i have an A6-4400M APU...
coreinfo's output:MMX * Supports MMX instruction set
So I think I can say, it isn't unsupported. If anyone can give me some tips on how to make this work thanks.
Compiler: gcc
IDE: visual studio code
_umul128
?