Books for learning to program a platfiorm virtual machine

Programming, for all ages and all languages.
Post Reply
User avatar
zeitue
Member
Member
Posts: 88
Joined: Fri Dec 14, 2012 6:05 pm
Libera.chat IRC: zeitue
Location: United States, Texas
Contact:

Books for learning to program a platfiorm virtual machine

Post 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
### Z++; && S++; ###
zeitue is pronounced zeɪtə
Web Site::Bit Bucket
Programming Languages: C, C++, Java, Ruby, Common Lisp, Clojure
Languages: English, zɪ̀ŋ, 日本語, maitraiuen
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Books for learning to program a platfiorm virtual machin

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Books for learning to program a platfiorm virtual machin

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Books for learning to program a platfiorm virtual machin

Post by Combuster »

Slightly offtopic, but probably relevant for the bigger picture: upcoming lecture on the subject - Should get recorded, maybe even livestreamed.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
zeitue
Member
Member
Posts: 88
Joined: Fri Dec 14, 2012 6:05 pm
Libera.chat IRC: zeitue
Location: United States, Texas
Contact:

Re: Books for learning to program a platfiorm virtual machin

Post 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?
### Z++; && S++; ###
zeitue is pronounced zeɪtə
Web Site::Bit Bucket
Programming Languages: C, C++, Java, Ruby, Common Lisp, Clojure
Languages: English, zɪ̀ŋ, 日本語, maitraiuen
Rew
Member
Member
Posts: 28
Joined: Mon Oct 29, 2012 2:26 pm

Re: Books for learning to program a platfiorm virtual machin

Post 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.
User avatar
zeitue
Member
Member
Posts: 88
Joined: Fri Dec 14, 2012 6:05 pm
Libera.chat IRC: zeitue
Location: United States, Texas
Contact:

Re: Books for learning to program a platfiorm virtual machin

Post 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.
### Z++; && S++; ###
zeitue is pronounced zeɪtə
Web Site::Bit Bucket
Programming Languages: C, C++, Java, Ruby, Common Lisp, Clojure
Languages: English, zɪ̀ŋ, 日本語, maitraiuen
Post Reply