Page 1 of 1

Books for learning to program a platfiorm virtual machine

Posted: Wed Jul 31, 2013 9:39 pm
by zeitue
Are there any good books, Ebooks, or tutorials for learning how to code a platform virtual machine?
I've checked the Wiki site and there is no information on there about virtual machines.
I'm trying to make my virtual CPU platform, so I'm looking for some books to asist me.
Thanks in advance :D

Re: Books for learning to program a platfiorm virtual machin

Posted: Thu Aug 01, 2013 1:02 am
by Combuster
An emulator is just an implementation of a well specified but severely intricate specification. You need little more than all the basic programming rules for a complex system to pull off this job.

Re: Books for learning to program a platfiorm virtual machin

Posted: Thu Aug 01, 2013 1:50 am
by iansjack
But a virtual machine is not necessarily an emulator of an existing CPU. The Java VM, the .NET framework, SmallTalk VMs all implement hypothetical processors.

Anything describing the internals of those examples would probably help; alternatively study the manuals for various processors, or any general books about computer architecture, to discover what facilities you might want to implement in your hypothetical one.

Re: Books for learning to program a platfiorm virtual machin

Posted: Thu Aug 01, 2013 4:27 am
by Combuster
Slightly offtopic, but probably relevant for the bigger picture: upcoming lecture on the subject - Should get recorded, maybe even livestreamed.

Re: Books for learning to program a platfiorm virtual machin

Posted: Thu Aug 01, 2013 3:12 pm
by zeitue
Combuster wrote:An emulator is just an implementation of a well specified but severely intricate specification. You need little more than all the basic programming rules for a complex system to pull off this job.
I managed to write a simple 4 register virtual machine but I was hoping you more information on things like CPU, I/O devices, FPU?, Memory coding for the VM.
I assume that virtual machines are a lot different from my work on operating systems.
I was also wondering things like if I should map my virtual registers to the host's registers?

Re: Books for learning to program a platfiorm virtual machin

Posted: Fri Aug 02, 2013 4:25 pm
by Rew
Virtual machines have essentially 3 options:
- Hardware virtualization
- Software virtualization
- Emulation

Both hardware and software virtualization run native code, thus they require the guest and host architecture to be compatible. With the tools that have been provided by amd and intel, x86 software virtualization doesn't really make sense anymore. That being said, I think what you are looking for is information on emulators.


I actually recently read a decent write-up on high level emulator design. The first answer in this thread: http://stackoverflow.com/questions/4486 ... ey-written has some good information.

Emulator optimization techniques vary greatly depending on your approach. Essentially, you are looking for more information on either interpreting or recompiling.

In my opinion, writing an effective interpreting emulator would start with understanding the pipeline of the guest OS and coming up with a design that will simulate that pipeline the best. You will probably end up with a block diagram similar to doing a google image search for intel or amd processors with named architectures.

Re: Books for learning to program a platfiorm virtual machin

Posted: Sun Aug 04, 2013 4:13 pm
by zeitue
Rew wrote:Virtual machines have essentially 3 options:
- Hardware virtualization
- Software virtualization
- Emulation

Both hardware and software virtualization run native code, thus they require the guest and host architecture to be compatible. With the tools that have been provided by amd and intel, x86 software virtualization doesn't really make sense anymore. That being said, I think what you are looking for is information on emulators.


I actually recently read a decent write-up on high level emulator design. The first answer in this thread: http://stackoverflow.com/questions/4486 ... ey-written has some good information.

Emulator optimization techniques vary greatly depending on your approach. Essentially, you are looking for more information on either interpreting or recompiling.

In my opinion, writing an effective interpreting emulator would start with understanding the pipeline of the guest OS and coming up with a design that will simulate that pipeline the best. You will probably end up with a block diagram similar to doing a google image search for intel or amd processors with named architectures.
I think really what I'm looking for is emulation, perhaps JIT as well. I'm intending to make my own virtual CPU architecture.

Thanks for the reply and the information if this was Stackoverflow I'd upvote that.