Answer the question
In order to leave comments, you need to log in
What does cwb do and will the program calculate the expression correctly?
Good day.
The task is very trivial: calculation of the expression (22 / c + 3 * b)
, where c, b - are entered from the keyboard.
There are two files - crosses and asm. Since it will be easier to type numbers in C++ from the keyboard, in the second file I simply get these variables using extern. But this is not so important for the context of this problem.
I will omit the code of the first file, all you need to know in the context of this question is that numbers are entered and exported to the asm file.
Here is the ASM code:
MODEL Large, C
.data
Extrn b:byte, c:byte, numerator:word ; numenator - результат
.code
Public Delim
Delim proc far
; Подсчёт выражения
mov al, 3
imul b
; al = 3 * b
mov bx, ax
mov ax, 22
idiv c
; должно быть ax = 22 / c
cbw ;?
add bx, ax
mov ax, bx
; ax =22/c + 3*b
cbw ; Что делает этот мнемоник?
mov word ptr numenator, ax
mov word ptr numenator + 2, dx
ret
Delim endp
end
mov bx, ax
mov ax, 22
idiv c
; ax = 22 / c
Answer the question
In order to leave comments, you need to log in
At first everything is correct:
- placed in AL 3 and multiplied by b, the result is in AX;
- recorded it in BX;
- placed in AX 22, divided by c, the quotient came out in AL;
- expanded the sign with pom. cbw, result in AX;
- added BX ( 3 * b) and AX (22 / s), and then wrote down in AX.
But then, instead of the second cbw, it was necessary to write cwd - to expand the AX sign to DX.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question