4

Assembly seems to have lots of tricks.

Is there a list/book/resource anywhere of these kinds of Assembly idiosyncrasies?

3
  • For which instruction set architecture?
    – julian
    Feb 26, 2018 at 3:33
  • @SYS_V wondering for x86_64 Feb 26, 2018 at 6:08
  • 1
    what trick is in xor-ing register to get a zero? It's just math/logic. Feb 26, 2018 at 7:07

2 Answers 2

4

There is no manual for what you call 'tricks' (personally, I prefer the term 'idioms'). Most of the idioms you are citing are used by compilers to perform a precise task in a more efficient manner than what you can see in the manuals.

The best way to learn about it is to read compiler generated assembly code and/or shellcodes. They are a great source of assembly idioms.

Here is a list of good readings or links to investigate all these idioms:

3
  • 1
    There is also this lovely book amazon.com/xchg-rax-xorpd/dp/1502958082 Feb 26, 2018 at 11:57
  • Right, I add it to the list!
    – perror
    Feb 26, 2018 at 11:59
  • For what it's worth The Art of Assembly Language (2nd Edition) by Randall Hyde is total trash. I read it though too. It has very little Assembly. it's a total rewrite of the Art of Assembly for DOS which is actually a good book. 2nd edition teaches something called High Level Assembly which is basically a separate language. Oct 5, 2018 at 20:36
1

The microarchitecture of Intel, AMD and VIA CPUs An optimization guide for assembly programmers and compiler makers by Agner Fog, Technical University of Denmark

Not for the fainthearted but probably the most detailed document on the subject.

1
  • Beware, the optimization based on 'branch prediction' may become obsolete for the next generation of processors depending on what tampering mechanisms will be used to remove the Spectre and Meltdown flaws. Anyway, the rest of the document is quite impressive. Thanks for posting it!
    – perror
    Mar 1, 2018 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.