Well you could break up you main into a few functions, like

- loadProgramIntoMemory
- executeProgramInMemory

You can test the second one quite easily just by manually adding a few instructions...