How could we assign a value that can be stored in memory and represent the state of the pin itself. (0 or 1)


but at the same time to not read the actual pin, but the value that is stored in memory.
simple, to read the value assigned to pins designated as output read latx its value is always what you last set it to
the latx value of pins set as input is meaningless in regards to actual pin logic level

to read the actual pin logic levels at a point in time read portx , its always the actual pin value at read time

pin and latx values are not necessarily equal at a point in time, pins set as output are subject to real world physical constraints dictated by the load impedance they are driving