diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index d62403e..1927571 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -326,7 +326,7 @@ "_journal/2024-02/2024-02-21.md": "f423137ae550eb958378750d1f5e98c7", "_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd", "_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b", - "c17/strings.md": "84c9b2b98d58bad9f057596a78901b13", + "c17/strings.md": "e909daa71ad93bcb38edbe30bc0516ac", "c17/index.md": "02722edf46dd45f732996eaa1980944f", "c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500", "c17/declarations.md": "2d7877915bf8a2772d1e4de636ba52a5", @@ -521,7 +521,7 @@ "set/axioms.md": "063955bf19c703e9ad23be2aee4f1ab7", "_journal/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05/2024-05-13.md": "d549dd75fb42b4280d4914781edb0113", - "x86-64/registers.md": "5f1c601930681df39a0b24b55fa4c593", + "x86-64/registers.md": "35f4e2f7e1a988f98dc0f89f29731f11", "_journal/2024-05-15.md": "4e6a7e6df32e93f0d8a56bc76613d908", "_journal/2024-05/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05-16.md": "580c7ec61ec56be92fa8d6affcf0a5f6", @@ -532,7 +532,7 @@ "_journal/2024-05/2024-05-16.md": "9fdfadc3f9ea6a4418fd0e7066d6b10c", "_journal/2024-05-18.md": "c0b58b28f84b31cea91404f43b0ee40c", "hashing/direct-addressing.md": "f75cc22e74ae974fe4f568a2ee9f951f", - "hashing/index.md": "f1dbb16667b056f2ea00db8db805c54f", + "hashing/index.md": "6b65a79afe7eac5aa960023f738b8f35", "set/classes.md": "6776b4dc415021e0ef60b323b5c2d436", "_journal/2024-05-19.md": "fddd90fae08fab9bd83b0ef5d362c93a", "_journal/2024-05/2024-05-18.md": "c0b58b28f84b31cea91404f43b0ee40c", @@ -580,7 +580,7 @@ "_journal/2024-06/2024-06-04.md": "52b28035b9c91c9b14cef1154c1a0fa1", "_journal/2024-06-06.md": "3f9109925dea304e7172df39922cc95a", "_journal/2024-06/2024-06-05.md": "b06a0fa567bd81e3b593f7e1838f9de1", - "set/relations.md": "18d3f9a6bec2a23a576910750fd2158d", + "set/relations.md": "2759e68e8dd19f513fca2da8d2506433", "_journal/2024-06-07.md": "795be41cc3c9c0f27361696d237604a2", "_journal/2024-06/2024-06-06.md": "db3407dcc86fa759b061246ec9fbd381", "_journal/2024-06-08.md": "b20d39dab30b4e12559a831ab8d2f9b8", @@ -590,7 +590,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": "3efe399b89b947ab280dc1e045675390", + "x86-64/instructions/access.md": "e54dfbaf4906886d550baa5736f4731f", "x86-64/instructions/index.md": "72c19067e938ab39ea51d25d6ac2bad9", "_journal/2024-06-09.md": "935b3ddf65c51e680ac5c000c7e380af", "_journal/2024-06/2024-06-08.md": "9e1ebc8882a395b96ca765ad5c982d68", @@ -783,7 +783,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": "72b6ffb986e47609bf8c41d6711d4372", + "set/natural-numbers.md": "fdb3bb9e0fd74f74496e9b03f05d26a2", "_journal/2024-08-24.md": "563fad24740e44734a87d7c3ec46cec4", "_journal/2024-08/2024-08-23.md": "7b5a40e83d8f07ff54cd9708017d029c", "_journal/2024-08/2024-08-22.md": "050235d5dc772b542773743b57ce3afe", @@ -793,7 +793,7 @@ "c17/basic-types.md": "7c6653bf6dc24c2f2aa72fc95c4f7875", "c17/types/simple.md": "502c7a742e8516057f820c75cc7a096e", "c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d", - "c17/types/derived.md": "4bc5b8d8a8d24a9048f2a0e1c96af8ab", + "c17/types/derived.md": "cd77112313bd0f9cf99b0f224a364179", "c17/types/basic.md": "5064e21e683c0218890058882e06b6f3", "c17/types/index.md": "14b651bcfc8b2d62ffd200a74a9a2a6b", "_journal/2024-08-25.md": "e73a8edbd027d0f1a39289540eb512f2", @@ -868,7 +868,15 @@ "_journal/2024-10-06.md": "851efa5156caadd79c898538a153c0dd", "_journal/2024-10/2024-10-05.md": "88b4c0155583394ece5f16c01e051019", "_journal/2024-10/2024-10-04.md": "6836a9c6eff8b5723ef474f4f4c298ed", - "_journal/2024-10/2024-10-03.md": "3f8c9a05e129ac698bad77873f114fe0" + "_journal/2024-10/2024-10-03.md": "3f8c9a05e129ac698bad77873f114fe0", + "_journal/2024-10-08.md": "213a5f689c450edbbedd0587200d5fd0", + "_journal/2024-10/2024-10-07.md": "a4e7bcbcbf0a02dd810a316023182c51", + "_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": "c36268b99c0681bfca245e0538a302e0", + "_journal/2024-10-10.md": "29e4be2c164c63f8b7aab56bddee3dd6", + "_journal/2024-10/2024-10-09.md": "b718c6f4cfe3069fcc0faf07ec414f73" }, "fields_dict": { "Basic": [ diff --git a/notes/_journal/2024-10-10.md b/notes/_journal/2024-10-10.md new file mode 100644 index 0000000..39986dd --- /dev/null +++ b/notes/_journal/2024-10-10.md @@ -0,0 +1,11 @@ +--- +title: "2024-10-10" +--- + +- [x] Anki Flashcards +- [x] KoL +- [x] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) + +* Continuing notes on x86 procedures. Control and data transfer. \ No newline at end of file diff --git a/notes/_journal/2024-10-07.md b/notes/_journal/2024-10/2024-10-07.md similarity index 61% rename from notes/_journal/2024-10-07.md rename to notes/_journal/2024-10/2024-10-07.md index 6f3aad2..60b6288 100644 --- a/notes/_journal/2024-10-07.md +++ b/notes/_journal/2024-10/2024-10-07.md @@ -2,7 +2,7 @@ title: "2024-10-07" --- -- [ ] Anki Flashcards +- [x] Anki Flashcards - [x] KoL - [x] OGS - [ ] Sheet Music (10 min.) diff --git a/notes/_journal/2024-10/2024-10-08.md b/notes/_journal/2024-10/2024-10-08.md new file mode 100644 index 0000000..bca247b --- /dev/null +++ b/notes/_journal/2024-10/2024-10-08.md @@ -0,0 +1,11 @@ +--- +title: "2024-10-08" +--- + +- [x] Anki Flashcards +- [x] KoL +- [ ] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) + +* Read through CS:APP section on procedure calls. Still need to make notes. \ No newline at end of file diff --git a/notes/_journal/2024-10/2024-10-09.md b/notes/_journal/2024-10/2024-10-09.md new file mode 100644 index 0000000..d2f9552 --- /dev/null +++ b/notes/_journal/2024-10/2024-10-09.md @@ -0,0 +1,11 @@ +--- +title: "2024-10-09" +--- + +- [x] Anki Flashcards +- [x] KoL +- [x] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) + +* Start adding notes on [[procedures]]. \ No newline at end of file diff --git a/notes/c17/strings.md b/notes/c17/strings.md index fe2c707..83ba1b6 100644 --- a/notes/c17/strings.md +++ b/notes/c17/strings.md @@ -44,7 +44,7 @@ END%% %%ANKI Basic -What kind of array has literals? +What kind of array can be expressed as a literal? Back: Strings. Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). diff --git a/notes/c17/types/derived.md b/notes/c17/types/derived.md index 8c75f44..1281af9 100644 --- a/notes/c17/types/derived.md +++ b/notes/c17/types/derived.md @@ -333,20 +333,6 @@ Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co END%% -%%ANKI -Basic -Suppose I pass the following array to a function. What does the parameter look like? -```c -double a[M][N][P]; -``` -Back: -```c -double a[][N][P]; -``` -Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). - -END%% - %%ANKI Basic Why shouldn't you use the `sizeof` operator on array parameters to functions? diff --git a/notes/hashing/index.md b/notes/hashing/index.md index 502d991..b5a6c91 100644 --- a/notes/hashing/index.md +++ b/notes/hashing/index.md @@ -26,22 +26,6 @@ Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition ( END%% -%%ANKI -Basic -Given a hash table with hash function $h$, the element at slot $k$ has what key? -Back: A key $k'$ such that $h(k') = k$. -Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). - -END%% - -%%ANKI -Basic -Given a hash table with hash function $h$, an element with key $k$ is placed in what slot? -Back: $h(k)$ -Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022). - -END%% - %%ANKI Basic Given a hash table `T[0:m-1]`, what is the domain of a hash function? diff --git a/notes/set/natural-numbers.md b/notes/set/natural-numbers.md index cd53e86..0ff5339 100644 --- a/notes/set/natural-numbers.md +++ b/notes/set/natural-numbers.md @@ -730,7 +730,7 @@ END%% %%ANKI Basic Suppose $A \cap B = A$. What relation immediately follows? -Back: $B = A$ +Back: $A \subseteq B$ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). END%% diff --git a/notes/set/relations.md b/notes/set/relations.md index 266a17b..0f1fd89 100644 --- a/notes/set/relations.md +++ b/notes/set/relations.md @@ -703,14 +703,6 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre END%% -%%ANKI -Basic -Given $R = \{\langle a, a \rangle, \langle b, c \rangle\}$, is $R$ irreflexive on $a$? -Back: N/A. We should ask if $R$ is irreflexive on set $\{a\}$. -Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). - -END%% - %%ANKI Basic *Why* isn't $R = \{\langle a, a \rangle, \langle b, c \rangle\}$ irreflexive on $\{a\}$? diff --git a/notes/x86-64/images/x86-64-stack.png b/notes/x86-64/images/x86-64-stack.png new file mode 100644 index 0000000..7b8c789 Binary files /dev/null and b/notes/x86-64/images/x86-64-stack.png differ diff --git a/notes/x86-64/instructions/access.md b/notes/x86-64/instructions/access.md index d9bf724..59300ea 100644 --- a/notes/x86-64/instructions/access.md +++ b/notes/x86-64/instructions/access.md @@ -294,6 +294,55 @@ Tags: c17 END%% +%%ANKI +Basic +Which register does `cltq` target? +Back: `%rax` +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? +Back: Sign extends `%eax` to `%rax`. +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 equivalent instruction to the following does x86-64 provide? +```asm +movslq %eax, %rax +``` +Back: `cltq` +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 equivalent instruction to the following does x86-64 provide? +```asm +movzlq %eax, %rax +``` +Back: N/A. +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 can the following instruction be rewritten using a MOV? +```asm +cltq +``` +Back: `movslq %eax, %rax` +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + ## PUSH and POP | Instruction | Operands | Effect | Description | diff --git a/notes/x86-64/procedures.md b/notes/x86-64/procedures.md new file mode 100644 index 0000000..a688f63 --- /dev/null +++ b/notes/x86-64/procedures.md @@ -0,0 +1,406 @@ +--- +title: Procedures +TARGET DECK: Obsidian::STEM +FILE TAGS: x86-64 +tags: + - x86-64 +--- + +## Overview + +The x86-64 stack grows towards lower addresses. When a procedure is invoked, more spack on the top of the stack is allocated for that procedure to make use of. This portion of the stack is called a **frame**. The general shape of the stack looks as follows: + +![[x86-64-stack.png]] + +Note parts of this diagram are omitted when possible. For instance, a stack frame may not exist at all if all arguments to a **leaf procedure** can be passed through registers. A leaf procedure is a function that does not call another function. + +%%ANKII +Basic +What ADT is used internally in procedure-calling mechanisms? +Back: A stack. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. +END%% + +%%ANKII +Cloze +The x86-64 stack grows towards {lower} addresses. +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 a frame w.r.t. the x86-64 stack? +Back: A region of the stack dedicated to a particular function call. +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 instructions are used to store and retrieve from the x86-64 stack? +Back: `pushq` and `popq`. +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 "stack pointer" refer to w.r.t. the x86-64 stack? +Back: Register `%rsp`. +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 is the stack pointer manipulated to allocate space on the x86-64 stack? +Back: By decrementing `%rsp` by an appropriate amount. +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 is the stack pointer manipulated to deallocate space on the x86-64 stack? +Back: By incrementing `%rsp` by an appropriate amount. +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 procedure `P` calls `Q`. What data sits at the end of `P`'s frame? +Back: A return address. +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 +A {leaf} procedure is a function that {does not call another 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 +Suppose procedure `P` calls `Q`. The return address belongs to who's frame? +Back: `P` +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 procedure `P` calls `Q`. Why is the return address considered to be in `P`'s frame? +Back: It is state relevant to `P`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +## Control Transfer + +Like [[conditions#JMP|JMP]] instructions, `call` allows specifying a direct or indirect operand. `call` pushes the address of the instruction following it onto the stack and updates the PC to the operand. `ret` reverts these steps. + +| Instruction | Operands | Description | +| ----------- | ----------- | ---------------- | +| `call` | Label | Procedure call | +| `call` | \**Operand* | Procedure call | +| `ret` | | Return from call | + +%%ANKI +Cloze +The {`call`} instruction is the counterpart to the {`ret`} instruction. +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 two things does the `call` instruction do? +Back: It pushes the return address on the stack and updates the PC. +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 two things does the `ret` instruction do? +Back: It pops the return address off the stack and updates the PC. +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 +The operand forms of `call` mirror what other instruction class? +Back: `JMP` +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 +A `call` instruction pushes what address onto the stack? +Back: That of the instruction following the `call` instruction. +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 return address is pushed onto the stack after `call` is run? +```x86 +1: ... +2: callq .L1 +3: ... +``` +Back: `3` +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 address is the PC updated to after `call` is run? +```x86 +1: ... +2: callq .L1 +3: ... +``` +Back: That corresponding to label `.L1`. +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(s) does a `call` instruction update? +Back: `%rsp` and `%rip`. +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(s) does a `ret` instruction update? +Back: `%rsp` and `%rip`. +Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. + +END%% + +## Data Transfer + +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%% + +## 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/x86-64/registers.md b/notes/x86-64/registers.md index e101514..7311c99 100644 --- a/notes/x86-64/registers.md +++ b/notes/x86-64/registers.md @@ -285,6 +285,21 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program END%% +%%ANKI +Cloze +By convention, register {`%rip`} is used for {the program counter}. +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 is used to track the instruction to execute next? +Back: `%rip` +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.