Advertisement
YauhenMardan

asm_while_2

May 6th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int a,i=0; //a-число, i-порядок
  7. cout<<"Type a: ";
  8. cin>>a;
  9. __asm{
  10. mov eax,a
  11. //модуль числа
  12. cmp eax,0
  13. jg a_less_0
  14. jmp a_greater_0
  15. a_less_0:
  16. jmp abs_
  17. a_greater_0:
  18. mov ebx,-1
  19. imul ebx
  20. jmp abs_
  21. abs_:
  22. mov ecx,eax
  23. //порядок числа
  24. beg_ord:
  25. cmp eax,0
  26. jle end_ord
  27. mov ebx,10
  28. cwd
  29. idiv ebx
  30. //i++
  31. mov ebx,i
  32. add ebx,1
  33. mov i,ebx
  34. jmp beg_ord
  35. end_ord:
  36.  
  37. }
  38. cout<<"Число "<<a<<" Порядок "<<i<<endl;
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement