Live data from Hacker News

A fundamental introduction to x86 assembly programming

nayuki.io

21–30 of 78 posts

Re: A fundamental introduction to x86 assembly programming

#21
post #13
post #10

Earlier quoted context omitted.

Seconding this. Is there even any advanced x86_64 assembly language material out there besides the AMD and Intel reference manuals?

Probably no. I think when you reach some level of understanding, you'll use manuals. Then you know what you're looking for. :)

And once you start reading the docs on the more efficient but far less consistent 64-bit calling convention, you may find yourself choosing words to describe it other than the "improved" that this author opted for.

Re: A fundamental introduction to x86 assembly programming

#22
post #9

Is there something like SPARC or other RISC architectures?

Yes there are... I wouldn't recommend starting with SPARC Asm though, it's nowhere near as fun as a CISC like x86, nor as easy as MIPS (which tends to be the "boring" go-to architecture CS courses use.) ARM is more interesting than MIPS and easier than x86.

What do you mean by ARM being more interesting than MIPS?

Re: A fundamental introduction to x86 assembly programming

#23

This is a nice fundamental introduction, but where would I go to see how to actually run code?

My best introduction to any asm language is just my C compiler putting out asm (gcc -S, I think). I can create small programs to do what I want, and see what the compiler puts out.

https://gcc.godbolt.org is also helpful, it colorizes the assembly output corresponding to the C/C++ source. Furthermore, you can simply change between Intel and AT&T synatx.

Re: A fundamental introduction to x86 assembly programming

#24
post #10

Am I the only one who feels the "intro to x86" market is oversaturated?

Seconding this. Is there even any advanced x86_64 assembly language material out there besides the AMD and Intel reference manuals?

It's somewhat analogous to how we went from 16 bit registers to 32 bit registers with the extended opcode variants, so if you understand x86, x86_64 isn't really much of a stretch.

Re: A fundamental introduction to x86 assembly programming

#25
If you want to learn x86 assembly, I recommend one of my favorite books Programming From The Ground Up:

http://savannah.nongnu.org/projects/pgubook/ (free pdf!)

This is a practical book and teaches assembly programming on Linux.

Author Jonathan Bartlett wrote this book because he was frustrated to no end with the existing books. At the end of them he could still ask, "How does the computer really work?" and not have a good answer. Jonathan's goal is to take you from knowing nothing about programming to understanding how to think, write, and learn like a programmer. You won't know everything, but you will have a background for how everything fits together.

Fun story: I remember how I went through this book in 2004, a day before a job interview, and I exactly got asked a question about how C functions get compiled to assembly, how the stack and memory management works. I got that job.

Re: A fundamental introduction to x86 assembly programming

#27
post #10

Earlier quoted context omitted.

Seconding this. Is there even any advanced x86_64 assembly language material out there besides the AMD and Intel reference manuals?

It's somewhat analogous to how we went from 16 bit registers to 32 bit registers with the extended opcode variants, so if you understand x86, x86_64 isn't really much of a stretch.

I only have a vague understanding of assembly in general, and x86_64 in general - but I thought that with so many more registers, the recommended style of programming can change quite a bit (hence aggressive use of registers for passing arguments to function calls in the x86_64 C ABIs)?

Re: A fundamental introduction to x86 assembly programming

#29
post #27

Earlier quoted context omitted.

It's somewhat analogous to how we went from 16 bit registers to 32 bit registers with the extended opcode variants, so if you understand x86, x86_64 isn't really much of a stretch.

I only have a vague understanding of assembly in general, and x86_64 in general - but I thought that with so many more registers, the recommended style of programming can change quite a bit (hence aggressive use of registers for passing arguments to function calls in the x86_64 C ABIs)?

That's less of an assembly issue and more of a compiler/calling convention issue. Assembly allows you to pass parameters on the stack or in registers. Calling conventions simply define a protocol for doing this consistently.

Re: A fundamental introduction to x86 assembly programming

#30
post #9

Is there something like SPARC or other RISC architectures?

Yes, The SPARC architecture manual. Punch that into Google or DuckDuckGo and it should be the second link (you want the SPARC V9 instruction set architecture). I would post the link I found, but since I actually have the physical book, I'm uncertain as to whether posting a link to a PDF of a possibly copyrighted book would get me in trouble with Hacker News or not.

I've done some SPARC assembler programming for fun, and for someone with 6502 / MC680x0 assembler background, SPARC has a really exotic assembler (register windows and synthetic instructions, most notably). It also illustrates just how complex and powerful the Scalable Processor ARCitecture is; for a RISC CPU, it has loads and loads of advanced features all designed for high performance, which leads me to think that the existing compilers generating SPARC code must be crap, since some of the SPARC processors (notably UltraSPARC II, UltraSPARC III, and UltraSPARC T1) are generally known to be slow when it comes to non-parallelized, number crunching performance. The design of the SPARC processors and their assembler is in direct opposition to that.

Post reply on HN