Advertisement
YauhenMardan

asm_5_r

May 6th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     int a;
  7.     int even=0, odd=0;
  8.     cout<<"Type a: ";
  9.     cin>>a;
  10.     __asm{
  11.         mov ebx,a
  12.        
  13.     beg_ord:
  14.         cmp ebx,0
  15.         jle end_ord
  16.        
  17.         mov eax,ebx
  18.         mov ecx,2
  19.         xor edx, edx
  20.         cdq
  21.         idiv ecx
  22.         //if even/odd
  23.         cmp edx,0
  24.         je eql_
  25.         jmp neql_
  26.     neql_:
  27.         mov edx,odd
  28.         add edx,1
  29.         mov odd,edx
  30.         jmp next_
  31.     eql_:
  32.         mov edx,even
  33.         add edx,1
  34.         mov even,edx
  35.         jmp next_
  36.     next_:
  37.         mov eax,ebx
  38.         mov ecx,10
  39.         xor edx, edx
  40.         cdq
  41.         idiv ecx
  42.         mov ebx,eax
  43.         jmp beg_ord
  44.     end_ord:
  45.     }
  46.     cout<<"Number: "<<a<<" even: "<<even<<" odd: "<<odd<<endl;
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement