Moved encoding functions to the register/memory classes