A quick introduction to x86 assembly for everyone
poincare101.herokuapp.com
poincare101.herokuapp.com
In a text editor, create a file called foo.cpp with the contents
void main(){int x,y=4;x=y;}
At a unix command prompt type
gcc foo.cpp
./a.out
That creates sort of a couple post it notes labeled x and y, with the number 4 on the y paper. Then it uses the equals sign (which is stupid because it doesn't compare anything, it copies numbers) to put what's on y onto the x paper.
Cool eh? Go Google "c++ keywords" for more you can do.
</sarc>
Many of the sentences here seem to contain incorrect original research or oversimplifications of the concepts required to understand assembly.
For example, "So, processors run something call opcode, which basically means binary. Of course, not all processors are the same, but, to preserve some measure of sanity, there's something called x86 which is a specification which gives some guidelines about opcode."
Additionally, Jumping to _start really isn't recursion in the sense of "calling a function from within itself," it's a jump to a named location in code- by the definition laid out in the article, loops are a form of recursion.
It's also a bit disingenuous to say that GAS (or AT&T syntax) is not meant to be written by developers, and that it was developed as a backend to GCC. While the latter may be true it does not necessarily reflect on the usability or accessibility of the language or the dialect.
x86 is a ridiculously complicated architecture with over 30 years of historical baggage -- it's very difficult for a beginner to tell what is relevant to modern x86 computers vs what was only relevant to x86 computers circa 1978. I'm talking about things like segmentation, real mode vs protected mode vs ..., the fact that there are multiple FPUs with different instruction sets (x87, SSE, etc.) and other instructions that reuse the registers (MMX)..., and let's not forget the 64-bit extensions either...
If someone would go and explain the history and design decisions of the x86 and summarize what's still relevant for e.g. user mode programming under Windows and Linux on computers released in the last 5 years, that would be really helpful to a lot of people trying to learn x86 assembly.
I'm sorry, but this is a terrible introduction to assembly. It incorrectly and inadequately explains what registers are, does not explain what's being done, and is 2 paragraphs long.
ld: i386 architecture of input file `first.o' is incompatible with i386:x86-64 output
What you want to do is type this instead: nasm -f elf64 first.s
On another note, the link to intel's "command listing" has horrible CSS. If you hover over it, it takes up more space, which moved it to the next line with my browser width, making it impossible to click.I wouldn't call "the thing processors run" opcode but machine code or something like that. Also, the usage of "procedure" in the context of assembly is a bit unusual.
It is a bit disappointing that the whole article is gathering some velocity, when the author hits the break for a full stop.
It's succinct at "only" 195 pages. People who are interested can use this to start and then read the Intel manuals when they need something that is not covered by the tutorial.
It would convert from c-style strings to actual numbers, do 32 bit addition on them, and then convert the number back to a c-style string before printing it to the screen.
For anyone getting started this may be worth a look, as I commented every single last line:
http://personal.x-istence.com/post/2008/02/03/addnumbersasm-...
(Do note, I also set up various stack frames, mainly so that I could do debugging of my assembly code in gdb)
Edit: This will only compile and run on FreeBSD and or Mac OS X due to the use of FreeBSD syscall numbers and calling convention by pushing parameters to the stack unlike Linux which wants stuff in register (see http://www.freebsd.org/doc/en/books/developers-handbook/x86-...)
Unfortunately the original domain seems to be offline for while.