I have 2 C++ code:
Code 1: Reduce assign variable
if(health < healthMax) health = healthMax;
health = healthMax;
No. The assignment will hopefully compile to a move between registers, which is cheaper than a conditional branch.
health is a global, you might want to manually sink the store to the global out of the loop, but even a store on every iteration isn't too bad. Repeated stores to the same memory location are cheap, because they will hit in L1 cache. You can expect a throughput of ~1 per clock, without hogging memory bandwidth for other cores.
Since you tagged this as
assembly, see the x86 tag wiki for links to performance details for that platform, especially Agner Fog's stuff. A lot of the concepts are similar for other architectures.