Advertisement
Guest User

asm#2

a guest
May 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. void func2()
  2. {
  3.     cout<<"Type number: ";
  4.     int t;
  5.     cin>>t;
  6.     int quan=0;
  7.     __asm
  8.     {
  9.         mov eax, t
  10.         mov ebx, 10
  11.     beg:
  12.         cmp eax, 0
  13.         je end_
  14.         jg gr
  15.         sub ebx, 0
  16.         jmp beg
  17.     gr:
  18.         cdq
  19.         idiv ebx
  20.         add quan,1
  21.         jmp beg
  22.     end_:
  23.        
  24.         mov eax, t
  25.         cmp eax, 0
  26.         jz null_
  27.         jmp endl_
  28.     null_:
  29.         add quan, 1
  30.     endl_:
  31.     }
  32.     cout<<"Quantity of numbers: "<<quan<<endl;
  33. }
  34.  
  35. void func3()
  36. {
  37.     int t;
  38.     cout<<"Type number: ";
  39.     cin>>t;
  40.     int quan1=1, modul, power=0, res=0;
  41.     __asm
  42.     {
  43.         mov eax, t
  44.         mov ecx, eax
  45.         mov ebx, 0
  46.     loop1:
  47.         mov eax, ecx
  48.         cmp eax, 0
  49.         jne zero1
  50.         jmp end2
  51.     zero1:
  52.         and eax, 1
  53.         shr ecx, 1
  54.         cmp eax, 1
  55.         je equal1
  56.         jmp loop1
  57.     equal1:
  58.         inc ebx
  59.         jmp loop1
  60.     end2:
  61.         mov res, ebx
  62.     }
  63.     cout<<"Result: "<<res<<endl;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement