Live data from Hacker News

Introduction to x64 Assembly

software.intel.com

61–70 of 78 posts

Re: Introduction to x64 Assembly

#61
post #10

Is there a good Windows assembler that doesn't get flagged by anti-virus software? UPDATE: I just ran across JWAsm and haven't encountered any problems so far. http://sourceforge.net/projects/jwasm/

FASM[1] is quite good, particularly its macro system, and the Windows version includes a minimal IDE. FASM and MenuetOS[2] are both written entirely in FASM.

[1]: http://flatassembler.net/

[2]: http://menuetos.net/

Re: Introduction to x64 Assembly

#63
post #8

I learned by working through the software developers' manuals. Many years ago, they used to ship them as physical copies. Nowadays they just send CDs. PDF copies: http://www.intel.com/content/www/us/en/processors/architectu...

When did they stop shipping physical copies? I ordered the new manuals for VT-x not 4 years ago and they were happy to ship me the full set of volumes for free.

I tried to order in january 2012 and they said back then that they replaced the free physical books with free CDs. Now it says:

Note: We are no longer offering the Intel® 64 and IA-32 Architectures Software Developer’s Manuals on CD-ROM. Hardcopy versions of the manual are available for purchase via a print-on-demand fulfillment model through a third-party vendor, Lulu (please reference 1 and 2 below): http://www.lulu.com/spotlight/IntelSDM.

Re: Introduction to x64 Assembly

#64
post #6
post #3

Intel keeps making up new names for their x86-64 architecture. Now 'x64' did they use that one before? Is IA-32e or EMT64 not better? Also if you want to find out quickly what they mean by 'x64', why is the article tagged with 'ia64' (which means Itanium).

- AMD64 -> Original x86 64bit extension from AMD. - EM64T (EMT64 is a common typo) -> Intel's implementation of AMD64, intel traded SSE3 to AMD for AMD64. - IA-32e -> Same as EM64T, Intel used this name for a bit, mostly during development. - INTEL64 -> Intel renamed EM64T to be more in line with AMD64's naming. - x86-64 -> Overarching instruction set, AMD64 and INTEL64 are implementations. - x64 -> Shorthand for x86…

Related is the term x32, which is an architecture (from the point of view of the Linux kernel) for x86-64 code designed to run in 0x86-64 32-bit mode.

Why would you do this? Given that you never use 4 GB of memory, you can save a few bytes of memory (32-bit pointers instead of 64-bit) while still getting the extra registers and operations of x86-64 code.

Re: Introduction to x64 Assembly

#65
post #45

"Intel stores bytes "little endian," meaning lower significant bytes are stored in lower memory addresses." I would like to meet the person that doesn't know what endianness is, but can still understand that explanation.

I agree that prose was not the right way to communicate this; BE & LE are much easier to explain via example (1 -> 00:00:00:01 or 01:00:00:00).

Except that now the reader has to understand what you mean with your xx:xx:xx:xx syntax. Having examples is good, but then you should provide a small graphic with boxes representing bytes in memory and associated numbers indicating memory addresses. And once you do that, you've actually just provided a visual illustration of exactly what the quote says: least significant byte at lowest memory address vs. highest memory address.

Re: Introduction to x64 Assembly

#66
post #36
post #35

Earlier quoted context omitted.

I always read mov x, y with coma being a synonym for equals, like mov x = y, hence it feels more natural to me. But the biggest issues are address modes, specially the more complex ones and the macros seem very light weight in features when compared to the Intel world.

I love this comment. It shows how powerful the right metaphor can be in understanding something, which is something we obsess over at Dev Bootcamp when teaching students. It also shows how tiny affordances ( http://en.wikipedia.org/wiki/Affordance ) make us "think" specific thoughts. I mean, it's called "mov" so something must be moving, which means there must be a subject, object, and possibly an indirect object, ri…

I see this more as a) an example of how well humans can learn to ignore misdirection (the word 'move' hints at src, dest arguments) and b) the first small step towards C:

- read "mov X,Y" as "X = Y"

- adjust syntax so that it allows "X = Y" (what you see is what you think)

- similarly, replace obscure syntax for indexed memory acces by such things as "X = Y[3]"

- getting annoyed with the seemingly random limitations of the language, add an expression parser that translates "X = 2 * Y + 3" into "X = 2 * Y" and "X = X + 3", each of which gets assembled into one instruction. For now, only allow expressions that get away with only using the result register for temporaries.

- use existing macro capabilities to build a library of control flow statements such as IF and WHILE.

- introduce standard way to call subroutines.

- introduce shorthand method for doing such calls: one for the call site that takes a couple of expressions as argument, and one for function entry that uses macros such as 'int' and 'char' to pop arguments from the call stack.

By that time, one almost has K&R C.

Re: Introduction to x64 Assembly

#67
post #7

That 3D "cross" graphic (Figure 1, "General Architecture") might be the worst illustration of a programmer's model for a CPU I've ever seen. I'm sure it makes sense after you've read the accompanying paragraph a sufficient number of times (once didn't cut it, for me), but not so sure it helps in that understanding. I guess it's a funny hint that the x86's architecture is complex, when a figure that's just trying to d…

I don't think thats the right graphic - a more reasonable graphic is in the PDF which the article is a copy of.

Something's going horribly wrong, I'm seeing a screenshot of code to read and parse CPUID.

Re: Introduction to x64 Assembly

#68
post #66
post #36

Earlier quoted context omitted.

I love this comment. It shows how powerful the right metaphor can be in understanding something, which is something we obsess over at Dev Bootcamp when teaching students. It also shows how tiny affordances ( http://en.wikipedia.org/wiki/Affordance ) make us "think" specific thoughts. I mean, it's called "mov" so something must be moving, which means there must be a subject, object, and possibly an indirect object, ri…

I see this more as a) an example of how well humans can learn to ignore misdirection (the word 'move' hints at src, dest arguments) and b) the first small step towards C: - read "mov X,Y" as "X = Y" - adjust syntax so that it allows "X = Y" (what you see is what you think) - similarly, replace obscure syntax for indexed memory acces by such things as "X = Y[3]" - getting annoyed with the seemingly random limitations…

Back in the 90's TI had a processor, maybe a DSP, I am not sure about it, which used a form of light C as their assembler.

There wasn't an Assembly language available as we tend to know.

I don't remember the name of the processor, though.

Re: Introduction to x64 Assembly

#69
post #31
post #19

For those of you that went through Z80, 6502, 68000, x86 macro assemblers like myself, it is just me or does the AT&T syntax just suck? I recently had to convert some code from Intel syntax with NASM macros to GAS with AT&T syntax, and boy what a pain.

I agree that indexing looks way better in Intel ("[ebx+3]") than in AT&T syntax ("2(%ebx)"). However, for me, AT&T's "mov X Y" for "move X to Y" feels better for me than Intel's "mov Y X" for "move Y from X" (who says that?). If they wanted to things in reverse, they should have named the instruction differently, for example as "load Y X" for "load Y from X" (as in "LDA #0xFF" from the 6502) As for movl instead of mo…

"Move" is called "load" on other architectures; indeed, the corresponding 8080 instruction is LD.

If x86 used LD instead of MOV, it would make more sense. LD AX,4 would be read as "load register AX with the value 4"; LD AX,BX would be "load AX with what's in BX"; LD AX,[SI] would be "load AX with what's in the memory location pointed to by SI" and so forth.

Re: Introduction to x64 Assembly

#70

Earlier quoted context omitted.

"It shows how powerful the right metaphor can be in understanding something" Just like how I was taught the difference between " ". Our teacher drew the rest of Pac-Man around the " " so that we'd think of " " like the mouth of Pac-Man. It wants to eat the larger number. But that was back around 1983 when Pac-Man was all the rage (when I was drawing Pac-Man eating ghosts on my folders).

My elementary school teachers used a similar metaphor with alligators. But I never could remember which number it was that got eaten, so I just figured the bigger side was for the bigger number. Since an equal sign doesn’t have a “bigger side”, it would imply that both sides are the same. Then I wondered why they didn’t just teach that. Then I liked school even less. (Oddly enough, my childhood intuition about equals…

The greedy alligator always wants the bigger prey.

It took me a long time to differentiate the symbols because, before using the alligator metaphor, my teacher tried this one: cross a line that goes perperdicular to the bottom part of the symbol. If it turns into a 4 it's smaller than; otherwise, if it turns into a 7, then it's bigger than.

I remember seeing a "5 When I hearded the alligator metaphor, however, I got it instantly.

Post reply on HN