> because assembly doesn’t have boolean.
What is flags register file for then? Zero flag, carry, overflow, etc? They sure look booleans to me. Sometimes assembler routines pass booleans in carry flag.
They're actually Boolean types created by a bitfield mapping of an integer.
If, in addition, you want implicit conversion from integers to booleans, you have to pick some patterns as meaning ‘false’.
The first is fairly normal in low-level languages. So, the question is why one would want implicit conversion from integer to boolean. The main reasons I can think of are
- because assembly doesn’t have boolean.
- to keep source code shorter.
For C, I think it was a combination of both. Testing for null pointers using if(p) is nicely short. From there, given that there’s little or no difference between pointers and integers at register level, it is a short step to if(i) for integer i.