Testing latest pari + WASM + node.js... and it works?! Wow.
License: GPL3
ubuntu2004
/* Copyright (C) 2000 The PARI group.12This file is part of the PARI/GP package.34PARI/GP is free software; you can redistribute it and/or modify it under the5terms of the GNU General Public License as published by the Free Software6Foundation; either version 2 of the License, or (at your option) any later7version. It is distributed in the hope that it will be useful, but WITHOUT8ANY WARRANTY WHATSOEVER.910Check the License for details. You should have received a copy of it, along11with the package; see the file 'COPYING'. If not, write to the Free Software12Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */13/*14ASM addll mulll bfffo15NOASM divll16*/17#ifdef ASMINLINE18#define LOCAL_HIREMAINDER register ulong hiremainder19#define LOCAL_OVERFLOW register ulong overflow2021#define addll(a, b)\22__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \23__asm__ ("addc %0,%2,%3\n\txor %1,%2,%2\n\taddze %1,%4\n\t" \24: "=&r" (__value), "=r" (overflow) \25: "r" (__arg1), "r" (__arg2), "1" ((ulong) 0)); \26__value; \27})2829#define addllx(a, b)\30__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \31__asm__ ("addc %0,%3,%4\n\tli %1,0\n\taddze %1,%4\n\taddc %0,%2,%5\n\taddze %1,%4\n\t" \32: "=&r" (__value), "=r" (overflow) \33: "r" (__arg1), "r" (__arg2), "1" (overflow), "0" ((ulong) 0)); \34__value; \35})3637#define bfffo(a) \38__extension__ ({ ulong __a = (a), __value; \39__asm__ ("cntlzd %0, %1" : "=r" (__value) : "r" (__a)); \40__value; \41})4243#define subll(a, b)\44__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \45__asm__ ("subfc %0,%3,%2\n\tli %1,0\n\taddme %1,%4\n\tneg %1,%4" \46: "=&r" (__value), "=r" (overflow) \47: "r" (__arg1), "r" (__arg2), "1" ((ulong)0)); \48__value; \49})5051#define subllx(a, b)\52__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \53__asm__ ("subfc %0,%5,%2\n\tli %1,0\n\taddme %1,%5\n\tsubfc %0,%3,%4\n\taddme %1,%5\n\tneg %1,%5" \54: "=r" (__value), "=r" (overflow) \55: "r" (__arg1), "r" (__arg2), "0" ((ulong)0), "1" (overflow)); \56__value; \57})5859#define mulll(a, b) \60__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b); \61__asm__ ("mulhdu %1,%2,%3\n\tmulld %0,%2,%3\n\t" \62: "=r" (__value), "=&r" (hiremainder) \63: "r" (__arg1), "r" (__arg2)); \64__value; \65})6667#define addmul(a, b) \68__extension__ ({ ulong __value, __arg1 = (a), __arg2 = (b), __temp; \69__asm__ ("mulld %0,%3,%4\n\tmulhdu %2,%3,%4\n\taddc %0,%5,%6\n\taddze %1,%7\n\t" \70: "=&r" (__value), "=r" (hiremainder), "=r" (__temp) \71: "r" (__arg1), "r" (__arg2), "0" ((ulong) 0), "1" (hiremainder), "2" ((ulong) 0)); \72__value; \73})74#endif757677