Re: [Algorithms] virtual machine how to???
Brought to you by:
vexxed72
From: Kent Q. <ken...@co...> - 2002-04-10 13:41:40
|
How much time do you have? Having written a fast VM and robust compiler for our game, I= speak from experience when I say that what you're attempting isn't= easy, and will probably suck up lots more time and energy than it's= worth. Especially since these days there are several hundred freely available embeddable scripting languages on the net, at least a couple of which are good enough to use even in high-end= production systems. I strongly recommend you look into Python and Lua, at least,= before you go ahead with this plan. But if you really want the experience of writing a compiler and= VM, poke around the Java website for information on the Java VM.= There used to be a whilte paper on it up there that explained how it worked, and it was pretty educational. In general, most people writing a portable VM try not to tie it= to any particular machine architecture and want to simplify the implementation, so they tend to implement a stack machine= (instead of having registers that can be mapped to real-life CPU registers). You have to decide at what level you want your fundamental= operations to take place -- do you want to have a low-level VM that does= basic load/math/store level operations, or do you want to have it understand your memory architecture, object systems, and the like= so that the VM respects your data environment? Each has its= advantages and disadvantages. Whether you actually write the object format out to disk as an= object file, or just leave it in memory for the VM to execute, you definitely want to separate the compilation process from the code= generation process. In other words, compile to a parse tree and= then code-generate from the parse tree. You'll save yourself a lot of pain in debugging the VM if you= write an assembler for it and build it completely separately from the compiler. =09Kent -- Kent Quirk, ken...@co... on 4/10/2002 On Wed, 10 Apr 2002 14:20:13 +0800, Toong See Wan scribbled: >Hey all, > >I am building a scripting engine for my game base on Basic= language >, I have work out part of the compiler portion and now i am = stuck >at the VM portion . How czn i implement a VM is there any= resources? >can any one give me a lead? > >I havde tired google but nothing much came out > >thanks > > >seewan |