Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void func1();
- void func2();
- void func3();
- int main()
- {
- int choice;
- cout << "Choose task: ";
- cin >> choice;
- if (choice == 1)
- {
- func1();
- }
- else if (choice == 2)
- {
- func2();
- }
- else if (choice == 3)
- {
- func3();
- }
- system("pause");
- return 0;
- }
- void func1()
- {
- short int a, b, res;
- cout << "Type a: ";
- cin >> a;
- cout << "Type b: ";
- cin >> b;
- _asm {
- mov ax, a
- mov bx, b
- cmp ax, bx
- je eql_
- jl le_
- mov cx, ax
- imul cx
- imul cx
- sub ax, 5
- cdq
- idiv bx
- mov res, ax
- jmp end_
- le_ :
- add ax, 1
- mov cx, ax
- mov ax, bx
- cdq
- idiv cx
- mov res, ax
- jmp end_
- eql_ :
- mov ax, 4
- mov res, ax
- end_ :
- }
- cout << "Result: " << res << endl;
- }
- void func2()
- {
- cout << "Type number: ";
- int t;
- cin >> t;
- int quan = 0;
- __asm
- {
- mov eax, t
- mov ebx, 10
- beg:
- cmp eax, 0
- je end_
- jg gr
- sub ebx, 0
- jmp beg
- gr :
- cdq
- idiv ebx
- add quan, 1
- jmp beg
- end_ :
- mov eax, t
- cmp eax, 0
- jz null_
- jmp endl_
- null_ :
- add quan, 1
- endl_ :
- }
- cout << "Quantity of numbers: " << quan << endl;
- }
- void func3()
- {
- int t;
- cout << "Type number: ";
- cin >> t;
- int quan1 = 1, modul, power = 0, res = 0;
- __asm
- {
- mov eax, t
- mov ecx, eax
- mov ebx, 0
- loop1:
- mov eax, ecx
- cmp eax, 0
- jne zero1
- jmp end2
- zero1 :
- and eax, 1
- shr ecx, 1
- cmp eax, 1
- je equal1
- jmp loop1
- equal1 :
- inc ebx
- jmp loop1
- end2 :
- mov res, ebx
- }
- cout << "Result: " << res << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement