I'm working on a simple bytecode interpreter to learn how virtual machines work. I've read about VMs and it seems that all of them are either stack based or register based. At the time it made sense, but then I started working on my interpreter and realized what am I doing? (I decided on a register machine.) I'm just loading all these values from pointers into these fake registers, doing operations, then putting the result back into the register and copying to a pointer. I thought, why not just do this directly? Why create fake registers that just serve as an overhead. Maybe I don't know enough about VMs yet to fully understand, but it would seem to me like my way would be much faster.
Why does a bytecode VM use stack or registers opposed to direct operations?
virtual machine;interpreters;bytecode