notebook/notes/x86-64/declarations.md

243 lines
8.8 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-27 02:48:57 +00:00
What is the width of a `word`?
2024-03-22 14:10:08 +00:00
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-27 02:48:57 +00:00
What historical reason explains why a `word` is 16 bits?
2024-03-22 14:10:08 +00:00
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-27 02:48:57 +00:00
What is the width of an Intel `byte`?
2024-03-22 14:10:08 +00:00
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?
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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-27 02:48:57 +00:00
What is the width of an Intel `word`?
2024-03-22 14:10:08 +00:00
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?
2024-03-27 02:48:57 +00:00
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-27 02:48:57 +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-27 02:48:57 +00:00
What is the width of an Intel `double word`?
2024-03-22 14:10:08 +00:00
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?
2024-03-27 02:48:57 +00:00
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-27 02:48:57 +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-27 02:48:57 +00:00
*Why* do `double word`s 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-27 02:48:57 +00:00
What is the width of an Intel `quad word`?
2024-03-22 14:10:08 +00:00
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?
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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
2024-03-27 02:48:57 +00:00
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-27 02:48:57 +00:00
What is the width of an Intel `single-precision`?
2024-03-22 14:10:08 +00:00
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?
2024-03-27 02:48:57 +00:00
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?
2024-03-27 02:48:57 +00:00
Back: `double word`s and `double-precision`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: 1711116523898-->
2024-03-20 17:33:13 +00:00
END%%
%%ANKI
2024-03-22 14:10:08 +00:00
Basic
2024-03-27 02:48:57 +00:00
What is the width of an Intel `double-precision`?
2024-03-22 14:10:08 +00:00
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-27 02:48:57 +00:00
Why is it safe for `double word`s and `double-precision`s to both use assembly-code suffix `l`?
2024-03-22 14:10:08 +00:00
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%%
## Bibliography
2024-03-20 17:33:13 +00:00
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.