CPU implementation

The basic CPU implementation. Efficiency is not checked here.