The sub command sets the flags ( OF , SF , ZF , AF , PF and CF , according to the documentation ) - the mov instruction is not. jz will only jump if the zero flag ( ZF ) is set, so if you want to switch to a value in eax , this flag must be set accordingly.
source share