4

Assembly seems to have lots of tricks.

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

Evan Carroll
  • 1,779
  • 1
  • 18
  • 50

2 Answers2

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:

perror
  • 19,083
  • 29
  • 87
  • 150
  • 1
    There is also this lovely book https://www.amazon.com/xchg-rax-xorpd/dp/1502958082 – Vitaly Osipov Feb 26 '18 at 11:57
  • Right, I add it to the list! – perror Feb 26 '18 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. – Evan Carroll Oct 05 '18 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.

Igor Skochinsky
  • 36,553
  • 7
  • 65
  • 115
fpmurphy
  • 311
  • 1
  • 2
  • 11
  • 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 01 '18 at 17:22