x86-64 stack details and applications of the recursion theorem.

main
Joshua Potter 2024-10-24 17:14:43 -06:00
parent 22c6429e32
commit 2f9e4cec96
9 changed files with 949 additions and 372 deletions

View File

@ -328,7 +328,7 @@
"_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd", "_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd",
"_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b", "_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b",
"c17/strings.md": "e909daa71ad93bcb38edbe30bc0516ac", "c17/strings.md": "e909daa71ad93bcb38edbe30bc0516ac",
"c17/index.md": "02722edf46dd45f732996eaa1980944f", "c17/index.md": "611dd21439d56575172ef004c7635382",
"c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500", "c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500",
"c17/declarations.md": "2d7877915bf8a2772d1e4de636ba52a5", "c17/declarations.md": "2d7877915bf8a2772d1e4de636ba52a5",
"algorithms/sorting/merge-sort.md": "6506483f7df6507cee0407bd205dbedd", "algorithms/sorting/merge-sort.md": "6506483f7df6507cee0407bd205dbedd",
@ -522,7 +522,7 @@
"set/axioms.md": "063955bf19c703e9ad23be2aee4f1ab7", "set/axioms.md": "063955bf19c703e9ad23be2aee4f1ab7",
"_journal/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5",
"_journal/2024-05/2024-05-13.md": "d549dd75fb42b4280d4914781edb0113", "_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-15.md": "4e6a7e6df32e93f0d8a56bc76613d908",
"_journal/2024-05/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5",
"_journal/2024-05-16.md": "580c7ec61ec56be92fa8d6affcf0a5f6", "_journal/2024-05-16.md": "580c7ec61ec56be92fa8d6affcf0a5f6",
@ -591,7 +591,7 @@
"x86-64/instructions/condition-codes.md": "9c05ed99f5c96162e25f0ec4db55c656", "x86-64/instructions/condition-codes.md": "9c05ed99f5c96162e25f0ec4db55c656",
"x86-64/instructions/logical.md": "49d40018f1fcb4ed1595d9175bbaab57", "x86-64/instructions/logical.md": "49d40018f1fcb4ed1595d9175bbaab57",
"x86-64/instructions/arithmetic.md": "df57fdc8d260d0812464b08565ef4c51", "x86-64/instructions/arithmetic.md": "df57fdc8d260d0812464b08565ef4c51",
"x86-64/instructions/access.md": "e54dfbaf4906886d550baa5736f4731f", "x86-64/instructions/access.md": "4589d79f9915ffeeab7b75d2208b7917",
"x86-64/instructions/index.md": "72c19067e938ab39ea51d25d6ac2bad9", "x86-64/instructions/index.md": "72c19067e938ab39ea51d25d6ac2bad9",
"_journal/2024-06-09.md": "935b3ddf65c51e680ac5c000c7e380af", "_journal/2024-06-09.md": "935b3ddf65c51e680ac5c000c7e380af",
"_journal/2024-06/2024-06-08.md": "9e1ebc8882a395b96ca765ad5c982d68", "_journal/2024-06/2024-06-08.md": "9e1ebc8882a395b96ca765ad5c982d68",
@ -607,7 +607,7 @@
"_journal/2024-06/2024-06-12.md": "f82dfa74d0def8c3179d3d076f94558e", "_journal/2024-06/2024-06-12.md": "f82dfa74d0def8c3179d3d076f94558e",
"_journal/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307", "_journal/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307",
"_journal/2024-06/2024-06-13.md": "e2722a00585d94794a089e8035e05728", "_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-15.md": "92cb8dc5c98e10832fb70c0e3ab3cec4",
"_journal/2024-06/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307", "_journal/2024-06/2024-06-14.md": "5d12bc272238ac985a1d35d3d63ea307",
"lambda-calculus/beta-reduction.md": "0935987f2bac0e6298735f2b26fd5885", "lambda-calculus/beta-reduction.md": "0935987f2bac0e6298735f2b26fd5885",
@ -784,7 +784,7 @@
"_journal/2024-08/2024-08-21.md": "1637b8ec8475cf3eb4f41d1d86cbf5df", "_journal/2024-08/2024-08-21.md": "1637b8ec8475cf3eb4f41d1d86cbf5df",
"_journal/2024-08/2024-08-20.md": "e8bec308d1b29e411c6799ace7ef6571", "_journal/2024-08/2024-08-20.md": "e8bec308d1b29e411c6799ace7ef6571",
"_journal/2024-08-23.md": "3b2feab2cc927e267263cb1e9c173d50", "_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-24.md": "563fad24740e44734a87d7c3ec46cec4",
"_journal/2024-08/2024-08-23.md": "7b5a40e83d8f07ff54cd9708017d029c", "_journal/2024-08/2024-08-23.md": "7b5a40e83d8f07ff54cd9708017d029c",
"_journal/2024-08/2024-08-22.md": "050235d5dc772b542773743b57ce3afe", "_journal/2024-08/2024-08-22.md": "050235d5dc772b542773743b57ce3afe",
@ -875,7 +875,7 @@
"_journal/2024-10/2024-10-06.md": "65a8e538144f59ee9e7296110cc9aa14", "_journal/2024-10/2024-10-06.md": "65a8e538144f59ee9e7296110cc9aa14",
"_journal/2024-10-09.md": "66acb6c8abbf0c860966223f3299c2bc", "_journal/2024-10-09.md": "66acb6c8abbf0c860966223f3299c2bc",
"_journal/2024-10/2024-10-08.md": "2f737d8198b12bf635808964c4887ae1", "_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-10.md": "29e4be2c164c63f8b7aab56bddee3dd6",
"_journal/2024-10/2024-10-09.md": "b718c6f4cfe3069fcc0faf07ec414f73", "_journal/2024-10/2024-10-09.md": "b718c6f4cfe3069fcc0faf07ec414f73",
"_journal/2024-10-15.md": "6e696a8d16ba257ed89e8564b771d290", "_journal/2024-10-15.md": "6e696a8d16ba257ed89e8564b771d290",
@ -895,7 +895,9 @@
"algorithms/dfs.md": "5fe40544db71b5cc79f4f8149478fc8e", "algorithms/dfs.md": "5fe40544db71b5cc79f4f8149478fc8e",
"_journal/2024-10/2024-10-21.md": "de1a0861e87df29aeff11a291f8fbd45", "_journal/2024-10/2024-10-21.md": "de1a0861e87df29aeff11a291f8fbd45",
"_journal/2024-10-23.md": "51b2ca6edf23b6a64fd7d3638a0b54cb", "_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": { "fields_dict": {
"Basic": [ "Basic": [

View File

@ -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.

View File

@ -2,9 +2,9 @@
title: "2024-10-23" title: "2024-10-23"
--- ---
- [ ] Anki Flashcards - [x] Anki Flashcards
- [x] KoL - [x] KoL
- [ ] OGS - [x] OGS
- [ ] Sheet Music (10 min.) - [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story) - [ ] Korean (Read 1 Story)

View File

@ -311,7 +311,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Are array elements typically lvalues or rvalues? Are array accesses typically lvalues or rvalues?
Back: lvalues. 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). Reference: ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf).
<!--ID: 1723510994997--> <!--ID: 1723510994997-->

View File

@ -178,6 +178,80 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
<!--ID: 1720786472266--> <!--ID: 1720786472266-->
END%% 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).
<!--ID: 1729804914205-->
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).
<!--ID: 1729804914206-->
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).
<!--ID: 1729804914207-->
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).
<!--ID: 1729804914208-->
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).
<!--ID: 1729804914209-->
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).
<!--ID: 1729804914210-->
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).
<!--ID: 1729804914211-->
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).
<!--ID: 1729804914212-->
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).
<!--ID: 1729804914213-->
END%%
## Injections ## 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. 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.
@ -2037,3 +2111,4 @@ END%%
* “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). * “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). * 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). * “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).

View File

@ -1071,6 +1071,240 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
<!--ID: 1727629232445--> <!--ID: 1727629232445-->
END%% 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).
<!--ID: 1729804914175-->
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).
<!--ID: 1729804914179-->
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).
<!--ID: 1729804914180-->
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).
<!--ID: 1729804914181-->
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).
<!--ID: 1729804914182-->
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).
<!--ID: 1729804914183-->
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).
<!--ID: 1729804914184-->
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).
<!--ID: 1729804914185-->
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).
<!--ID: 1729804914186-->
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).
<!--ID: 1729804914187-->
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).
<!--ID: 1729804914188-->
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).
<!--ID: 1729804914189-->
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).
<!--ID: 1729804914190-->
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).
<!--ID: 1729804914191-->
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).
<!--ID: 1729804914192-->
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).
<!--ID: 1729804914193-->
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).
<!--ID: 1729804914194-->
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).
<!--ID: 1729804914195-->
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).
<!--ID: 1729804914196-->
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).
<!--ID: 1729804914197-->
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).
<!--ID: 1729804914198-->
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).
<!--ID: 1729804914199-->
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).
<!--ID: 1729804914200-->
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).
<!--ID: 1729804914201-->
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).
<!--ID: 1729804914202-->
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).
<!--ID: 1729804914203-->
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).
<!--ID: 1729804914204-->
END%%
## Bibliography ## Bibliography
* Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). * Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).

View File

@ -302,6 +302,14 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
<!--ID: 1728382784100--> <!--ID: 1728382784100-->
END%% 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.
<!--ID: 1729808568362-->
END%%
%%ANKI %%ANKI
Basic Basic
What does the `cltq` instruction do? What does the `cltq` instruction do?
@ -312,7 +320,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What equivalent instruction to the following does x86-64 provide? What equivalent no-operand instruction does x86-64 provide?
```asm ```asm
movslq %eax, %rax movslq %eax, %rax
``` ```
@ -323,7 +331,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What equivalent instruction to the following does x86-64 provide? What equivalent no-operand instruction does x86-64 provide?
```asm ```asm
movzlq %eax, %rax movzlq %eax, %rax
``` ```
@ -334,7 +342,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
How can the following instruction be rewritten using a MOV? How is the following instruction equivalently rewritten using MOV?
```asm ```asm
cltq cltq
``` ```

View File

@ -191,414 +191,195 @@ END%%
## Data Transfer ## 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 | The 7th argument is placed closer to the top of the stack (i.e. with lower address) than subsequent arguments.
| ---- | ------ | ------ | ------ | ------ | ------ | ------ |
| 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 %%ANKI
Basic Basic
How many registers are available for passing integral arguments between procedures? Which frame contains the 7th argument?
Back: `6` ```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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336766--> Tags: c17
<!--ID: 1729810820635-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
How many bytes make up the `%rdi` register? Which frame contains the return address?
Back: $8$ ```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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336770--> Tags: c17
<!--ID: 1729811536734-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
How many bytes make up the `%di` register? Which of the 7th or 8th argument has lower address?
Back: $2$ ```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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336774--> Tags: c17
<!--ID: 1729808568349-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
How many bytes make up the `%dil` register? Which of the 7th or 8th argument is nearer the stack's top?
Back: $1$ ```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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336779--> Tags: c17
<!--ID: 1729810820663-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
How many bytes make up the `%edi` register? Which arguments are placed onto the stack?
Back: $4$ ```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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336782--> Tags: c17
<!--ID: 1729810820678-->
END%% 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
<!--ID: 1729808568354-->
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
<!--ID: 1729808568358-->
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 %%ANKI
Cloze 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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336787--> Tags: c17
END%% <!--ID: 1729810820682-->
%%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.
<!--ID: 1728559336792-->
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.
<!--ID: 1728559336797-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
How do you access the low-order 2 bytes of `%rdi`? *Why* doesn't `P` have to allocate any local variables on the stack?
Back: By using `%di`. ```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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336802--> Tags: c17
<!--ID: 1729810820698-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
How do you access the low-order 4 bytes of `%rdi`? *Why* doesn't `P` have to allocate any local variables on the stack?
Back: By using `%edi`. ```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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336808--> Tags: c17
<!--ID: 1729810820701-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
How do you access the low-order byte of `%rdi`? Is `P`'s local stack variables or arguments to `Q` nearer the stack's top?
Back: By using `%dil`. ```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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336813--> Tags: c17
<!--ID: 1729811536739-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
Which register should the first integral argument of a procedure be placed in? Is `P`'s local stack variables or arguments to `Q` nearer the stack's top?
Back: `%rdi` ```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. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1728559336817--> Tags: c17
END%% <!--ID: 1729811536743-->
%%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.
<!--ID: 1728559336823-->
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.
<!--ID: 1728559336829-->
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.
<!--ID: 1728559336834-->
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.
<!--ID: 1728559336838-->
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.
<!--ID: 1728559336843-->
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.
<!--ID: 1728559336847-->
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.
<!--ID: 1728559336852-->
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.
<!--ID: 1728559336856-->
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.
<!--ID: 1728559336860-->
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.
<!--ID: 1728559336864-->
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.
<!--ID: 1728559336868-->
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.
<!--ID: 1728559336872-->
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.
<!--ID: 1728559336876-->
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.
<!--ID: 1728559336879-->
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.
<!--ID: 1729533668317-->
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.
<!--ID: 1729533668324-->
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.
<!--ID: 1729533668328-->
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.
<!--ID: 1729533668334-->
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.
<!--ID: 1729533668338-->
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.
<!--ID: 1729533668341-->
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.
<!--ID: 1729533668345-->
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.
<!--ID: 1729641729174-->
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.
<!--ID: 1729533668349-->
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.
<!--ID: 1729533668352-->
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.
<!--ID: 1729533668358-->
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.
<!--ID: 1729533668361-->
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.
<!--ID: 1729612004982-->
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.
<!--ID: 1729641729180-->
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.
<!--ID: 1729641729183-->
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.
<!--ID: 1729641729186-->
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.
<!--ID: 1729641729189-->
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.
<!--ID: 1729641729193-->
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.
<!--ID: 1729641729196-->
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.
<!--ID: 1729641729200-->
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.
<!--ID: 1729641729203-->
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.
<!--ID: 1729641729207-->
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.
<!--ID: 1729641729210-->
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.
<!--ID: 1729641729214-->
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.
<!--ID: 1729641729217-->
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.
<!--ID: 1729641729221-->
END%% END%%
## Bibliography ## Bibliography

View File

@ -300,6 +300,470 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
<!--ID: 1728558297568--> <!--ID: 1728558297568-->
END%% 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.
<!--ID: 1728559336766-->
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.
<!--ID: 1728559336770-->
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.
<!--ID: 1728559336774-->
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.
<!--ID: 1728559336779-->
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.
<!--ID: 1728559336782-->
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.
<!--ID: 1728559336787-->
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.
<!--ID: 1728559336792-->
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.
<!--ID: 1728559336797-->
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.
<!--ID: 1728559336802-->
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.
<!--ID: 1728559336808-->
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.
<!--ID: 1728559336813-->
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.
<!--ID: 1728559336817-->
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.
<!--ID: 1728559336823-->
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.
<!--ID: 1728559336829-->
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.
<!--ID: 1728559336834-->
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.
<!--ID: 1728559336838-->
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.
<!--ID: 1728559336843-->
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.
<!--ID: 1728559336847-->
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.
<!--ID: 1728559336852-->
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.
<!--ID: 1728559336856-->
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.
<!--ID: 1728559336860-->
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.
<!--ID: 1728559336864-->
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.
<!--ID: 1728559336868-->
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.
<!--ID: 1728559336872-->
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.
<!--ID: 1728559336876-->
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.
<!--ID: 1728559336879-->
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.
<!--ID: 1729533668317-->
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.
<!--ID: 1729533668324-->
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.
<!--ID: 1729533668328-->
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.
<!--ID: 1729533668334-->
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.
<!--ID: 1729533668338-->
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.
<!--ID: 1729533668341-->
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.
<!--ID: 1729533668345-->
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.
<!--ID: 1729641729174-->
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.
<!--ID: 1729533668349-->
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.
<!--ID: 1729533668352-->
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.
<!--ID: 1729533668358-->
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.
<!--ID: 1729533668361-->
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.
<!--ID: 1729612004982-->
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.
<!--ID: 1729641729180-->
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.
<!--ID: 1729641729183-->
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.
<!--ID: 1729641729186-->
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.
<!--ID: 1729641729189-->
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.
<!--ID: 1729641729193-->
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.
<!--ID: 1729641729196-->
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.
<!--ID: 1729641729200-->
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.
<!--ID: 1729641729203-->
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.
<!--ID: 1729641729207-->
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.
<!--ID: 1729641729210-->
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.
<!--ID: 1729641729214-->
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.
<!--ID: 1729641729217-->
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.
<!--ID: 1729641729221-->
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.
<!--ID: 1729810820710-->
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.
<!--ID: 1729810820713-->
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.
<!--ID: 1729810820715-->
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.
<!--ID: 1729810820718-->
END%%
## Condition Codes ## Condition Codes
The CPU also maintains a set of single-bit **condition code** registers describing attributes of the most recent arithmetic or logical operation. The CPU also maintains a set of single-bit **condition code** registers describing attributes of the most recent arithmetic or logical operation.