Answer the question
In order to leave comments, you need to log in
Why does division of div fail in assembler in C++?
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
int main()
{
setlocale(LC_ALL, "rus");
char b1 = 3, b2, b3 = 1 , res2; //1 байт el, bl, ah ]] cbw -> short
short w1= 1000, w2 = 500, w3 = 2; //2 байт ax, bx, cx, dx, cwde -> long
long d1 = 5000, res; //4 байт eax, ebx, ecx cbq -> дальше
printf("%d %d %d %d\n", w1, w2, w3, d1);
_asm{
// 1 2 3 8 7 4 6 5
//(w1 - w2) * w3 / b1 + b2 * ((d1 - w2) - (w3 + b3));
// 1 - (w1 - w2)
mov ax, w1
sub ax, w2
// 2 - (w1 - w2) * w3
imul ax, w3
// 3 - (w1 - w2) * w3 / b1
mov bl, b1
div bl
mov res2, al
}
printf("%d", res2);
return 0;
}
Answer the question
In order to leave comments, you need to log in
Why does division of div fail in assembler in C++?
char b1 = 3, b2, b3 = 1 , res2; //1 байт el, bl, ah ]] cbw -> short short w1= 1000, w2 = 500, w3 = 2; //(w1 - w2) * w3 / b1
div bl
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question