C lvalues/rvalues, objects, and values.
parent
9101fa8a7a
commit
d5bb63618f
|
@ -309,9 +309,9 @@
|
|||
"_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd",
|
||||
"_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b",
|
||||
"c17/strings.md": "2da50edd26eae35c81f70e65bbd12d49",
|
||||
"c17/index.md": "78576ee41d0185df82c59999142f4edb",
|
||||
"c17/index.md": "7662b066e7cf52e94d21fed57dfe227f",
|
||||
"c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500",
|
||||
"c17/declarations.md": "e5b4268270bcec35e6f2e4b727c5494e",
|
||||
"c17/declarations.md": "9d0cf7a345d89b454447b3f66d4b7b64",
|
||||
"algorithms/sorting/merge-sort.md": "6506483f7df6507cee0407bd205dbedd",
|
||||
"_journal/2024-02-24.md": "9bb319d5014caf962a9ce3141076cff4",
|
||||
"_journal/2024-02/2024-02-23.md": "0aad297148e8cc4058b48b7e45787ca7",
|
||||
|
@ -569,7 +569,7 @@
|
|||
"_journal/2024-06/2024-06-07.md": "c6bfc4c1e5913d23ea7828a23340e7d3",
|
||||
"lambda-calculus/alpha-conversion.md": "6df655e60976715e5c6fbbe72b628c6d",
|
||||
"lambda-calculus/index.md": "76d58f85c135c7df00081f47df31168e",
|
||||
"x86-64/instructions/condition-codes.md": "77eda8d73ab458bd5ae2e6e11582be74",
|
||||
"x86-64/instructions/condition-codes.md": "b9430cc0ad207f210a8d5ca6dacccbd5",
|
||||
"x86-64/instructions/logical.md": "818428b9ef84753920dc61e5c2de9199",
|
||||
"x86-64/instructions/arithmetic.md": "271218d855e7291f119f96e91f582738",
|
||||
"x86-64/instructions/access.md": "c19bc3392cf493fcc9becf46c818cc50",
|
||||
|
@ -736,7 +736,9 @@
|
|||
"_journal/2024-08/2024-08-09.md": "2ce3e0c468f51750d8ad86a19bcc3264",
|
||||
"_journal/2024-08-11.md": "acc91e07b43590e90846d2c936dcb3d5",
|
||||
"_journal/2024-08/2024-08-10.md": "08e7ea4a78c46645b93ec51e2372d04f",
|
||||
"_journal/2024-08-12.md": "dbce7846aa65606fe528e4cd51022a9f"
|
||||
"_journal/2024-08-12.md": "8a37a2d1381f9d9e29d83031bad80dd0",
|
||||
"_journal/2024-08/2024-08-11.md": "acc91e07b43590e90846d2c936dcb3d5",
|
||||
"c17/types.md": "2bca56b2d95cc358553fb798acde6522"
|
||||
},
|
||||
"fields_dict": {
|
||||
"Basic": [
|
||||
|
|
|
@ -9,3 +9,4 @@ title: "2024-08-12"
|
|||
- [ ] Korean (Read 1 Story)
|
||||
|
||||
* Add more SET condition code checks.
|
||||
* Notes on C lvalues and rvalues, objects and values.
|
|
@ -8,7 +8,7 @@ tags:
|
|||
|
||||
## Overview
|
||||
|
||||
C declarations were designed so that the declaration of an object looks like the use of the object. This isn't quite true - keywords like `volatile` and `const` only exist in declarations - but for the most part, this philosophy can be leveraged to read C declarations.
|
||||
C declarations were designed so that the **declaration** of an object looks like the use of the object. This isn't quite true - keywords like `volatile` and `const` only exist in declarations - but for the most part, this philosophy can be leveraged to read C declarations.
|
||||
|
||||
## Declarators
|
||||
|
||||
|
@ -911,4 +911,5 @@ END%%
|
|||
## Bibliography
|
||||
|
||||
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
* “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf).
|
||||
* Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
|
||||
|
|
|
@ -1,5 +1,375 @@
|
|||
---
|
||||
title: C17
|
||||
TARGET DECK: Obsidian::STEM
|
||||
FILE TAGS: c17
|
||||
tags:
|
||||
- c17
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
An **object** is a region of data storage in the execution environment, the contents of which can represent **values**. We say an object type is **complete** if there is sufficient information to determine the size of objects of that type. Otherwise we say it is **incomplete**.
|
||||
|
||||
An **lvalue** is an expression (with non-`void` object type) that potentially designates an object. An **rvalue** is the "value of the expression."
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does an object refer to?
|
||||
Back: A region of data storage in the execution environment, the contents of which can represent values.
|
||||
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: 1723510994830-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does a value refer to?
|
||||
Back: The contents of an object when interpreted as having a specific type.
|
||||
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: 1723510994835-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
A {value} refers to the contents of an {object} when interpreted as having a specific type.
|
||||
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: 1723510994839-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Types are partitioned into what two categories?
|
||||
Back: Object types and function types.
|
||||
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: 1723510994842-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is an object type?
|
||||
Back: A type that describes objects.
|
||||
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: 1723510994846-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is a function type?
|
||||
Back: A type that describes functions.
|
||||
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: 1723510994851-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What two parts characterize a function type?
|
||||
Back: The return type and the number/types of its parameters.
|
||||
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: 1723510994856-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean for an object type to be complete?
|
||||
Back: There is sufficient information to determine the size of objects of that type.
|
||||
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: 1723510994866-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean for an object type to be incomplete?
|
||||
Back: There is insufficient information to determine the size of objects of that type.
|
||||
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: 1723510994870-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is an lvalue?
|
||||
Back: An expression (with non-`void` object type) that potentially designates an object.
|
||||
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: 1723510994874-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Why are lvalues named the way they are?
|
||||
Back: The name is an acronym for **l**ocator **value**.
|
||||
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: 1723510994878-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is an rvalue?
|
||||
Back: The value of an expression.
|
||||
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: 1723510994881-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Why are rvalues named the way they are?
|
||||
Back: The name is an acronym for **r**ight **value**.
|
||||
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: 1723510994886-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What object type can an lvalue *not* have?
|
||||
Back: `void`
|
||||
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: 1723510994890-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What object type can an lvalue have?
|
||||
Back: Any object type other than `void`.
|
||||
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: 1723510994895-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Can an lvalue designate an object?
|
||||
Back: Yes.
|
||||
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: 1723510994900-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Can an lvalue designate a function?
|
||||
Back: No.
|
||||
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: 1723510994907-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is `x` an lvalue or rvalue in the following snippet?
|
||||
```c
|
||||
int x = 10;
|
||||
```
|
||||
Back: An lvalue.
|
||||
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: 1723510994914-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is `int` an lvalue or rvalue in the following snippet?
|
||||
```c
|
||||
int x = 10;
|
||||
```
|
||||
Back: Neither.
|
||||
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: 1723510994920-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is `10` an lvalue or rvalue in the following snippet?
|
||||
```c
|
||||
int x = 10;
|
||||
```
|
||||
Back: An rvalue.
|
||||
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: 1723510994925-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
*Why* is `x` an lvalue in the following?
|
||||
```c
|
||||
int x = 10;
|
||||
```
|
||||
Back: Because `x` refers to a memory location.
|
||||
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: 1723510994932-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is `x` an lvalue or rvalue in the following snippet?
|
||||
```c
|
||||
void x;
|
||||
```
|
||||
Back: Neither.
|
||||
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: 1723510994939-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is `x` an lvalue or rvalue in the following snippet?
|
||||
```c
|
||||
void *x;
|
||||
```
|
||||
Back: An lvalue.
|
||||
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: 1723510994945-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is `y` an lvalue or rvalue in the following snippet?
|
||||
```c
|
||||
int y = x + 10;
|
||||
```
|
||||
Back: An lvalue.
|
||||
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: 1723510994952-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is `x` an lvalue or rvalue in the following snippet?
|
||||
```c
|
||||
int y = x + 10;
|
||||
```
|
||||
Back: An rvalue.
|
||||
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: 1723510994958-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In the second line, is `ptr` an lvalue or rvalue?
|
||||
```c
|
||||
int *ptr = &x;
|
||||
*ptr = 10;
|
||||
```
|
||||
Back: An lvalue.
|
||||
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: 1723510994964-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In the second line, is `*ptr` an lvalue or rvalue?
|
||||
```c
|
||||
int *ptr = &x;
|
||||
*ptr = 10;
|
||||
```
|
||||
Back: An lvalue.
|
||||
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: 1723510994970-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is `getValue` an lvalue or rvalue in the following snippet?
|
||||
```c
|
||||
int getValue () {
|
||||
return 42;
|
||||
}
|
||||
```
|
||||
Back: Neither.
|
||||
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: 1723510994975-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is `getValue()` an lvalue or rvalue in the following snippet?
|
||||
```c
|
||||
int d = getValue();
|
||||
```
|
||||
Back: An rvalue.
|
||||
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: 1723510994980-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
*Why* is `getValue` in the following snippet neither an lvalue nor an rvalue?
|
||||
```c
|
||||
int getValue() {
|
||||
return 42;
|
||||
}
|
||||
```
|
||||
Back: The function name is just syntax. That is, it isn't an expression.
|
||||
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: 1723510994984-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Are variables typically lvalues or rvalues?
|
||||
Back: lvalues.
|
||||
Reference: ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf).
|
||||
<!--ID: 1723510994988-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Are constants typically lvalues or rvalues?
|
||||
Back: rvalues.
|
||||
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: 1723510994992-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Are array elements typically lvalues or rvalues?
|
||||
Back: lvalues.
|
||||
Reference: ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf).
|
||||
<!--ID: 1723510994997-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Are dereferenced pointers typically lvalues or rvalues?
|
||||
Back: lvalues.
|
||||
Reference: ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf).
|
||||
<!--ID: 1723510995001-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Are temporary values typically lvalues or rvalues?
|
||||
Back: rvalues.
|
||||
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: 1723510995006-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Does `x` have complete or incomplete object type in the following?
|
||||
```c
|
||||
void x;
|
||||
```
|
||||
Back: Incomplete.
|
||||
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: 1723510995010-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Does `x` have complete or incomplete object type in the following?
|
||||
```c
|
||||
int x;
|
||||
```
|
||||
Back: Complete.
|
||||
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: 1723510995016-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Does `x` have complete or incomplete object type in the following?
|
||||
```c
|
||||
void *x;
|
||||
```
|
||||
Back: Complete.
|
||||
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: 1723510995023-->
|
||||
END%%
|
||||
|
||||
## Bibliography
|
||||
|
||||
* “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf).
|
||||
* Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
title: Types
|
||||
TARGET DECK: Obsidian::STEM
|
||||
FILE TAGS: c17
|
||||
tags:
|
||||
- c17
|
||||
---
|
||||
|
||||
## Overview
|
|
@ -94,19 +94,32 @@ END%%
|
|||
|
||||
## SET
|
||||
|
||||
| Instruction | Synonym | Effect | Description |
|
||||
| ----------- | -------- | --------------------------------- | ------------------------------------ |
|
||||
| `sete` | `setz` | `D <- ZF` | Equal / zero |
|
||||
| `setne` | `setnz` | `D <- ~ZF` | Not equal / not zero |
|
||||
| `sets` | | `D <- SF` | Negative |
|
||||
| `setns` | | `D <- ~SF` | Nonnegative |
|
||||
| `setl` | `setnge` | `D <- SF ^ OF` | Less (signed `<`) |
|
||||
| `setle` | `setng` | <code>D <- (SF ^ OF) \| ZF</code> | Less or equal (signed `<=`) |
|
||||
| `setg` | `setnle` | `D <- ~(SF ^ OF) & ~ZF` | Greater (signed `>`) |
|
||||
| `setge` | `setnl` | `D <- ~(SF ^ OF)` | Greater or equal (signed `<=`) |
|
||||
| `setb` | `setnae` | `D <- CF` | Below (unsigned `<`) |
|
||||
The description of the `SET` commands apply to the case of a comparison instruction. That is, the condition codes are set according to computation `t = a - b`, where `t`, `a`, and `b` may be interpreted as signed or unsigned depending on the `SET` instruction invoked.
|
||||
|
||||
Note how the other condition code effects are easy to derive from `setl` and `setb`.
|
||||
| Instruction | Synonym | Evaluation | Description |
|
||||
| ----------- | -------- | ---------------------------- | ------------------------------ |
|
||||
| `sete` | `setz` | `ZF` | Equal / zero |
|
||||
| `setne` | `setnz` | `~ZF` | Not equal / not zero |
|
||||
| `sets` | | `SF` | Negative |
|
||||
| `setns` | | `~SF` | Nonnegative |
|
||||
| `setl` | `setnge` | `SF ^ OF` | Less (signed `<`) |
|
||||
| `setle` | `setng` | <code>(SF ^ OF) \| ZF</code> | Less or equal (signed `<=`) |
|
||||
| `setg` | `setnle` | `~(SF ^ OF) & ~ZF` | Greater (signed `>`) |
|
||||
| `setge` | `setnl` | `~(SF ^ OF)` | Greater or equal (signed `<=`) |
|
||||
| `setb` | `setnae` | `CF` | Below (unsigned `<`) |
|
||||
| `setbe` | `setna` | <code>CF \| ZF</code> | Below or equal (unsigned `<=`) |
|
||||
| `seta` | `setnbe` | `~CF & ~ZF` | Above (unsigned `>`) |
|
||||
| `setae` | `setnb` | `~CF` | Above or equal (unsigned `>=`) |
|
||||
|
||||
Note how the other condition code evaluations are easy to derive from `setl` and `setb`.
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What arithmetic computation is a `SET` instruction's description based on?
|
||||
Back: `t = a - b`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723413572733-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
|
@ -265,14 +278,6 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
|||
<!--ID: 1720992217917-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What arithmetic computation is a `SET` instruction's interpretation of condition codes based on?
|
||||
Back: `t = a - b`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723413572733-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is `l` in the `setl` instruction short for?
|
||||
|
@ -500,6 +505,99 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
|||
<!--ID: 1723466622325-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is `a` in the `seta` instruction short for?
|
||||
Back: **A**bove.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919305-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{`seta`} is a synonym for {`setnbe`}.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919313-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What condition code(s) does `seta` refer to?
|
||||
Back: `CF` and `ZF`.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919317-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In terms of condition codes, what value does `seta` put in its specified destination?
|
||||
Back: `~CF & ~ZF`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919321-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is `ae` in the `setae` instruction short for?
|
||||
Back: **A**bove or **e**qual.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919325-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{`setae`} is a synonym for {`setnb`}.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919329-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What condition code(s) does `setae` refer to?
|
||||
Back: `CF`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919333-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In terms of condition codes, what value does `setae` put in its specified destination?
|
||||
Back: `~CF`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919338-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is `be` in the `setbe` instruction short for?
|
||||
Back: **B**elow or **e**qual.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919343-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{`setbe`} is a synonym for {`setna`}.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919349-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What condition code(s) does `setbe` refer to?
|
||||
Back: `CF` and `ZF`.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919355-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In terms of condition codes, what value does `setbe` put in its specified destination?
|
||||
Back: `CF | ZF`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1723471919361-->
|
||||
END%%
|
||||
|
||||
## Bibliography
|
||||
|
||||
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
|
|
Loading…
Reference in New Issue