Добавил:
cfe_o
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:3 / lab_3
.txt
#include <iostream>
int main()
{
short a;
short b;
short c;
short d;
std::cout << "chislo a ";
std::cin >> a;
std::cout << "chislo b ";
std::cin >> b;
std::cout << "chislo c ";
std::cin >> c;
std::cout << "chislo d ";
std::cin >> d;
short Summa = a + b;
std::cout << "A + B = " << Summa << std::endl;
short SummaAsm;
_asm {
mov ax, a;
add ax, b;
mov SummaAsm, AX;
}
std::cout << "ASM A + B = " << SummaAsm << std::endl;
short Raznost = a - b;
std::cout << "A - B = " << Raznost << std::endl;
short Raz;
_asm {
mov ax, a;
sub ax, b;
mov raz, ax;
}
std::cout << "ASM A - B = " << Raz << std::endl;
short SumRaz = a + b - c;
std::cout << "A + B - C = " << SumRaz << std::endl;
short SumRazAsm;
_asm {
mov ax, a;
add ax, b;
sub ax, c;
mov SumRazAsm, ax;
}
std::cout << "ASM A + B - C = " << SumRazAsm << std::endl;
short Proiz1 = (a + b) * (c + a);
std::cout << "(A + B)*(C + A) = " << Proiz1 << std::endl;
short Proiz1Asm;
_asm {
mov ax, a;
mov bx, c;
add ax, b;
add bx, a;
mul bx;
mov Proiz1Asm, ax;
}
std::cout << "ASM (A + B)*(C + A) = " << Proiz1Asm << std::endl;
short Proiz2 = (a + b + c) * (c - a + b);
std::cout << "(A + B + C)*(C - A + B) = " << Proiz2 << std::endl;
short Proiz2Asm;
_asm {
mov ax, a;
mov bx, c;
add ax, b;
add ax, c;
sub bx, a;
add bx, b;
mul bx;
mov Proiz2Asm, ax;
}
std::cout << "ASM (A + B + C)*(C - A + B) = " << Proiz2Asm << std::endl;
short StepenC = pow(c, 4);
short Proiz3 = (a + b) * StepenC;
std::cout << "(A + B) * C**4 = " << Proiz3 << std::endl;
short Proiz3Asm;
_asm {
mov ax, c;
mov bx, AX;
mul bx;
mul bx;
mul bx;
mov cx, a;
add cx, b;
mul cx;
mov Proiz3Asm, ax;
}
std::cout << "ASM (A + B) * C**4 = " << Proiz3Asm << std::endl;
short Proiz4 = ((a + b) * c - (d + c) * b) * a;
std::cout << "((A + B)*C - (D + C)*B)*A = " << Proiz4 << std::endl;
short Proiz4Asm;
_asm {
mov ax, a;
add ax, b;
mul c;
mov bx, ax;
mov ax, d;
add ax, c;
mul b;
mov cx, ax;
sub bx, cx;
mov ax, bx;
mul a;
mov Proiz4Asm, ax;
}
std::cout << "ASM ((A + B)*C - (D + C)*B)*A = " << Proiz4Asm << std::endl;
short Proiz5 = (((a - c) * b + d) * a - c) * b;
std::cout << "(((A - C)*B + D)*A - C)*B = " << Proiz5 << std::endl;
short Proiz5Asm;
_asm {
sub AX, c;
mul b;
add AX, d;
mul a;
sub AX, c;
mul b;
mov Proiz5Asm, AX;
}
std::cout << "ASM (((A - C)*B + D)*A - C)*B = " << Proiz5Asm << std::endl;
short OperAND = a & b;
std::cout << "A and B = " << OperAND << std::endl;
short OperANDasm;
_asm {
mov ax, a;
mov bx, b;
and ax, bx;
mov OperANDasm, ax;
}
std::cout << "(ASM) A and B = " << OperANDasm << std::endl;
short OperOR = a | b;
std::cout << "A or B = " << OperOR << std::endl;
short OperORasm;
_asm {
mov ax, a;
mov bx, b;
or ax, bx;
mov OperORasm, ax;
}
std::cout << "(ASM) A or B = " << OperORasm << std::endl;
short OperNOT = ~a;
std::cout << "not A = " << OperNOT << std::endl;
short OperNOTasm;
_asm {
mov ax, a;
not ax;
mov OperNOTasm, ax;
}
std::cout << "(ASM) not A = " << OperNOT << std::endl;
short OperXOR = a ^ b;
std::cout << "A xor B = " << OperXOR << std::endl;
short OperXORasm;
_asm {
mov ax, a;
mov bx, b;
xor ax, bx;
mov OperXORasm, ax;
}
std::cout << "(ASM) A xor B = " << OperXORasm << std::endl;
}
Соседние файлы в папке 3