Add WriteRegister function

Not sure if we really need to implement it by ourselves