[HN Gopher] X64 Cheat Sheet (2019) [pdf]
       ___________________________________________________________________
        
       X64 Cheat Sheet (2019) [pdf]
        
       Author : ingve
       Score  : 67 points
       Date   : 2022-10-05 12:44 UTC (10 hours ago)
        
 (HTM) web link (cs.brown.edu)
 (TXT) w3m dump (cs.brown.edu)
        
       | KyleSanderson wrote:
       | I feel blessed that my intro was the Z80...
        
         | don-code wrote:
         | Mine was one of the later 6800-series - an 8-bit CISC CPU with
         | enough 16-bit extensions to not feel too constrained. It's
         | interesting that everything which made it a great learning
         | platform (orthogonal instruction set, instructions for common
         | but complex operations, ability to access lower bits of
         | registers directly) make x64 a horrible instruction set to
         | learn as your first. In that regard, x64 seems more RISC-like:
         | it's intended for compilers to generate that, not humans.
        
       | ranger_danger wrote:
       | Wow this is _intro_ to computer systems?
        
         | groovybits wrote:
         | It really depends where you go. In undergrad, my first intro CS
         | course was basically working through the Intel x86 manuals[0].
         | 
         | Partway through, I transferred to another state, and their
         | college's intro course was about C.
         | 
         | 0:
         | https://www.intel.com/content/www/us/en/developer/articles/t...
        
         | MonkeyClub wrote:
         | Not really -- where are the NANDs and machine code?
        
         | vajrabum wrote:
         | I got curious and looked. It's not intro to computer science,
         | but intro to computer systems (i.e. systems programming and
         | high level computer architecture).
         | https://cs.brown.edu/courses/info/csci0330/
        
         | sq_ wrote:
         | In my experience, sometimes the "systems" part means something
         | along the lines of "architecture". I've seen syllabi for
         | "computer systems" courses that did an overview of virtual
         | memory and all, ran up to a bit of assembly, and then moved on
         | to stuff the OS provides like syscalls, etc. Maybe that's the
         | case here?
        
         | pjmlp wrote:
         | Back on my high school days at technical school, Assembly
         | programming was taught on the 11th grade, alongside Turbo
         | Pascal, Clipper and DBase III+, to give an image of the time
         | period.
         | 
         | 15 year old students had no issue dealing with 8086 and 68000
         | Assembly.
        
       | johnklos wrote:
       | This is from a school? The author (Doeppner, it seems) should be
       | embarrassed.
       | 
       | "x64" is a marketing name primarily used by Microsoft. Sure, many
       | of us know what you're talking about when you use "x64", but it's
       | just not a real thing. There's no 464, 564, 664, 764, et cetera,
       | so the "x" means nothing, unlike its use in "x86".
       | 
       | It's like using "virus" to describe a Trojan - people will
       | generally get the gist, but you're technically wrong, and if
       | you're supposed to know what you're talking about, then you're
       | certainly not showing it.
        
         | smegsicle wrote:
         | and then there's x32, the (abandoned?) project for taking
         | advantage of most of AMD64 while keeping pointers as 32bit to
         | conserve memory
        
         | kvathupo wrote:
         | As a recent grad, I was going to say education on hardware
         | optimization is lacking in universities, but then again there's
         | a lot of snake oil on sites like stackoverflow. Although users
         | like Peter Cordes have done a good job cleaning up, people
         | still seem to eschew benchmarking for eyeballing code a la "Big
         | O", ignoring the effects of compilers and hardware (CPU type,
         | memory layout).
         | 
         | I wouldn't be too harsh on the prof for a throwaway doc: it
         | reads as a perfectly fine intro to concepts like stack, heap,
         | and basic assembly instructions. I'd argue most computer
         | science students, with aims of a programming job, don't need to
         | even know these concepts [1], [2]. With hardware advancements,
         | most probably don't need to worry about code performance. Of
         | those who do, they'll just google Agner Fog, and learn on their
         | own just fine. Despite my opening sentence, I'm sure the
         | Electrical Engineering/Computer Engineering departments are
         | much stronger in this area.
         | 
         | [1] - https://en.wikipedia.org/wiki/Global_interpreter_lock
         | 
         | [2] - https://en.wikipedia.org/wiki/JavaScript
        
         | Joker_vD wrote:
         | Yeah, it's actually called EM64T or at the very worst IA-32e.
         | /s
         | 
         | Speaking seriously, there are two variants of this
         | architecture: AMD64 and Intel 64 (that's what AMD and Intel
         | call their respective versions). Everything else is misnomer,
         | including legacy monikers such as "x86-64".
        
         | Blackthorn wrote:
         | This is one of the most stark examples of bikeshedding I've
         | seen on this site.
        
           | blueflow wrote:
           | Imagine having studied tons of literature for your thesis and
           | then ending up in a industry that uses the same terms, except
           | with half of them with a meaning that is incompatible with
           | what you learned, but in a subtle manner.
        
           | [deleted]
        
           | johnklos wrote:
           | > one of the most stark examples of bikeshedding
           | 
           | I think your reaction is an excellent example of a
           | significant problem with discourse on the Internet.
           | 
           | Correct terms matter. Using incorrect terminology just
           | because it's common is no excuse.
           | 
           | Being pedantic about things isn't helpful, either, but which
           | is worse: a teacher in a specific field using terms
           | incorrectly, and therefore passing along that incorrect
           | usage, or someone pointing that out?
           | 
           | So let's reexamine: is this "one of the most stark examples
           | of bikeshedding", or is this the Internet showing its lack of
           | tolerance for a genuine care for facts and correctness?
        
             | Joker_vD wrote:
             | So, what is the correct term then: "Intel 64" or "AMD64"?
             | That's what the CPU manufacturers call their specification
             | of that architecture _right now_. Intel used to call it
             | "IA-32e". AMD called it "x86-64" before they've released
             | it, but then switched to "AMD64". All of those are
             | "marketing names" used (or no longer used) by the
             | manufacturers. How should we pick the correct one? Is there
             | even a correct one?
        
               | johnklos wrote:
               | If "x64" can refer to amd64 or Intel 64, then it can also
               | refer to PPC64, aarch64, mips64, et cetera.
               | 
               | But Intel 64, amd64, x86_64, x86, all work because none
               | are ambiguous or misleading. "IA-32e" would be confusing,
               | but at least it refers to a specific Intel marketing term
               | that one can look up. They're specific enough to avoid
               | ambiguity.
               | 
               | (to be fair, "Intel 64" could refer to Itanic, so that's
               | not as unambiguous as it could be, but without context,
               | it's reasonable most would assume it refers to 64 bit
               | x86)
        
             | biorach wrote:
             | I vote bikeshedding
        
             | Blackthorn wrote:
             | Sorry but you veered way past "someone pointing it out" and
             | crashed your car into the bike shed when you said "The
             | author (Doeppner, it seems) should be embarrassed."
        
       | DethNinja wrote:
       | I wish somebody would create an online playground for learning
       | x64 assembly.
       | 
       | It isn't so hard to install NASM and start from there, but it
       | would be substantially easier to learn if there was an option
       | like codeacademy for assembly.
        
         | whitepirate20 wrote:
         | I've been searching for this for the last couple weeks. Not
         | related, but the original author who wrote Programming from The
         | Ground Up released a new assembly book last year. PGU was
         | previously one of the highest recommended assembly books
        
       | [deleted]
        
       | batch12 wrote:
       | Weird. I was just looking at this exact document again while
       | playing the flare-on CtF.
        
       | djmips wrote:
       | I haven't checked - on phone - but is the ABI described MSVC or
       | GCC ?
        
         | iamcreasy wrote:
         | Can you kindly recommend me a book to learn more about ABI and
         | the associate information such as computer architecture etc? In
         | university I've written as assembler, a compiler and also took
         | computer architecture class but still I do not seem to
         | understand the ABI.
        
           | maldev wrote:
           | Unironically the NASM docs are AMAZING for this, and by far
           | the best. https://www.nasm.us/xdoc/2.15.05/html/nasmdoc0.html
           | .
           | 
           | For example for 64bit windows https://www.nasm.us/xdoc/2.15.0
           | 5/html/nasmdo12.html#section-... .
           | 
           | There's also this for formats, this is windows for example. h
           | ttps://www.nasm.us/xdoc/2.15.05/html/nasmdoc8.html#section-..
           | .
           | 
           | For general systems programming/asm, AMD has REALLY well
           | written documentation. Intel is better for edge cases and are
           | more explicit. But when learning the explicitness makes it
           | more complicated and AMD reads on the level of a regular
           | person, not some 80 year old greybeard who writes asm in hex
           | codes.
        
             | iamcreasy wrote:
             | Thank you. But I was wondering if there is any reputable
             | text book that I can read front to back that will give me a
             | good overview with examples. Connecting ABI in relation to
             | MSVC, GCC and System V as the sibling comment mentioned. I
             | have use MASM before, and I am not sure if NASM manual
             | contains what I am looking for - but I'll take a look.
        
         | dennis_moore wrote:
         | "To call a function, the program should place the first six
         | integer or pointer parameters in the registers %rdi, %rsi,
         | %rdx, %rcx, %r8, and %r9." This sounds like System V, hence
         | GCC.
        
       ___________________________________________________________________
       (page generated 2022-10-05 23:01 UTC)