Created
March 13, 2021 15:58
-
-
Save nokotan/78ecf012340908daa0a6ce47642718c9 to your computer and use it in GitHub Desktop.
inline WebAssembly in emscripten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdint> | |
#include <iostream> | |
int32_t add(int32_t n) { | |
int32_t sum; | |
__asm ( | |
"local.get %1\n" | |
"i32.const 1\n" | |
"i32.add\n" | |
"local.set %0" | |
: "=r"(sum) | |
: "r"(n) | |
); | |
return sum; | |
} | |
int main() { | |
int32_t a; | |
std::cin >> a; | |
std::cout << add(a) << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment