- Wait - do noting
- Pop - discard the top item on the stack
- Execute - take the top item from the stack add it to the current location, then carry on executing from the new location.
- Stop - stop executing
- Copy - take the top 3 items from the stack, the first is the relative address behind the current location to start copying from, the 2nd is the location ahead of the current location to start copying to, and the 3rd is the number of cells to copy.
A few years ago I was playing around with the KDE desktop and found the "Virtual Machine" screensaver.
At first I was puzzled by its screen full of apparently random coloured numbers and a letters, but after it was left to run for some time, something weird happened - the random numbers and letters started forming repeating patterns.
After reading the source code I realised that the letters where instructions for a very simple stack based computer, and the numbers were data. The screen represented the memory of the computer, the numbers data, and the letters instructions.
Over a long period of time some of the memory locations would end up containing a self-replicating program, and that program (or programs) would then have many copies of them made and they would slowly take over the screen.
If the stack has more than 15 items on it, stop running. If the stack is empty when trying to pop a value from it, stop running. Stop executing after 1000 instructions have been run.
When running stops, start running from a random location with an empty stack and the instruction count set to zero.
This machine is similar (identical?) to the 'Core Wars' virtual machine.
Clicky here to see the system running. Code is here