x86-64 procedures.
parent
926f709811
commit
a5b3b4f1af
|
@ -326,7 +326,7 @@
|
||||||
"_journal/2024-02/2024-02-21.md": "f423137ae550eb958378750d1f5e98c7",
|
"_journal/2024-02/2024-02-21.md": "f423137ae550eb958378750d1f5e98c7",
|
||||||
"_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": "84c9b2b98d58bad9f057596a78901b13",
|
"c17/strings.md": "e909daa71ad93bcb38edbe30bc0516ac",
|
||||||
"c17/index.md": "02722edf46dd45f732996eaa1980944f",
|
"c17/index.md": "02722edf46dd45f732996eaa1980944f",
|
||||||
"c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500",
|
"c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500",
|
||||||
"c17/declarations.md": "2d7877915bf8a2772d1e4de636ba52a5",
|
"c17/declarations.md": "2d7877915bf8a2772d1e4de636ba52a5",
|
||||||
|
@ -521,7 +521,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": "5f1c601930681df39a0b24b55fa4c593",
|
"x86-64/registers.md": "35f4e2f7e1a988f98dc0f89f29731f11",
|
||||||
"_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",
|
||||||
|
@ -532,7 +532,7 @@
|
||||||
"_journal/2024-05/2024-05-16.md": "9fdfadc3f9ea6a4418fd0e7066d6b10c",
|
"_journal/2024-05/2024-05-16.md": "9fdfadc3f9ea6a4418fd0e7066d6b10c",
|
||||||
"_journal/2024-05-18.md": "c0b58b28f84b31cea91404f43b0ee40c",
|
"_journal/2024-05-18.md": "c0b58b28f84b31cea91404f43b0ee40c",
|
||||||
"hashing/direct-addressing.md": "f75cc22e74ae974fe4f568a2ee9f951f",
|
"hashing/direct-addressing.md": "f75cc22e74ae974fe4f568a2ee9f951f",
|
||||||
"hashing/index.md": "f1dbb16667b056f2ea00db8db805c54f",
|
"hashing/index.md": "6b65a79afe7eac5aa960023f738b8f35",
|
||||||
"set/classes.md": "6776b4dc415021e0ef60b323b5c2d436",
|
"set/classes.md": "6776b4dc415021e0ef60b323b5c2d436",
|
||||||
"_journal/2024-05-19.md": "fddd90fae08fab9bd83b0ef5d362c93a",
|
"_journal/2024-05-19.md": "fddd90fae08fab9bd83b0ef5d362c93a",
|
||||||
"_journal/2024-05/2024-05-18.md": "c0b58b28f84b31cea91404f43b0ee40c",
|
"_journal/2024-05/2024-05-18.md": "c0b58b28f84b31cea91404f43b0ee40c",
|
||||||
|
@ -580,7 +580,7 @@
|
||||||
"_journal/2024-06/2024-06-04.md": "52b28035b9c91c9b14cef1154c1a0fa1",
|
"_journal/2024-06/2024-06-04.md": "52b28035b9c91c9b14cef1154c1a0fa1",
|
||||||
"_journal/2024-06-06.md": "3f9109925dea304e7172df39922cc95a",
|
"_journal/2024-06-06.md": "3f9109925dea304e7172df39922cc95a",
|
||||||
"_journal/2024-06/2024-06-05.md": "b06a0fa567bd81e3b593f7e1838f9de1",
|
"_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-07.md": "795be41cc3c9c0f27361696d237604a2",
|
||||||
"_journal/2024-06/2024-06-06.md": "db3407dcc86fa759b061246ec9fbd381",
|
"_journal/2024-06/2024-06-06.md": "db3407dcc86fa759b061246ec9fbd381",
|
||||||
"_journal/2024-06-08.md": "b20d39dab30b4e12559a831ab8d2f9b8",
|
"_journal/2024-06-08.md": "b20d39dab30b4e12559a831ab8d2f9b8",
|
||||||
|
@ -590,7 +590,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": "3efe399b89b947ab280dc1e045675390",
|
"x86-64/instructions/access.md": "e54dfbaf4906886d550baa5736f4731f",
|
||||||
"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",
|
||||||
|
@ -783,7 +783,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": "72b6ffb986e47609bf8c41d6711d4372",
|
"set/natural-numbers.md": "fdb3bb9e0fd74f74496e9b03f05d26a2",
|
||||||
"_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",
|
||||||
|
@ -793,7 +793,7 @@
|
||||||
"c17/basic-types.md": "7c6653bf6dc24c2f2aa72fc95c4f7875",
|
"c17/basic-types.md": "7c6653bf6dc24c2f2aa72fc95c4f7875",
|
||||||
"c17/types/simple.md": "502c7a742e8516057f820c75cc7a096e",
|
"c17/types/simple.md": "502c7a742e8516057f820c75cc7a096e",
|
||||||
"c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d",
|
"c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d",
|
||||||
"c17/types/derived.md": "4bc5b8d8a8d24a9048f2a0e1c96af8ab",
|
"c17/types/derived.md": "cd77112313bd0f9cf99b0f224a364179",
|
||||||
"c17/types/basic.md": "5064e21e683c0218890058882e06b6f3",
|
"c17/types/basic.md": "5064e21e683c0218890058882e06b6f3",
|
||||||
"c17/types/index.md": "14b651bcfc8b2d62ffd200a74a9a2a6b",
|
"c17/types/index.md": "14b651bcfc8b2d62ffd200a74a9a2a6b",
|
||||||
"_journal/2024-08-25.md": "e73a8edbd027d0f1a39289540eb512f2",
|
"_journal/2024-08-25.md": "e73a8edbd027d0f1a39289540eb512f2",
|
||||||
|
@ -868,7 +868,15 @@
|
||||||
"_journal/2024-10-06.md": "851efa5156caadd79c898538a153c0dd",
|
"_journal/2024-10-06.md": "851efa5156caadd79c898538a153c0dd",
|
||||||
"_journal/2024-10/2024-10-05.md": "88b4c0155583394ece5f16c01e051019",
|
"_journal/2024-10/2024-10-05.md": "88b4c0155583394ece5f16c01e051019",
|
||||||
"_journal/2024-10/2024-10-04.md": "6836a9c6eff8b5723ef474f4f4c298ed",
|
"_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": {
|
"fields_dict": {
|
||||||
"Basic": [
|
"Basic": [
|
||||||
|
|
|
@ -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.
|
|
@ -2,7 +2,7 @@
|
||||||
title: "2024-10-07"
|
title: "2024-10-07"
|
||||||
---
|
---
|
||||||
|
|
||||||
- [ ] Anki Flashcards
|
- [x] Anki Flashcards
|
||||||
- [x] KoL
|
- [x] KoL
|
||||||
- [x] OGS
|
- [x] OGS
|
||||||
- [ ] Sheet Music (10 min.)
|
- [ ] Sheet Music (10 min.)
|
|
@ -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.
|
|
@ -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]].
|
|
@ -44,7 +44,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What kind of array has literals?
|
What kind of array can be expressed as a literal?
|
||||||
Back: Strings.
|
Back: Strings.
|
||||||
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
<!--ID: 1728244147668-->
|
<!--ID: 1728244147668-->
|
||||||
|
|
|
@ -333,20 +333,6 @@ Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co
|
||||||
<!--ID: 1728244147560-->
|
<!--ID: 1728244147560-->
|
||||||
END%%
|
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).
|
|
||||||
<!--ID: 1728244147578-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Why shouldn't you use the `sizeof` operator on array parameters to functions?
|
Why shouldn't you use the `sizeof` operator on array parameters to functions?
|
||||||
|
|
|
@ -26,22 +26,6 @@ Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (
|
||||||
<!--ID: 1716307180959-->
|
<!--ID: 1716307180959-->
|
||||||
END%%
|
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).
|
|
||||||
<!--ID: 1716307180961-->
|
|
||||||
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).
|
|
||||||
<!--ID: 1716307180962-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Given a hash table `T[0:m-1]`, what is the domain of a hash function?
|
Given a hash table `T[0:m-1]`, what is the domain of a hash function?
|
||||||
|
|
|
@ -730,7 +730,7 @@ END%%
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Suppose $A \cap B = A$. What relation immediately follows?
|
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).
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
<!--ID: 1726797814900-->
|
<!--ID: 1726797814900-->
|
||||||
END%%
|
END%%
|
||||||
|
|
|
@ -703,14 +703,6 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
|
||||||
<!--ID: 1721870888384-->
|
<!--ID: 1721870888384-->
|
||||||
END%%
|
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).
|
|
||||||
<!--ID: 1721870888391-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
*Why* isn't $R = \{\langle a, a \rangle, \langle b, c \rangle\}$ irreflexive on $\{a\}$?
|
*Why* isn't $R = \{\langle a, a \rangle, \langle b, c \rangle\}$ irreflexive on $\{a\}$?
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
|
@ -294,6 +294,55 @@ Tags: c17
|
||||||
<!--ID: 1714677608754-->
|
<!--ID: 1714677608754-->
|
||||||
END%%
|
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.
|
||||||
|
<!--ID: 1728382784100-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728382784104-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728382784107-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728479148446-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728382784110-->
|
||||||
|
END%%
|
||||||
|
|
||||||
## PUSH and POP
|
## PUSH and POP
|
||||||
|
|
||||||
| Instruction | Operands | Effect | Description |
|
| Instruction | Operands | Effect | Description |
|
||||||
|
|
|
@ -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.
|
||||||
|
<!--ID: 1728480337611-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728480337614-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728480337617-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728480337621-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728480337604-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728481058927-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728481058953-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728481058960-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728481058966-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728558288130-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728558288148-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728558288160-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728558288165-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728558288171-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728558288177-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728558288183-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728559336730-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728559336760-->
|
||||||
|
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.
|
||||||
|
<!--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%%
|
||||||
|
|
||||||
|
## Bibliography
|
||||||
|
|
||||||
|
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
@ -285,6 +285,21 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
||||||
<!--ID: 1724119420122-->
|
<!--ID: 1724119420122-->
|
||||||
END%%
|
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.
|
||||||
|
<!--ID: 1728558288189-->
|
||||||
|
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.
|
||||||
|
<!--ID: 1728558297568-->
|
||||||
|
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.
|
||||||
|
|
Loading…
Reference in New Issue