Advertisement
artur99

AMS Count number of 7s in number

Dec 7th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5.  
  6. int main() {
  7.     int a, b, d, rest;
  8.     a = 2277474;
  9.  
  10.     _asm {
  11.         mov eax, a
  12.         mov ecx, 0
  13.         mov ebx, 10
  14.         _while:
  15.             cmp eax, 0
  16.             je _endwhile
  17.             mov edx, 0
  18.             div ebx
  19.             cmp edx, 7
  20.             jne _not7
  21.                 inc ecx
  22.             _not7:
  23.             jmp _while
  24.         _endwhile:
  25.         mov b, ecx;
  26.         /* shl eax, 2*/
  27.         /* shr eax, 2*/
  28.         /* rol eax, 2*/
  29.         /* ror eax, 2*/
  30.         /* mul cx === ax * cx */
  31.         /* div b == dxax / b = ax rest dx */
  32.     };
  33.  
  34.     cout << b;
  35.     cout << endl;
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement