Some registers are write only and do not return the value that was written. They are latches. You are best as said elsewhere keeping a local variable as to what has been written and modifiying that before writing to a port. The example I gave works for writing to a Port and reading from a memory location.