notebook/notes/x86-64/declarations.md

243 lines
8.7 KiB
Markdown
Raw Normal View History

2024-03-20 17:33:13 +00:00
---
2024-03-22 14:10:08 +00:00
title: Declarations
2024-03-20 17:33:13 +00:00
TARGET DECK: Obsidian::STEM
2024-03-22 14:10:08 +00:00
FILE TAGS: x86-64
2024-03-20 17:33:13 +00:00
tags:
2024-03-22 14:10:08 +00:00
- x86-64
2024-03-20 17:33:13 +00:00
---
## Overview
2024-03-22 14:10:08 +00:00
| C Declaration | Intel Data Type | Suffix | Size (bytes) |
| ------------- | ---------------- | ------ | ------------ |
| `char` | Byte | `b` | 1 |
| `short` | Word | `w` | 2 |
| `int` | Double word | `l` | 4 |
| `long` | Quad word | `q` | 8 |
| `char *` | Quad word | `q` | 8 |
| `float` | Single-precision | `s` | 4 |
| `double` | Double-precision | `l` | 8 |
2024-03-20 17:33:13 +00:00
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
What is the width of a word?
Back: 16 bits.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523806-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
What historical reason explains why a word is 16 bits?
Back: Because the 8086 that introduced x86 was 16 bits.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523813-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
What is the width of an Intel "byte"?
Back: $8$ bits
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523816-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
Which Intel data types are 1 bytes wide?
Back: Just the "byte".
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523818-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
The "{byte}" Intel data type has assembly-code suffix {`b`}.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523821-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
What is the width of an Intel "word"?
Back: $16$ bits
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523824-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
Which Intel data types are 2 bytes wide?
Back: Just the "word".
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523827-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Cloze
2024-03-22 14:10:08 +00:00
The "{word}" Intel data type has assembly-code suffix {`w`}.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523830-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
What is the width of an Intel "double word"?
Back: $32$ bits
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523833-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
Which Intel data types are 4 bytes wide?
Back: The double word and single-precision.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523836-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Cloze
2024-03-22 14:10:08 +00:00
The "{double word/double-precision}" Intel data type has assembly-code suffix {`l`}.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523839-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
*Why* do double words have assembly-code suffix `l`?
Back: The suffix stands for "long", relative to a 16-bit word.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523842-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
What is the width of an Intel "quad word"?
Back: $64$ bits
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523846-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
Which Intel data types are 8 bytes wide?
Back: The quad word and double-precision.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523850-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
The "{quad word}" Intel data type has assembly-code suffix {`q`}.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523853-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
C integral declaration {`char`} corresponds to Intel data type "{byte}".
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
Tags: c17
<!--ID: 1711116523858-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
C integral declaration {`short`} corresponds to Intel data type "{word}".
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
Tags: c17
<!--ID: 1711116523862-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
C integral declaration {`int`} corresponds to Intel data type "{double word}".
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
Tags: c17
<!--ID: 1711116523866-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
C integral declaration {`long`} corresponds to Intel data type "{quad word}".
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
Tags: c17
<!--ID: 1711116523870-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
C declaration `char *` corresponds to Intel data type "{quad word}".
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
Tags: c17
<!--ID: 1711116523874-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
C floating-point declaration {`float`} corresponds to Intel data type "{single-precision}".
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
Tags: c17
<!--ID: 1711116523877-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
The "{single-precision}" Intel data type has assembly-code suffix {`s`}.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523881-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Cloze
C floating-point declaration {`double`} corresponds to Intel data type "{double-precision}".
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
Tags: c17
<!--ID: 1711116523885-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
What is the width of an Intel "singe precision"?
Back: $32$ bits
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523889-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
What two Intel data types do floating-point numbers come in?
Back: Single-precision and double-precision.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523893-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
Assembly-code suffix `l` is used for what two Intel data types?
Back: Double words and double-precisions.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523898-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Basic
What is the width of an Intel "double-precision"?
Back: $64$ bits
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523903-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
Basic
2024-03-22 14:10:08 +00:00
Why is it safe for double words and double-precisions to both use assembly-code suffix `l`?
Back: Floating-point code uses a different set of instructions and registers.
2024-03-20 17:33:13 +00:00
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
2024-03-22 14:10:08 +00:00
<!--ID: 1711116523908-->
2024-03-20 17:33:13 +00:00
END%%
## References
2024-03-22 14:10:08 +00:00
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.