I\'ve been bashing my head against the wall for over an hour and I can\'t understand why the below doesn\'t work.
If I change b: db 1 to b: db 0 then i
You've declared b as a byte:
b: db 1
but you load it as a dword:
mov eax, dword [b]
This explains why the zero flag is unset even when b is 0: because it's loading the next 3 bytes as well.
Just change your declaration:
b: dd 1
Alternatively, you could load a byte with zero extension: movzx eax, byte [b]
Similarly, you load a qword from z but you only defined it as a dd dword. See Which variable size to use (db, dw, dd) with x86 assembly?
Also, use default rel so all addressing modes pick RIP-relative addressing without having to say [rel b] everywhere.