Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication3.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <cstring>
- using namespace std;
- struct rect {
- int x, y;
- int width;
- int height;
- };
- void f(rect *, rect *)
- {
- int raspuns;
- _asm {
- mov ebx, [ebp + 8]//ebx = r1
- mov ecx, [ebp+12]//ecx = r2
- mov eax,[ebx]//eax=x1
- mov edx,[ecx]//edx=x2
- CMP eax,edx//if(x1<=x2)
- JG _case2//r2 nu e inclus in r1 dar poate e invers
- mov eax,[ebx+4]//eax=y1
- mov edx,[ecx+4]//edx=y2
- CMP eax,edx//if(y1<=y2)
- JG _case3// sigur nimic nu e inclus
- mov edx,[ebx]//edx=x1
- add edx,[ebx+8]//edx=x1+width1
- mov eax,[ecx]
- add eax,[ecx+8]
- CMP edx,eax//if(x1+width1>x2+width2)
- JL _case3
- mov edx,[ebx+4]//edx=y1
- add edx,[ebx+12]//edx=y1+height1
- mov eax,[ecx+4]
- add eax,[ecx+12]
- CMP edx,eax//if(y1+heigh1>y2+height2)
- JL _case3
- mov raspuns,2//adica r2 inclus in r1
- JMP _jos
- _case2:
- mov eax,[ecx+4]//eax=y2
- mov edx,[ebx+4]//edx=y1
- CMP eax,edx//if(y2<y1)
- JG _case3// x2<x1 si y1<y2 => nimic nu e inclus
- mov edx,[ecx]//edx=x2
- add edx,[ecx+8]//edx=x2+width2
- mov eax,[ebx]
- add eax,[ebx+8]
- cmp edx,eax//if(x2+width2>x1+width1)
- JL _case3
- mov edx,[ecx+4]//edx=y2
- add edx,[ecx+12]//edx=y2+height2
- mov eax,[ebx+4]
- add eax,[ebx+12]
- CMP edx,eax//if(y2+height2>y1+height1)
- JL _case3
- mov raspuns,2 //adica r1 inclus in r2
- JMP _jos
- _case3:
- mov raspuns,0//niciunul nu e inclus
- _jos:
- }
- cout << raspuns;
- }
- int main()
- {
- rect r1,r2;
- cin >> r1.x>>r1.y>>r1.width>>r1.height;
- cin >> r2.x >> r2.y >> r2.width >> r2.height;
- _asm {
- lea ebx,r1
- push ebx
- lea ebx,r2
- push ebx
- CALL f
- add esp,8
- }
- return 0;
- }
- // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
- // Debug program: F5 or Debug > Start Debugging menu
- // Tips for Getting Started:
- // 1. Use the Solution Explorer window to add/manage files
- // 2. Use the Team Explorer window to connect to source control
- // 3. Use the Output window to see build output and other messages
- // 4. Use the Error List window to view errors
- // 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
- // 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