Build a language from scratch -- simulator

Coordinator
Jun 17, 2015 at 6:52 PM
Edited Jun 17, 2015 at 7:26 PM
Simulator is not one of the must-have component to build a language. But as far as I can tell, it should be recommended. A simulator can help you to decide the memory model. Such as how to store data in memory, how to store constants in source code, how to refer an instruction location or data location.

Simulator itself is not so important, it's just the combination of a set of registers, memory. It accepts a series of instructions, and execute them. A common computer system may have both the series of instructions and other data all in the memory. But indeed the instructions should not change themselves at run-time <DEP & GPF ensure we should only execute instructions in code segment, and read-write data in other segments.>, which means instructions can be stored somewhere other than memory.

The simulator in my system works in such way, it has only a stack of byte-arrays. And accepts push / pop instructions to push a new data-array in the stack or pop a data-array from the stack.