Move memory code into new file and add memory mapped register base.