#include <iostream>
#include <stdio.h>
#include <cstdlib>
int main()
{
signed short int a, b, c, d, e, f, res_c, res_asm, res_asm1, res_asm2;
printf("(4*c-d/2+23-e)/(b+a*a-1+f)\n");
printf("Enter the values of the range [-32768...32767]\n");
printf("a = "); scanf_s("%d", &a);
printf("b = "); scanf_s("%d", &b);
printf("c = "); scanf_s("%d", &c);
printf("d = "); scanf_s("%d", &d);
printf("e = "); scanf_s("%d", &e);
printf("f = "); scanf_s("%d", &f);
res_c = (4 * c - d / 2 + 23 - e) / (b + a * a - 1 + f);
printf("Result C = %d\n", res_c);
__asm
{
// (4*c-d/2+23-e)/(b+a*a-1+f)
mov ax, 4; // <al> = 4
cwd;
mov bx, c; // <bl> = c
imul bx; // <bl> = 4*c
mov bx, 1; // <bl> = 1
idiv bx; // <al> = 4*c
mov bx, ax; // <bl> = 4*c
mov ax, d; // <al> = d
cwd; //<ax> = d
mov dx, 2; // <dl> = 2
idiv dx; // <al> = d/2
mov dx, ax; // <dl> = d/2
sub bx, dx; // <bl> = 4*c-d/2
add bx, 23; // <bl> = 4*c-d/2+23
sub bx, e; // <bl> = 4*c-d/2+23-e
mov ax, a; // <al> = a
cwd; // <ax> = a
imul a; // <al> = a*a
mov cx, b; // <cl> = b
add cx, ax; // <cl> = b+a*a
dec cx; // <cl> = b+a*a-1
add cx, f; // <cl> = b+a*a-1+f
mov ax, bx;
idiv cx; // <bl> = (4*c-d/2+23-e)/(b+a*a-1+f)
mov res_asm, ax; // <res_asm> = (4*c-d/2+23-e)/(b+a*a-1+f)
}
printf("Result ASM = %d\n", res_asm);
printf("\n");
system("Pause");
return 0;
}