From 2f9e4cec961bd857a3f52e85e6e27e87004c455a Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Thu, 24 Oct 2024 17:14:43 -0600 Subject: [PATCH] x86-64 stack details and applications of the recursion theorem. --- .../plugins/obsidian-to-anki-plugin/data.json | 16 +- notes/_journal/2024-10-24.md | 13 + notes/_journal/{ => 2024-10}/2024-10-23.md | 4 +- notes/c17/index.md | 2 +- notes/set/functions.md | 77 ++- notes/set/natural-numbers.md | 234 +++++++++ notes/x86-64/instructions/access.md | 14 +- notes/x86-64/procedures.md | 497 +++++------------- notes/x86-64/registers.md | 464 ++++++++++++++++ 9 files changed, 949 insertions(+), 372 deletions(-) create mode 100644 notes/_journal/2024-10-24.md rename notes/_journal/{ => 2024-10}/2024-10-23.md (50%) diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index 05943c1..2bf6845 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -328,7 +328,7 @@ "_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd", "_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b", "c17/strings.md": "e909daa71ad93bcb38edbe30bc0516ac", - "c17/index.md": "02722edf46dd45f732996eaa1980944f", + "c17/index.md": "611dd21439d56575172ef004c7635382", "c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500", "c17/declarations.md": "2d7877915bf8a2772d1e4de636ba52a5", "algorithms/sorting/merge-sort.md": "6506483f7df6507cee0407bd205dbedd", @@ -522,7 +522,7 @@ "set/axioms.md": "063955bf19c703e9ad23be2aee4f1ab7", "_journal/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05/2024-05-13.md": "d549dd75fb42b4280d4914781edb0113", - "x86-64/registers.md": "35f4e2f7e1a988f98dc0f89f29731f11", + "x86-64/registers.md": "639225864ca4ab67b8cd82d742662fe1", "_journal/2024-05-15.md": "4e6a7e6df32e93f0d8a56bc76613d908", "_journal/2024-05/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05-16.md": "580c7ec61ec56be92fa8d6affcf0a5f6", @@ -591,7 +591,7 @@ "x86-64/instructions/condition-codes.md": "9c05ed99f5c96162e25f0ec4db55c656", "x86-64/instructions/logical.md": "49d40018f1fcb4ed1595d9175bbaab57", "x86-64/instructions/arithmetic.md": "df57fdc8d260d0812464b08565ef4c51", - "x86-64/instructions/access.md": "e54dfbaf4906886d550baa5736f4731f", + "x86-64/instructions/access.md": "4589d79f9915ffeeab7b75d2208b7917", "x86-64/instructions/index.md": "72c19067e938ab39ea51d25d6ac2bad9", "_journal/2024-06-09.md": "935b3ddf65c51e680ac5c000c7e380af", "_journal/2024-06/2024-06-08.md": "9e1ebc8882a395b96ca765ad5c982d68", @@ -607,7 +607,7 @@ "_journal/2024-06/2024-06-12.md": "f82dfa74d0def8c3179d3d076f94558e", "_journal/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307", "_journal/2024-06/2024-06-13.md": "e2722a00585d94794a089e8035e05728", - "set/functions.md": "979e5fcf8cda2ab0bbabe67c589c6a5c", + "set/functions.md": "fce911b8610d0d00e39ef7fb8489f240", "_journal/2024-06-15.md": "92cb8dc5c98e10832fb70c0e3ab3cec4", "_journal/2024-06/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307", "lambda-calculus/beta-reduction.md": "0935987f2bac0e6298735f2b26fd5885", @@ -784,7 +784,7 @@ "_journal/2024-08/2024-08-21.md": "1637b8ec8475cf3eb4f41d1d86cbf5df", "_journal/2024-08/2024-08-20.md": "e8bec308d1b29e411c6799ace7ef6571", "_journal/2024-08-23.md": "3b2feab2cc927e267263cb1e9c173d50", - "set/natural-numbers.md": "fdb3bb9e0fd74f74496e9b03f05d26a2", + "set/natural-numbers.md": "3d7dfbf80e38dccccf48f2def485aa80", "_journal/2024-08-24.md": "563fad24740e44734a87d7c3ec46cec4", "_journal/2024-08/2024-08-23.md": "7b5a40e83d8f07ff54cd9708017d029c", "_journal/2024-08/2024-08-22.md": "050235d5dc772b542773743b57ce3afe", @@ -875,7 +875,7 @@ "_journal/2024-10/2024-10-06.md": "65a8e538144f59ee9e7296110cc9aa14", "_journal/2024-10-09.md": "66acb6c8abbf0c860966223f3299c2bc", "_journal/2024-10/2024-10-08.md": "2f737d8198b12bf635808964c4887ae1", - "x86-64/procedures.md": "b7b8233deb29727b53938a78e1a797f4", + "x86-64/procedures.md": "49d733982a9f9ebf2b1bbe419175afca", "_journal/2024-10-10.md": "29e4be2c164c63f8b7aab56bddee3dd6", "_journal/2024-10/2024-10-09.md": "b718c6f4cfe3069fcc0faf07ec414f73", "_journal/2024-10-15.md": "6e696a8d16ba257ed89e8564b771d290", @@ -895,7 +895,9 @@ "algorithms/dfs.md": "5fe40544db71b5cc79f4f8149478fc8e", "_journal/2024-10/2024-10-21.md": "de1a0861e87df29aeff11a291f8fbd45", "_journal/2024-10-23.md": "51b2ca6edf23b6a64fd7d3638a0b54cb", - "_journal/2024-10/2024-10-22.md": "5ff4eb7eba58e77c4fb65b7162a485e6" + "_journal/2024-10/2024-10-22.md": "5ff4eb7eba58e77c4fb65b7162a485e6", + "_journal/2024-10-24.md": "33ad9c1d21222b4002fb3760f88800a8", + "_journal/2024-10/2024-10-23.md": "919e5b7773f496f89bb9f1b45a99da7b" }, "fields_dict": { "Basic": [ diff --git a/notes/_journal/2024-10-24.md b/notes/_journal/2024-10-24.md new file mode 100644 index 0000000..17719cf --- /dev/null +++ b/notes/_journal/2024-10-24.md @@ -0,0 +1,13 @@ +--- +title: "2024-10-24" +--- + +- [x] Anki Flashcards +- [x] KoL +- [x] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) + +* Finished "Recursion on $\omega$" and "Arithmetic" sections of Enderton's "Elements of Set Theory". +* Notes on recursively defined [[natural-numbers#Addition|addition]], [[natural-numbers#Multiplication|multiplication]] and [[natural-numbers#Exponentiation|exponentiation]] [[functions|operations]]. +* Notes on local stack variables and arguments passed on the stack. \ No newline at end of file diff --git a/notes/_journal/2024-10-23.md b/notes/_journal/2024-10/2024-10-23.md similarity index 50% rename from notes/_journal/2024-10-23.md rename to notes/_journal/2024-10/2024-10-23.md index 39a30b8..2cd34fb 100644 --- a/notes/_journal/2024-10-23.md +++ b/notes/_journal/2024-10/2024-10-23.md @@ -2,9 +2,9 @@ title: "2024-10-23" --- -- [ ] Anki Flashcards +- [x] Anki Flashcards - [x] KoL -- [ ] OGS +- [x] OGS - [ ] Sheet Music (10 min.) - [ ] Korean (Read 1 Story) diff --git a/notes/c17/index.md b/notes/c17/index.md index 1e19afe..60aeb05 100644 --- a/notes/c17/index.md +++ b/notes/c17/index.md @@ -311,7 +311,7 @@ END%% %%ANKI Basic -Are array elements typically lvalues or rvalues? +Are array accesses typically lvalues or rvalues? Back: lvalues. Reference: ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf). diff --git a/notes/set/functions.md b/notes/set/functions.md index a8d4687..961fe8a 100644 --- a/notes/set/functions.md +++ b/notes/set/functions.md @@ -178,6 +178,80 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre END%% +An **operation** on some set (say) $S$ is a function with "signature" $S \times \cdots \times S \rightarrow S$. More precisely, an $n$-ary operation on $S$ is a function $S^n \rightarrow S$ where $n \geq 0$. + +%%ANKI +Basic +Let $A$ and $B$ be disjoint sets. Is $f \colon A \rightarrow B$ a function, operation, both, or neither? +Back: Function. +Reference: “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). + +END%% + +%%ANKI +Basic +Let $A \subseteq B$. Is $f \colon A \rightarrow B$ a function, operation, or both? +Back: Both. +Reference: “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). + +END%% + +%%ANKI +Basic +Let $A$ and $B$ be disjoint sets. $f \colon A \rightarrow B$ is an operation on what set? +Back: N/A. +Reference: “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). + +END%% + +%%ANKI +Basic +Let $A \subseteq B$. $f \colon A \rightarrow B$ is an operation on what set? +Back: $B$. +Reference: “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). + +END%% + +%%ANKI +Basic +What is the arity of operation $f \colon A \rightarrow A$? +Back: $1$ +Reference: “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). + +END%% + +%%ANKI +Basic +What is the arity of operation $f \colon A \times A \rightarrow A$? +Back: $2$ +Reference: “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). + +END%% + +%%ANKI +Basic +What is the arity of operation $f \colon A \times \cdots \times A \rightarrow A$? +Back: The number of terms in $A \times \cdots \times A$. +Reference: “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). + +END%% + +%%ANKI +Basic +Why is it incomplete to state function $f$ is an operation? +Back: We have to ask what set $f$ is an operation on. +Reference: “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). + +END%% + +%%ANKI +Basic +Which of operations or functions is the more general concept? +Back: Functions. +Reference: “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). + +END%% + ## Injections A function is **injective** or **one-to-one** if each element of the codomain is mapped to by at most one element of the domain. @@ -2036,4 +2110,5 @@ END%% * “Bijection, Injection and Surjection,” in _Wikipedia_, May 2, 2024, [https://en.wikipedia.org/w/index.php?title=Bijection_injection_and_surjection](https://en.wikipedia.org/w/index.php?title=Bijection,_injection_and_surjection&oldid=1221800163). * “Fiber (Mathematics),” in _Wikipedia_, April 10, 2024, [https://en.wikipedia.org/w/index.php?title=Fiber_(mathematics)&oldid=1218193490](https://en.wikipedia.org/w/index.php?title=Fiber_(mathematics)&oldid=1218193490). * Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). -* “Kernel (Set Theory),” in _Wikipedia_, May 22, 2024, [https://en.wikipedia.org/w/index.php?title=Kernel_(set_theory)&oldid=1225189560](https://en.wikipedia.org/w/index.php?title=Kernel_(set_theory)&oldid=1225189560). \ No newline at end of file +* “Kernel (Set Theory),” in _Wikipedia_, May 22, 2024, [https://en.wikipedia.org/w/index.php?title=Kernel_(set_theory)&oldid=1225189560](https://en.wikipedia.org/w/index.php?title=Kernel_(set_theory)&oldid=1225189560). +* “Operation (Mathematics).” In _Wikipedia_, October 10, 2024. [https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)](https://en.wikipedia.org/w/index.php?title=Operation_(mathematics)&oldid=1250395938). \ No newline at end of file diff --git a/notes/set/natural-numbers.md b/notes/set/natural-numbers.md index 0ff5339..47c80d0 100644 --- a/notes/set/natural-numbers.md +++ b/notes/set/natural-numbers.md @@ -1071,6 +1071,240 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre END%% +### Addition + +For each $m \in \omega$, there exists (by the recursion theorem) a unique function $A_m \colon \omega \rightarrow \omega$ such that for all $n \in \omega$, $$\begin{align*} A_m(0) & = m, \\ A_m(n^+) & = A_m(n)^+ \end{align*}$$ + +**Addition** ($+$) is the binary operation on $\omega$ such that for any $m, n \in \omega$, $$m + n = A_m(n).$$ + +%%ANKI +Basic +Let $A_m \colon \omega \rightarrow \omega$ denote recursively defined addition. How is $A_m(n)$ more traditionally denoted? +Back: As $m + n$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $A_m \colon \omega \rightarrow \omega$ denote recursively defined addition. How is $m + n$ defined in terms of $A_m$? +Back: As $A_m(n)$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $A_m \colon \omega \rightarrow \omega$ denote recursively defined addition. What does $A_m(0)$ evalute to? +Back: $m$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $A_m \colon \omega \rightarrow \omega$ denote recursively defined addition. What does $A_m(n^+)$ evalute to? +Back: $A_m(n)^+$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $A_m \colon \omega \rightarrow \omega$ denote recursively defined addition. How do we know $A_m$ exists? +Back: The recursion theorem states it does. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is $m + n$ defined as a relation? +Back: $\{ \langle m, n, A_m(n) \rangle \mid m, n \in \omega \}$ where $A_m \colon \omega \rightarrow \omega$ is recursively defined addition. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is $+$ (addition) a function, operation, both, or neither? +Back: Both. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Without introducing new notation, what does $m + 0$ evaluate to? +Back: $m$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Without introducing new notation, what does $m + n^+$ evaluate to? +Back: $(m + n)^+$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +### Multiplication + +For each $m \in \omega$, there exists (by the recursion theorem) a unique function $M_m \colon \omega \rightarrow \omega$ such that for all $n \in \omega$, $$\begin{align*} M_m(0) & = 0, \\ M_m(n^+) & = M_m(n) + m \end{align*}$$ + +**Multiplication** ($\cdot$) is the binary operation on $\omega$ such that for any $m, n \in \omega$, $$m \cdot n = M_m(n).$$ + +%%ANKI +Basic +Let $M_m \colon \omega \rightarrow \omega$ denote recursively defined multiplication. How is $M_m(n)$ more traditionally denoted? +Back: As $m \cdot n$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $M_m \colon \omega \rightarrow \omega$ denote recursively defined multiplication. How is $m \cdot n$ defined in terms of $M_m$? +Back: As $M_m(n)$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $M_m \colon \omega \rightarrow \omega$ denote recursively defined multiplication. What does $M_m(0)$ evalute to? +Back: $0$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $M_m \colon \omega \rightarrow \omega$ denote recursively defined multiplication. What does $M_m(n^+)$ evalute to? +Back: $M_m(n) + m$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $M_m \colon \omega \rightarrow \omega$ denote recursively defined multiplication. How do we know $M_m$ exists? +Back: The recursion theorem states it does. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is $m \cdot n$ defined as a relation? +Back: $\{ \langle m, n, M_m(n) \rangle \mid m, n \in \omega \}$ where $M_m \colon \omega \rightarrow \omega$ is recursively defined multiplication. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is $\cdot$ (multiplication) a function, operation, both, or neither? +Back: Both. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Without introducing new notation, what does $m \cdot 0$ evaluate to? +Back: $0$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Without introducing new notation, what does $m \cdot n^+$ evaluate to? +Back: $m \cdot n + m$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +### Exponentiation + +For each $m \in \omega$, there exists (by the recursion theorem) a unique function $E_m \colon \omega \rightarrow \omega$ such that for all $n \in \omega$, $$\begin{align*} E_m(0) & = 1, \\ E_m(n^+) & = E_m(n) \cdot m \end{align*}$$ + +**Exponentiation** is the binary operation on $\omega$ such that for any $m, n \in \omega$, $$m^n = E_m(n).$$ + +%%ANKI +Basic +Let $E_m \colon \omega \rightarrow \omega$ denote recursively defined exponentiation. How is $E_m(n)$ more traditionally denoted? +Back: As $m^n$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $E_m \colon \omega \rightarrow \omega$ denote recursively defined exponentiation. How is $m^n$ defined in terms of $E_m$? +Back: As $E_m(n)$. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $E_m \colon \omega \rightarrow \omega$ denote recursively defined exponentiation. What does $E_m(0)$ evalute to? +Back: $1$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $E_m \colon \omega \rightarrow \omega$ denote recursively defined exponentiation. What does $E_m(n^+)$ evalute to? +Back: $E_m(n) \cdot m$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Let $E_m \colon \omega \rightarrow \omega$ denote recursively defined exponentiation. How do we know $E_m$ exists? +Back: The recursion theorem states it does. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +How is $m^n$ defined as a relation? +Back: $\{ \langle m, n, E_m(n) \rangle \mid m, n \in \omega \}$ where $E_m \colon \omega \rightarrow \omega$ is recursively defined exponentiation. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Is exponentiation a function, operation, both, or neither? +Back: Both. +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Without introducing new notation, what does $m^0$ evaluate to? +Back: $1$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + +%%ANKI +Basic +Without introducing new notation, what does $m^{(n^+)}$ evaluate to? +Back: $m^n \cdot m$ +Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). + +END%% + ## Bibliography * Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). diff --git a/notes/x86-64/instructions/access.md b/notes/x86-64/instructions/access.md index 59300ea..48514aa 100644 --- a/notes/x86-64/instructions/access.md +++ b/notes/x86-64/instructions/access.md @@ -302,6 +302,14 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program END%% +%%ANKI +Basic +What is instruction `cltq` an acronym for? +Back: **C**onvert **l**ong **t**o **q**uad. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + %%ANKI Basic What does the `cltq` instruction do? @@ -312,7 +320,7 @@ END%% %%ANKI Basic -What equivalent instruction to the following does x86-64 provide? +What equivalent no-operand instruction does x86-64 provide? ```asm movslq %eax, %rax ``` @@ -323,7 +331,7 @@ END%% %%ANKI Basic -What equivalent instruction to the following does x86-64 provide? +What equivalent no-operand instruction does x86-64 provide? ```asm movzlq %eax, %rax ``` @@ -334,7 +342,7 @@ END%% %%ANKI Basic -How can the following instruction be rewritten using a MOV? +How is the following instruction equivalently rewritten using MOV? ```asm cltq ``` diff --git a/notes/x86-64/procedures.md b/notes/x86-64/procedures.md index 39588d6..3bc3af0 100644 --- a/notes/x86-64/procedures.md +++ b/notes/x86-64/procedures.md @@ -191,414 +191,195 @@ END%% ## Data Transfer -x86-64 employs 6 registers for passing integral (i.e. integer and pointer) arguments between caller and callee. +The 6 registers used for passing integral arguments are highlighted [[registers#Integral Arguments|here]]. If more than 6 integral arguments are specified to a procedure, the surplus are placed onto the stack in the caller's frame. -| Bits | Arg 1 | Arg2 | Arg3 | Arg4 | Arg5 | Arg6 | -| ---- | ------ | ------ | ------ | ------ | ------ | ------ | -| 64 | `%rdi` | `%rsi` | `%rdx` | `%rcx` | `%r8` | `%r9` | -| 32 | `%edi` | `%esi` | `%edx` | `%ecx` | `%r8d` | `%r9d` | -| 16 | `%di` | `%si` | `%dx` | `%cx` | `%r8w` | `%r9w` | -| 8 | `%dil` | `%sil` | `%dl` | `%cl` | `%r8b` | `%r9b` | +The 7th argument is placed closer to the top of the stack (i.e. with lower address) than subsequent arguments. %%ANKI Basic -How many registers are available for passing integral arguments between procedures? -Back: `6` +Which frame contains the 7th argument? +```c +void P() { + ... + Q(1, 2, 3, 4, 5, 6, 7); + ... +} +``` +Back: `P`'s frame. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% %%ANKI Basic -How many bytes make up the `%rdi` register? -Back: $8$ +Which frame contains the return address? +```c +void P() { + ... + Q(1, 2, 3); + ... +} +``` +Back: `P`'s frame. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% %%ANKI Basic -How many bytes make up the `%di` register? -Back: $2$ +Which of the 7th or 8th argument has lower address? +```c +void P() { + ... + Q(1, 2, 3, 4, 5, 6, 7, 8); + ... +} +``` +Back: The 7th argument. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% %%ANKI Basic -How many bytes make up the `%dil` register? -Back: $1$ +Which of the 7th or 8th argument is nearer the stack's top? +```c +void P() { + ... + Q(1, 2, 3, 4, 5, 6, 7, 8); + ... +} +``` +Back: The 7th argument. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% %%ANKI Basic -How many bytes make up the `%edi` register? -Back: $4$ +Which arguments are placed onto the stack? +```c +void P() { + ... + Q(1, 2, 3, 4, 5, 6, 7, 8); + ... +} +``` +Back: Arguments 7 and 8. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% +%%ANKI +Basic +Which of the 6th or 7th argument is nearer the stack's top? +```c +void P() { + ... + Q(1, 2, 3, 4, 5, 6, 7); + ... +} +``` +Back: N/A. Argument 6 isn't placed onto the stack at all. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +%%ANKI +Basic +Which of the 7th argument or the return address is nearer the stack's top? +```c +void P() { + ... + Q(1, 2, 3, 4, 5, 6, 7); + ... +} +``` +Back: The return address. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +Tags: c17 + +END%% + +In some cases, integral values still need to be placed onto the stack. For example, operator `&` is applied to a local variable and hence we must be able to generate an address for it. + %%ANKI Cloze -By convention, register {`%rdi`} is used for {the first integral argument}. +In the following, `P` is the {caller} and `Q` is the {callee}. +```c +int P() { Q(); } +``` Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:Words} are to {2:`%di`} whereas {2:double words} are to {1:`%edi`}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:Bytes} are to {2:`%dil`} whereas {2:quad words} are to {1:`%rdi`}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% %%ANKI Basic -How do you access the low-order 2 bytes of `%rdi`? -Back: By using `%di`. +*Why* doesn't `P` have to allocate any local variables on the stack? +```c +void P() { + int a = 100; + Q(a); +} +``` +Back: A register can be set to immediate `$100` for `Q` to access. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% %%ANKI Basic -How do you access the low-order 4 bytes of `%rdi`? -Back: By using `%edi`. +*Why* doesn't `P` have to allocate any local variables on the stack? +```c +void P() { + int a = 100; + Q(&a); +} +``` +Back: N/A. It does since we need an address for `a` to supply to `Q`. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% %%ANKI Basic -How do you access the low-order byte of `%rdi`? -Back: By using `%dil`. +Is `P`'s local stack variables or arguments to `Q` nearer the stack's top? +```c +void P() { + ... + Q(1, 2, 3, 4, 5, 6); + ... +} +``` +Back: N/A. `P` does not have any arguments passed to `Q` on the stack. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% %%ANKI Basic -Which register should the first integral argument of a procedure be placed in? -Back: `%rdi` +Is `P`'s local stack variables or arguments to `Q` nearer the stack's top? +```c +void P() { + ... + Q(1, 2, 3, 4, 5, 6, 7); + ... +} +``` +Back: The arguments to `Q`. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -From smallest to largest, list the four "first integral argument" registers. -Back: `%dil`, `%di`, `%edi`, and `%rdi`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%rsi` register? -Back: $8$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%si` register? -Back: $2$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%sil` register? -Back: $1$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%esi` register? -Back: $4$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -By convention, register {`%rsi`} is used for {the second integral argument}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:Words} are to {2:`%si`} whereas {2:double words} are to {1:`%esi`}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:Bytes} are to {2:`%sil`} whereas {2:quad words} are to {1:`%rsi`}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How do you access the low-order 2 bytes of `%rsi`? -Back: By using `%si`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How do you access the low-order 4 bytes of `%rsi`? -Back: By using `%esi`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How do you access the low-order byte of `%rsi`? -Back: By using `%sil`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -Which register should the second integral argument of a procedure be placed in? -Back: `%rsi` -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -From smallest to largest, list the four "second integral argument" registers. -Back: `%sil`, `%si`, `%esi`, and `%rsi`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:`%rdi`} is to the {2:first} integral argument whereas {2:`%rsi`} is to the {1:second} integral argument. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%rdx` register? -Back: $8$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%dx` register? -Back: $2$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%dl` register? -Back: $1$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%edx` register? -Back: $4$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -By convention, register {`%rdx`} is used for {the third integral argument}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:Words} are to {2:`%dx`} whereas {2:double words} are to {1:`%edx`}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:Bytes} are to {2:`%dl`} whereas {2:quad words} are to {1:`%rdx`}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How do you access the low-order 2 bytes of `%rdx`? -Back: By using `%dx`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How do you access the low-order 4 bytes of `%rdx`? -Back: By using `%edx`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How do you access the low-order byte of `%rdx`? -Back: By using `%dl`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -Which register should the third integral argument of a procedure be placed in? -Back: `%rdx` -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -From smallest to largest, list the four "third integral argument" registers. -Back: `%dl`, `%dx`, `%edx`, and `%rdx`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:`%dil`} is to the {2:first} integral argument whereas {2:`%dl`} is to the {1:third} integral argument. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%rcx` register? -Back: $8$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%ecx` register? -Back: $4$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%cx` register? -Back: $2$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How many bytes make up the `%cl` register? -Back: $1$ -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -By convention, register {`%rcx`} is used for {the fourth integral argument}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:Words} are to {2:`%cx`} whereas {2:quad words} are to {1:`%rcx`}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:Bytes} are to {2:`%cl`} whereas {2:double words} are to {1:`%ecx`}. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How do you access the low-order 2 bytes of `%rcx`? -Back: By using `%cx`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How do you access the low-order 4 bytes of `%rcx`? -Back: By using `%ecx`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -How do you access the low-order byte of `%rcx`? -Back: By using `%cl`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -Which register should the fourth integral argument of a procedure be placed in? -Back: `%rcx` -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Basic -From smallest to largest, list the four "fourth integral argument" registers. -Back: `%cl`, `%cx`, `%ecx`, and `%rcx`. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - -END%% - -%%ANKI -Cloze -{1:`%di`} is to the {2:first} integral argument whereas {2:`%cx`} is to the {1:fourth} integral argument. -Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. - +Tags: c17 + END%% ## Bibliography diff --git a/notes/x86-64/registers.md b/notes/x86-64/registers.md index 7311c99..b75f316 100644 --- a/notes/x86-64/registers.md +++ b/notes/x86-64/registers.md @@ -300,6 +300,470 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program END%% +## Integral Arguments + +x86-64 employs 6 registers for passing integral (i.e. integer and pointer) arguments between caller and callee. + +| Bits | Arg 1 | Arg2 | Arg3 | Arg4 | Arg5 | Arg6 | +| ---- | ------ | ------ | ------ | ------ | ------ | ------ | +| 64 | `%rdi` | `%rsi` | `%rdx` | `%rcx` | `%r8` | `%r9` | +| 32 | `%edi` | `%esi` | `%edx` | `%ecx` | `%r8d` | `%r9d` | +| 16 | `%di` | `%si` | `%dx` | `%cx` | `%r8w` | `%r9w` | +| 8 | `%dil` | `%sil` | `%dl` | `%cl` | `%r8b` | `%r9b` | + +%%ANKI +Basic +How many registers are available for passing integral arguments between procedures? +Back: `6` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%rdi` register? +Back: $8$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%di` register? +Back: $2$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%dil` register? +Back: $1$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%edi` register? +Back: $4$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +By convention, register {`%rdi`} is used for {the first integral argument}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:Words} are to {2:`%di`} whereas {2:double words} are to {1:`%edi`}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:Bytes} are to {2:`%dil`} whereas {2:quad words} are to {1:`%rdi`}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order 2 bytes of `%rdi`? +Back: By using `%di`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order 4 bytes of `%rdi`? +Back: By using `%edi`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order byte of `%rdi`? +Back: By using `%dil`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which register should the first integral argument of a procedure be placed in? +Back: `%rdi` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +From smallest to largest, list the four "first integral argument" registers. +Back: `%dil`, `%di`, `%edi`, and `%rdi`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%rsi` register? +Back: $8$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%si` register? +Back: $2$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%sil` register? +Back: $1$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%esi` register? +Back: $4$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +By convention, register {`%rsi`} is used for {the second integral argument}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:Words} are to {2:`%si`} whereas {2:double words} are to {1:`%esi`}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:Bytes} are to {2:`%sil`} whereas {2:quad words} are to {1:`%rsi`}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order 2 bytes of `%rsi`? +Back: By using `%si`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order 4 bytes of `%rsi`? +Back: By using `%esi`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order byte of `%rsi`? +Back: By using `%sil`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which register should the second integral argument of a procedure be placed in? +Back: `%rsi` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +From smallest to largest, list the four "second integral argument" registers. +Back: `%sil`, `%si`, `%esi`, and `%rsi`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:`%rdi`} is to the {2:first} integral argument whereas {2:`%rsi`} is to the {1:second} integral argument. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%rdx` register? +Back: $8$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%dx` register? +Back: $2$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%dl` register? +Back: $1$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%edx` register? +Back: $4$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +By convention, register {`%rdx`} is used for {the third integral argument}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:Words} are to {2:`%dx`} whereas {2:double words} are to {1:`%edx`}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:Bytes} are to {2:`%dl`} whereas {2:quad words} are to {1:`%rdx`}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order 2 bytes of `%rdx`? +Back: By using `%dx`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order 4 bytes of `%rdx`? +Back: By using `%edx`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order byte of `%rdx`? +Back: By using `%dl`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which register should the third integral argument of a procedure be placed in? +Back: `%rdx` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +From smallest to largest, list the four "third integral argument" registers. +Back: `%dl`, `%dx`, `%edx`, and `%rdx`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:`%dil`} is to the {2:first} integral argument whereas {2:`%dl`} is to the {1:third} integral argument. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%rcx` register? +Back: $8$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%ecx` register? +Back: $4$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%cx` register? +Back: $2$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How many bytes make up the `%cl` register? +Back: $1$ +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +By convention, register {`%rcx`} is used for {the fourth integral argument}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:Words} are to {2:`%cx`} whereas {2:quad words} are to {1:`%rcx`}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:Bytes} are to {2:`%cl`} whereas {2:double words} are to {1:`%ecx`}. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order 2 bytes of `%rcx`? +Back: By using `%cx`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order 4 bytes of `%rcx`? +Back: By using `%ecx`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +How do you access the low-order byte of `%rcx`? +Back: By using `%cl`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which register should the fourth integral argument of a procedure be placed in? +Back: `%rcx` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +From smallest to largest, list the four "fourth integral argument" registers. +Back: `%cl`, `%cx`, `%ecx`, and `%rcx`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Cloze +{1:`%di`} is to the {2:first} integral argument whereas {2:`%cx`} is to the {1:fourth} integral argument. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which register should `Q` use to access value `1`? +```c +void P() { + Q(1, 2, 3, 4, 5, 6); +} +``` +Back: `%rdi` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which register should `Q` use to access value `2`? +```c +void P() { + Q(1, 2, 3, 4, 5, 6); +} +``` +Back: `%rci` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which register should `Q` use to access value `3`? +```c +void P() { + Q(1, 2, 3, 4, 5, 6); +} +``` +Back: `%rdx` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +%%ANKI +Basic +Which register should `Q` use to access value `4`? +```c +void P() { + Q(1, 2, 3, 4, 5, 6); +} +``` +Back: `%rcx` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + ## Condition Codes The CPU also maintains a set of single-bit **condition code** registers describing attributes of the most recent arithmetic or logical operation.