Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit9420791a9335fc174627bea5f2a25f434bbe7ae5 (patch)
Author
 ValeriHristov <valeri.dhristov@gmail.com>
2018-11-17 15:47:38 +0200
Committer
 dtrendafilov <trendafilov.dn@gmail.com>
2018-11-17 15:47:38 +0200
Files83773f29d6617f13a087037de2189c31cb910cf9
IPL-9420791a9335fc174627bea5f2a25f434bbe7ae5.tar
IPL-9420791a9335fc174627bea5f2a25f434bbe7ae5.tar.gz
IPL-9420791a9335fc174627bea5f2a25f434bbe7ae5.zip
Parent002c541a9cdc84895a3459189270773d885e3e19 (diff)
GCD in asm (#41)
1 files changed, 30 insertions, 0 deletions
-rw-r--r--homework/61984/HW3/main.cpp30
diff --git a/homework/61984/HW3/main.cpp b/homework/61984/HW3/main.cpp
new file mode 100644
index 0000000..7696fe7
--- /dev/null
+++ b/homework/61984/HW3/main.cpp
@@ -0,0 +1,30 @@
+#include <iostream>
+int gcd(int a, int b)
+{
+ __asm
+ {
+ mov eax, a
+ mov ecx, b
+ loop1:
+ cmp eax, ecx
+ je end
+ jg suba
+ jmp subb
+
+ suba:
+ sub eax, ecx;
+ jmp loop1;
+
+ subb:
+ sub ecx, eax
+ jmp loop1
+
+ end:
+ }
+}
+
+int main()
+{
+ std::cout << gcd(21, 5);
+ return 0;
+}