I have a bit of a dilemma regarding the scenarios in which ZF is being set in NASM.
As far as I know, it's supposed to be set to 1 whenever the result of an arithmetic operation is 0, and it's being set to 0 otherwise. I saw that this does apply for ADD / SUB instructions, but it does not apply for DIV / MUL and their signed correspondents.
This is a bit of code that shows this.
bits 32
global start
extern exit
import exit msvcrt.dll
segment data use32 class=data
segment code use32 class=code
start:
mov ax, 128
sar al, 7
; AL is now -1 signed, AH = 0
imul ah
; AX = 0, however ZF is also 0
push dword 0
call [exit]
After googling for a few minutes, I have found on some course from a university's page that in the case of DIV / MUL instructions, the ZF is undefined.
Is this true, and if it is, why does this happen, even though after an operation whose result is 0, the ZF is not being set?