Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. // ConsoleApplication3.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6. #include <cstring>
  7. using namespace std;
  8. struct rect {
  9. int x, y;
  10. int width;
  11. int height;
  12. };
  13. void f(rect *, rect *)
  14. {
  15. int raspuns;
  16. _asm {
  17. mov ebx, [ebp + 8]//ebx = r1
  18. mov ecx, [ebp+12]//ecx = r2
  19. mov eax,[ebx]//eax=x1
  20. mov edx,[ecx]//edx=x2
  21. CMP eax,edx//if(x1<=x2)
  22. JG _case2//r2 nu e inclus in r1 dar poate e invers
  23. mov eax,[ebx+4]//eax=y1
  24. mov edx,[ecx+4]//edx=y2
  25. CMP eax,edx//if(y1<=y2)
  26. JG _case3// sigur nimic nu e inclus
  27. mov edx,[ebx]//edx=x1
  28. add edx,[ebx+8]//edx=x1+width1
  29. mov eax,[ecx]
  30. add eax,[ecx+8]
  31. CMP edx,eax//if(x1+width1>x2+width2)
  32. JL _case3
  33. mov edx,[ebx+4]//edx=y1
  34. add edx,[ebx+12]//edx=y1+height1
  35. mov eax,[ecx+4]
  36. add eax,[ecx+12]
  37. CMP edx,eax//if(y1+heigh1>y2+height2)
  38. JL _case3
  39. mov raspuns,2//adica r2 inclus in r1
  40. JMP _jos
  41. _case2:
  42. mov eax,[ecx+4]//eax=y2
  43. mov edx,[ebx+4]//edx=y1
  44. CMP eax,edx//if(y2<y1)
  45. JG _case3// x2<x1 si y1<y2 => nimic nu e inclus
  46. mov edx,[ecx]//edx=x2
  47. add edx,[ecx+8]//edx=x2+width2
  48. mov eax,[ebx]
  49. add eax,[ebx+8]
  50. cmp edx,eax//if(x2+width2>x1+width1)
  51. JL _case3
  52. mov edx,[ecx+4]//edx=y2
  53. add edx,[ecx+12]//edx=y2+height2
  54. mov eax,[ebx+4]
  55. add eax,[ebx+12]
  56. CMP edx,eax//if(y2+height2>y1+height1)
  57. JL _case3
  58. mov raspuns,2 //adica r1 inclus in r2
  59. JMP _jos
  60. _case3:
  61. mov raspuns,0//niciunul nu e inclus
  62. _jos:
  63. }
  64.  
  65. cout << raspuns;
  66. }
  67. int main()
  68. {
  69. rect r1,r2;
  70. cin >> r1.x>>r1.y>>r1.width>>r1.height;
  71. cin >> r2.x >> r2.y >> r2.width >> r2.height;
  72. _asm {
  73. lea ebx,r1
  74. push ebx
  75. lea ebx,r2
  76. push ebx
  77. CALL f
  78. add esp,8
  79. }
  80. return 0;
  81. }
  82. // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
  83. // Debug program: F5 or Debug > Start Debugging menu
  84.  
  85. // Tips for Getting Started:
  86. // 1. Use the Solution Explorer window to add/manage files
  87. // 2. Use the Team Explorer window to connect to source control
  88. // 3. Use the Output window to see build output and other messages
  89. // 4. Use the Error List window to view errors
  90. // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
  91. // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement