I´m looking forward to learn an assembly language.

I searched web for the tutorial and found different tutorials with different syntax of assembly.

There is any difference between 8086 assembler, nasm and gcc?

What is the better way to learn code with in assembly language?

thanks.

有帮助吗?

解决方案

Basically there are two flavours on the x86 chipset which is AT&T or the Intel snytax. Most people I know prefer the Intel syntax because it is much easier to understand, but of course this is also a matter of getting used to. When I learned assembly on 6510 or M68000 I found the AT&T syntax closer related, it is rather confusing with it's adressing modes IMO.

If you instruct gcc to write the assembly sourcefile it uses AT&T syntax by default, but you can switch that to Intel as well using

gcc -S -masm=intel test.c

nasm is an assembler and gcc is a compiler so they have quite different purposes.

As for learning assembly there are lots of tutorials, for example The Art of Assembly. But if you really want to learn it, IMO the best way is to start debug and enter some instructions and see what they are doing and how they change reigsters and flags, writing small loops first.

This way you can focus on the instructions and not fight with the assembler source syntax as well.

其他提示

I wouldnt start with x86, not a good first instruction set even if you have the hardware. ARM, msp430, avr, and some others are better and have open source simulators where you can get better visibility. I would start small, simply adding or anding a few numbers, write a memory location, read it back, that kind if thing. The simulators (can) prevent you from needing to make system calls to "see" your results, likewise they can definitely help you work through hangs and crashes, which you will get and which IMO leads to giving up on the whole thing. Once you know more, you can switch to hardware or try another instruction set (each new one gets exponentially easier than the prior) leading to x86 if you by then still feel there is a need...With x86 I recommend going back to the early days, find an 8088/86 simulator, learn the original instruction set, then if you still feel the need, then skip to 80386 and newer. You will also need to be able to switch formats in your head, gnu using AT&T was a cardinal sin (gnu assembler folks commit these sins regularly BTW, it is almost expected), but unfortunately we now have these two competing formats. With practice you should easily be able to tell what format is being used on inspection of code, but mentally switching back and forth may still be a challenge.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top