The following pages link to Programming:Source code to show that when a port is read in output mode; the data read will be ANDed with the inputs to that port: