Answer the question
In order to leave comments, you need to log in
What is the correct way to use imul signed multiplication?
The task is to multiply 2 numbers.
When there are positive numbers in the tests, everything works with mul.
And when there was a negative answer does not converge.
How can I fix the code so that unsigned numbers work too?
Test:
int multiply(int, int);
Test(multiply, should_correctly_multiply_3_and_5_to_give_15) {
cr_assert_eq(multiply(3, 5), 15);
}
global multiply
section .text
multiply:
mov ax, si
mov cx, di
imul cx
ret
The expression (multiply(-3, 5)) == (-15) is false.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question