From bb6343317d237b975d64e6b2fab5109bbd5e1059 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Mon, 18 Nov 2024 08:40:19 -0700 Subject: [PATCH] Notes on caller- and callee-saved registers. --- .../plugins/obsidian-to-anki-plugin/data.json | 25 ++++++--- notes/_journal/2024-11-18.md | 9 +++ notes/_journal/{ => 2024-11}/2024-11-16.md | 0 notes/_journal/2024-11/2024-11-17.md | 9 +++ notes/algorithms/order-growth.md | 2 +- notes/c17/types/derived.md | 56 +++++++++++++++++++ notes/encoding/floating-point.md | 4 +- notes/hashing/addressing.md | 2 +- notes/set/graphs.md | 2 +- notes/set/natural-numbers.md | 6 +- notes/x86-64/registers.md | 48 ++++++++++++++++ 11 files changed, 147 insertions(+), 16 deletions(-) create mode 100644 notes/_journal/2024-11-18.md rename notes/_journal/{ => 2024-11}/2024-11-16.md (100%) create mode 100644 notes/_journal/2024-11/2024-11-17.md diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index 96f9ccd..0be9e49 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -263,7 +263,7 @@ "algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2", "algorithms/loop-invariant.md": "3b390e720f3b2a98e611b49a0bb1f5a9", "algorithms/running-time.md": "5efc0791097d2c996f931c9046c95f65", - "algorithms/order-growth.md": "1e5cbdfd9dea80ba284db3589f55e65f", + "algorithms/order-growth.md": "434073572a080e423c1bf464806c6d65", "_journal/2024-02-08.md": "19092bdfe378f31e2774f20d6afbfbac", "algorithms/sorting/selection-sort.md": "73415c44d6f4429f43c366078fd4bf98", "algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97", @@ -395,12 +395,12 @@ "_journal/2024-03/2024-03-15.md": "e54b2513beac5f46313b4c37622adf39", "_journal/2024-03-17.md": "72e99c7630085aee2c7f340a06b5ada7", "_journal/2024-03/2024-03-16.md": "ab7629c24ebe70838072cf6acec47cb0", - "encoding/floating-point.md": "3331bce1aaf94e0cf5d21d62af386d04", + "encoding/floating-point.md": "4e7a91995a82b6ce796b291de6a0c2bc", "_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f", "_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b", "set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53", "set/index.md": "29f5f295765101fe11d821faa908b027", - "set/graphs.md": "de5817ecac06f006c7f985cc1b45f67a", + "set/graphs.md": "cf09e6b0aaf61bc461f4fd3787dab682", "_journal/2024-03-19.md": "a0807691819725bf44c0262405e97cbb", "_journal/2024-03/2024-03-18.md": "2c711c50247a9880f7ed0d33b16e1101", "awk/variables.md": "e40a20545358228319f789243d8b9f77", @@ -526,7 +526,7 @@ "set/axioms.md": "063955bf19c703e9ad23be2aee4f1ab7", "_journal/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05/2024-05-13.md": "d549dd75fb42b4280d4914781edb0113", - "x86-64/registers.md": "89a6a1f731c643b6b72ff6a93e895a10", + "x86-64/registers.md": "a1daead80c55434c0aed939c53103f9d", "_journal/2024-05-15.md": "4e6a7e6df32e93f0d8a56bc76613d908", "_journal/2024-05/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05-16.md": "580c7ec61ec56be92fa8d6affcf0a5f6", @@ -673,7 +673,7 @@ "_journal/2024-07-13.md": "13b5101306b5542b8a1381a6477378ca", "_journal/2024-07/2024-07-12.md": "8073584fae2fe7bffcd4b69a7cd29058", "hashing/static.md": "3ec6eaee73fb9b599700f5a56b300b83", - "hashing/addressing.md": "c068221b70d2e37b8978951e1b91acd9", + "hashing/addressing.md": "d00477899acfdb87c7f5d4e6493faa58", "ontology/index.md": "0994403dcd84415f1459752129b55f65", "ontology/permissivism.md": "643e815a79bc5c050cde9f996aa44ef5", "ontology/properties.md": "91ece501551c444afcd119d7197958ef", @@ -788,7 +788,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": "6219f07da2d79fba29bb16bcd2f48ce2", + "set/natural-numbers.md": "3a49690199a943ca8038040278060585", "_journal/2024-08-24.md": "563fad24740e44734a87d7c3ec46cec4", "_journal/2024-08/2024-08-23.md": "7b5a40e83d8f07ff54cd9708017d029c", "_journal/2024-08/2024-08-22.md": "050235d5dc772b542773743b57ce3afe", @@ -798,7 +798,7 @@ "c17/basic-types.md": "7c6653bf6dc24c2f2aa72fc95c4f7875", "c17/types/simple.md": "44d56a2998f3bba578f14672c8b0ee3c", "c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d", - "c17/types/derived.md": "ac1651775cc1a75247da176627fcf421", + "c17/types/derived.md": "7e5d0939f72ee02ae00a78a2af17a0fd", "c17/types/basic.md": "5064e21e683c0218890058882e06b6f3", "c17/types/index.md": "14b651bcfc8b2d62ffd200a74a9a2a6b", "_journal/2024-08-25.md": "e73a8edbd027d0f1a39289540eb512f2", @@ -931,7 +931,16 @@ "geometry/cartesian.md": "b7003f70ab4822aa6eb4b84ba35f6e65", "geometry/index.md": "679dcd097f4bebe417828c695444c88c", "_journal/2024-11-10.md": "5478337fd2017b99d0b359713a511e66", - "_journal/2024-11/2024-11-09.md": "46f3a640223ef533f4523837b67b57c3" + "_journal/2024-11/2024-11-09.md": "46f3a640223ef533f4523837b67b57c3", + "_journal/2024-11-18.md": "5567592053951cee80450cf582df270a", + "_journal/2024-11/2024-11-17.md": "76f5c49cb9b8722bbdac76a5e87f688c", + "_journal/2024-11/2024-11-16.md": "db4f2e5db5bb1d2199fee88eb1a6c881", + "_journal/2024-11/2024-11-15.md": "db4f2e5db5bb1d2199fee88eb1a6c881", + "_journal/2024-11/2024-11-14.md": "db4f2e5db5bb1d2199fee88eb1a6c881", + "_journal/2024-11/2024-11-13.md": "db4f2e5db5bb1d2199fee88eb1a6c881", + "_journal/2024-11/2024-11-12.md": "24c858a93c0a5063820bd96207e6f8ab", + "_journal/2024-11/2024-11-11.md": "d3ad8ddc5ecdb2cc08773fdef2ce6869", + "_journal/2024-11/2024-11-10.md": "38ce405754e3823c8239df44546f3b35" }, "fields_dict": { "Basic": [ diff --git a/notes/_journal/2024-11-18.md b/notes/_journal/2024-11-18.md new file mode 100644 index 0000000..cde020a --- /dev/null +++ b/notes/_journal/2024-11-18.md @@ -0,0 +1,9 @@ +--- +title: "2024-11-18" +--- + +- [ ] Anki Flashcards +- [x] KoL +- [ ] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) \ No newline at end of file diff --git a/notes/_journal/2024-11-16.md b/notes/_journal/2024-11/2024-11-16.md similarity index 100% rename from notes/_journal/2024-11-16.md rename to notes/_journal/2024-11/2024-11-16.md diff --git a/notes/_journal/2024-11/2024-11-17.md b/notes/_journal/2024-11/2024-11-17.md new file mode 100644 index 0000000..61ec93a --- /dev/null +++ b/notes/_journal/2024-11/2024-11-17.md @@ -0,0 +1,9 @@ +--- +title: "2024-11-18" +--- + +- [x] Anki Flashcards +- [x] KoL +- [ ] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) \ No newline at end of file diff --git a/notes/algorithms/order-growth.md b/notes/algorithms/order-growth.md index e84d770..e613a1e 100644 --- a/notes/algorithms/order-growth.md +++ b/notes/algorithms/order-growth.md @@ -1195,7 +1195,7 @@ END%% %%ANKI Basic What is the reflexive property of $\omega$-notation? -Back: N/A +Back: N/A. Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). END%% diff --git a/notes/c17/types/derived.md b/notes/c17/types/derived.md index 7dc7c04..b8d0983 100644 --- a/notes/c17/types/derived.md +++ b/notes/c17/types/derived.md @@ -1026,6 +1026,62 @@ Tags: x86-64 END%% +%%ANKI +Basic +Suppose `char *p` has address `S`. What is the result of the following? +```c +(int *) p + 7 +``` +Back: `S + 28` +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 +Suppose `char *p` has address `S`. What is the result of the following? +```c +(int *) (p + 7) +``` +Back: `S + 7` +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 we declare a function pointer `fp` to the following? +```c +int foo(int x, int *p); +``` +Back: +```c +int (*fp)(int, int *); +``` +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 do the following two lines declare instances of? +```c +int (*fp)(int, int *); +int *fp(int, int *); +``` +Back: The first is a function pointer. The second is a function. +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 is the value of a function pointer? +Back: The address of the first instruction in the function's machine-code representation. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + ## Bibliography * Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. diff --git a/notes/encoding/floating-point.md b/notes/encoding/floating-point.md index 06c1651..20d6bd3 100644 --- a/notes/encoding/floating-point.md +++ b/notes/encoding/floating-point.md @@ -1325,8 +1325,8 @@ END%% %%ANKI Basic -What is the most important group quality $+^f$ is lacking? -Back: Associativity. +What are the most important group qualities $+^f$ is lacking? +Back: Associativity and commutativity. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% diff --git a/notes/hashing/addressing.md b/notes/hashing/addressing.md index 5e3d383..7618873 100644 --- a/notes/hashing/addressing.md +++ b/notes/hashing/addressing.md @@ -546,7 +546,7 @@ END%% %%ANKI Basic -When is the load factor of a open addressing hash table $1$? +When does the load factor of an open addressing hash table equal $1$? Back: When there exist the same number of total entries as slots. Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). diff --git a/notes/set/graphs.md b/notes/set/graphs.md index 261c5b7..de5f8d4 100644 --- a/notes/set/graphs.md +++ b/notes/set/graphs.md @@ -961,7 +961,7 @@ END%% Basic What are the paths from vertex $3$ to vertex $6$? ![[directed-graph-example.png]] -Back: N/A +Back: N/A. Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). END%% diff --git a/notes/set/natural-numbers.md b/notes/set/natural-numbers.md index 8ec7c6a..66d63bc 100644 --- a/notes/set/natural-numbers.md +++ b/notes/set/natural-numbers.md @@ -291,7 +291,7 @@ END%% %%ANKI Basic -What can be said about a subset of $\omega$? +What can be said about subsets of $\omega$? Back: N/A. Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). @@ -299,8 +299,8 @@ END%% %%ANKI Basic -What can be said about an inductive subset of $\omega$? -Back: It must coincide with $\omega$. +What can be said about inductive subsets of $\omega$? +Back: They must coincide with $\omega$. Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). END%% diff --git a/notes/x86-64/registers.md b/notes/x86-64/registers.md index 7fd84d2..8583606 100644 --- a/notes/x86-64/registers.md +++ b/notes/x86-64/registers.md @@ -307,6 +307,54 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program END%% +%%ANKI +Basic +Which number-suffixed register(s) are used for passing integral arguments to procedures? +Back: `%r8` and `%r9`. +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 number-suffixed register(s) are conventionally designated "callee-saved"? +Back: `%r12`, `%13`, `%r14`, and `%r15`. +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 number-suffixed register(s) are conventionally designated "caller-saved"? +Back: `%r10` and `%r11`. +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 it mean for a register to be callee-saved? +Back: The callee must ensure the register's value is unchanged by the time it returns. +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 it mean for a register to be caller-saved? +Back: Any procedure can modify the register's value. +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 +*Why* are caller-saved registers named the way they are? +Back: It's up to the caller to preserve their value before a procedure call. +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.