The instruction set reference says that the ZF is undefined for the imul instruction. So what happens to the ZF if I multiply a value in a register by an immediate value of 0x0?
Asked
Active
Viewed 152 times
0
-
Related: [How is the sign flag calculated with the imul instruction?](https://stackoverflow.com/q/29901622) - SF is undefined as well – Peter Cordes Aug 17 '22 at 19:57
1 Answers
2
Undefined means that result can be anything and none of the values matter anything.

Andrey
- 59,039
- 12
- 119
- 163
-
-
-
@Andrey: ZF is only a single bit, it's always either zero or 1. This is assembly language, not C undefined behaviour. `setz al` will produce 0 or 1. You just don't know which. `jz` will either go to the target or fall through, not jump somewhere else. (And yes, on at least some CPUs, for example Skylake, it actually will set ZF=0 even when both halves of the result are zero. Same if it's non-zero) – Peter Cordes Feb 09 '22 at 18:48