Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a virtual machine to learn assembly

Tags:

assembly

I'm in the planning phases to learn assembly language and would like to take a start with x86 assembly but have computers around me with 64-bit processors (i7, i5 and a Core 2 Duo) and operating systems. Since I use my existing machines for work and don't want to things to go wrong while learning/practicing, I've been planning to buy or build a cheap 32-bit system using some old hardware that I may find. But before that, I'm wondering if it is possible to use a virtual machine for the same purpose. Would the machine instructions that are executed only be limited to virtual machine or would they be interacting with the virtual machine's host (i.e. my computer itself)?

I've looked around to see if someone has already tried such a thing, but seems like nobody has - so, my apologies if my question is naive as I don't know anything at all about assembly yet. But would be great if someone can shed some light on this subject and offer some pointers for people like me who want to learn assembly in a safe and isolated environment.

like image 912
Zishan Neno Avatar asked Oct 22 '12 23:10

Zishan Neno


2 Answers

I strongly suggest:

1) use an instruction set simulator (on par with what you are asking). much better visibility and a better chance at success, less frustration, less chance at giving up.

2) do NOT learn x86 assembly first. (having the hardware is a bad excuse for learning x86 first). very bad architecture, learn a good architecture first then if you bother to learn x86 learn it later and then learn 8088/86 first using one of the many simulators/emulators.

3) learn a few instruction sets, if you start with a good one, then all other instruction sets and even programming languages are a small matter of syntax.

4) you are not learning system calls that is a bad way to learn assembly, learn the instruction set and how to program with it, system calls is after you have learned the assembly and choose to continue to program applications in it.

msp430 (or pdp11/lsi11), arm, thumb, avr, mico8, and a list of others are much better. save mips for after you have learned a few as well, it has uncommon features that can put you in the wrong mindset for other architectures.

if your programming skills are strong already then you can pick up assembly in a matter of days and have a few to many instruction sets in a matter of weeks. If you follow this guide and learn a few unrelated (to each other)(good) instruction sets, then start to look at x86 you will see exactly why I am recommending learning it last or never. Like 6502 and pic and some others it has historic educational value, but due to the nature of the history of the family you cant get much out of it from a tuning/programming perspective. Actually I recommend reading The Zen of Assembly, and remember even when written it was about how to think about performance coding in general, not about 8088/86 performance tuning.

A good way to really learn assembly is by writing a disassembler, problem is that most instruction sets are variable word length and variable word length disassemblers are an advanced programming problem. ARM and thumb (not thumb2) are fixed word length and very easy to write disassemblers for.

like image 52
old_timer Avatar answered Oct 04 '22 04:10

old_timer


Start by using qemu. It's a lightweight VM that you can run programs (raw assembly, c, c++, etc) on without even installing an OS on it.

like image 40
JosephH Avatar answered Oct 04 '22 04:10

JosephH