Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CPP:
- #include <iostream>
- using namespace std;
- extern "C" bool check(int x1, int x2, int x3, int x4);
- int main()
- {
- int x1, x2, x3, x4;
- cout << "Введите (x1, x2): ";
- cin >> x1 >> x2;
- cout << "Введите (x3, x4): ";
- cin >> x3 >> x4;
- cout << check(x1, x2, x3, x4) << endl;
- return 0;
- }
- ASM:
- [section .text]
- global check
- check:
- mov eax, [esp+4] ; arg1=x1
- mov ebx, [esp+8] ; arg2=x2
- ; eax = abs(x1-x3)
- sub eax, [esp+12] ; arg3=x3
- abs_eax:
- neg eax
- js abs_eax ; goto abs_eax if SF=1 (eax < 0)
- ; ebx = abs(x2-x4)
- sub ebx, [esp+16] ; arg4=x4
- abs_ebx:
- neg ebx
- js abs_ebx ; goto abs_eax if SF=1 (ebx < 0)
- ; if(eax == 2)
- cmp eax, 2
- je if_x1_sub_x3_eq_2
- ; if(eax == 3)
- cmp eax, 3
- je if_x1_sub_x3_eq_3
- jmp not_bitten
- if_x1_sub_x3_eq_2:
- cmp ebx, 3
- je bitten ; if(ecx == 3)
- jmp not_bitten
- if_x1_sub_x3_eq_3:
- cmp ebx, 2
- je bitten ; if(ecx == 2)
- jmp not_bitten
- bitten:
- mov eax, 1
- ret
- not_bitten:
- mov eax, 0
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement