I have to finish a college assignment and I'm having issues with one particular assertion on an unit test. Essentially the exercise is to check if number A is multiple of number B in Assembly x86 (1 if yes, 0 if no). I have every test passing with the exception of one where both numbers are negative.
What I have in Assembly is:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
movl A(%rip), %eax
js isDividendLessThanZero
movl B(%rip), %ecx
js isDivisorLessThanZero
cmpl $0, %ecx
je isZero
xor %edx, %edx
idivl %ecx
cmpl $0, %edx
jne isZero
movl $1, %eax
jmp end
isZero:
movl $0, %eax
isDivisorLessThanZero:
neg %ecx
isDividendLessThanZero:
neg %eax
end:
popq %rbx
movq %rbp, %rsp
popq %rbp
```
I have added the 2 last conditional blocks to negate the divisor and/or the dividend if they/re negative, but it's not having any effect. Could you please tell me what I'm doing wrong? Thanks!