Thiemos Archiv
- Friday, 2020-07-24 17:45
- I have a collection of obsolete "computer books" from the 1980s and earlier, including many about the programming language BASIC. Whenever I skim through another addition to my collection, one BASIC keyword keeps catching my attention:
SWAP
. It's such a simple enhancement. There are even dedicated Wikipedia articles about the concept (Dreieckstausch in German). Yet it doesn't exist in any of the modern programming languages I use nowadays. Why is that? Kommentare zu diesem Beitrag können per E-Mail an den Autor gesandt werden.
The main reason for XCHG in x86 isn´t really optimizing actual variable swaps but rather a result of lack of registers combined with specific functionality to register assignments in the first x86 revisions (pre 386), similar for FXCH for x87 with its FPU stack. On todays CPUs with out of order execution an register renaming XCHG as well as FXCH is basically a no-op anyway.