Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
div64 inline asm and other versions
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//for http://rextester.com/l/cpp_online_compiler_visual //Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x86 //#include <iostream> #include <string> #include <boost/filesystem.hpp> #include <Windows.h> //#include <direct.h> using namespace std; static string my_exe(void){ char buf[MAX_PATH]; DWORD tmp = GetModuleFileNameA( NULL, // self buf, MAX_PATH); return buf; //cout << "GMFN: " << tmp << ' ' << buf << endl; } int main() { string dircmd = "dir "; boost::filesystem::path p( my_exe() ); //boost::filesystem::path dir = p.parent_path(); p.remove_filename(); //p.replace_extension(".asm"); system ( (dircmd + p.string()).c_str() ); auto subdir = p.end(); subdir--; // cout << "subdir: " << subdir->c_str() << endl; p /= *subdir; p.replace_extension(".asm"); // cout << "p: " << p.string() << endl; system ( (string("type ") + p.string()).c_str() ); } #include <stdint.h> #define ABI _vectorcall // compiling with -Gv so vectorcall is the default doesn't work: boost doesn't link // MSVC // we could return a struct, but that would complicate thing int ABI div64(int hi, int lo, int divisor, int *premainder) { int quotient, tmp; __asm { mov edx, hi; mov eax, lo; idiv divisor mov quotient, eax mov tmp, edx; // mov ecx, premainder // Or this I guess? // mov [ecx], edx } *premainder = tmp; return quotient; } int ABI div64_noasm(int lo, int hi, int *premainder, int divisor) { int64_t hilo = ( ((uint64_t)hi) << 32) | (uint64_t)lo; *premainder = hilo % divisor; return hilo / divisor; } int ABI div64_noasm_merged(int64_t hilo, int *premainder, int divisor) { *premainder = hilo % divisor; return hilo / divisor; } unsigned ABI div64_noasm_u64_merged(uint64_t hilo, unsigned *premainder, unsigned divisor) { *premainder = hilo % divisor; return hilo / divisor; }
cl.exe
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 2.71 sec, absolute running time: 1.43 sec, absolute service time: 4,22 sec
edit mode
|
history
|
discussion