10

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.

4

5 回答 5

15

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.

于 2012-10-23T00:10:51.063 回答
6

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.

于 2012-10-22T23:33:57.063 回答
3

Yes you can do assembly programming within a virtual machine, and you will be limited to the instruction set exposed by the virtual machine. If you do a 32 bit machine within a 64 bit host environment, you will only see the 32 bit instructions.

For what it's worth, assembly programming is not "unsafe" to do in your host environment, so there's not really any need to use a VM unless you are looking to emulate different hardware altogether, or are looking to write things like bootloaders and tiny operating systems.

For just learning assembly though, I certainly wouldn't start off writing bootloaders / operating systems, as you wont have access to debuggers and test cycles will be long. Start off with http://www.nasm.us/ to learn x86/x86-64 assembly, or look into http://wiki.qemu.org/Main_Page for doing things like ARM programming.

于 2012-10-22T23:34:08.540 回答
0

try Marss86

MARSSx86 (MARSS for short) is a tool for cycle accurate full system simulation of the x86-64 architecture, specifically multicore implementations. Our goal is to create a simple yet efficient full system architectural simulation environment based on existing tools.

于 2013-10-27T13:36:33.503 回答
0

If you are trying to learn assembly language with respect to Arm architecture then my suggestion is learn basics from below sites .Here in these it explain how to use qemu w.r.t assembly and its best place to start

http://www.bravegnu.org/gnu-eprog/index.html#intro

also http://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/

so from above site u can try on virtual machine like qemu without need of real hardware

于 2013-10-27T14:10:39.760 回答