Advertisement
YauhenMardan

asm_8.12_r

May 18th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int n = 6;
  6. const int k = 3;
  7. int n_ = n;
  8. int t;
  9. int main() {
  10. int a[n], b[k];
  11. cout << "Fill the first 'a' array:" << endl;
  12. for (int i = 0; i < n; i++) {
  13. cin >> a[i];
  14. }
  15. cout << "Fill the second 'b' array:" << endl;
  16. for (int i = 0; i < k; i++) {
  17. cin >> b[i];
  18. }
  19. _asm {
  20. mov ecx, k
  21. mov edi, 0
  22. beg_:
  23.  
  24. mov esi, 0
  25. mov edx, ecx //save ecx
  26. mov ecx, n_
  27. beg2_ :
  28. mov ebx, b[edi]
  29. cmp ebx, a[esi]
  30. je EQL
  31. add esi, 4
  32. jmp NXT
  33. EQL :
  34. //----
  35. mov ebx,ecx // save ecx
  36. mov t,esi //save esi
  37. mov ecx,n_
  38. beg_shift_:
  39. cmp ecx,1
  40. je NNN
  41. add esi,4
  42. mov eax,a[esi]
  43. sub esi,4
  44. mov a[esi],eax
  45. add esi, 4
  46. loop beg_shift_
  47. NNN:
  48. mov eax, n_ //n_--
  49. sub eax,1
  50. mov n_,eax
  51.  
  52. mov ecx, ebx // load ecx
  53. mov esi, t //load esi
  54.  
  55. //add ecx,1
  56. //----
  57. NXT :
  58. loop beg2_
  59.  
  60. mov ecx, edx //load ecx
  61. add edi, 4
  62. loop beg_
  63. }
  64. cout << "The third 'a' array:" << endl;
  65. for (int i = 0; i < n_; i++) {
  66. cout << a[i] << endl;
  67. }
  68. system("pause");
  69. return 0;
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement