-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
345 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ a couple of CPU cycles | |
|
||
|
||
|
||
[prev](2.md) [next](4.md) | ||
[prev](002.md) +++ [next](004.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ Examples of such instructions are: | |
|
||
|
||
|
||
[prev](3.md) [next](5.md) | ||
[prev](003.md) +++ [next](005.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ representation -- internal interrupt). | |
|
||
|
||
|
||
[prev](4.md) [next](6.md) | ||
[prev](004.md) +++ [next](006.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ model are trying to solve? | |
|
||
|
||
|
||
[prev](5.md) [next](7.md) | ||
[prev](005.md) +++ [next](007.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ What is the purpose of stack pointer? | |
|
||
|
||
|
||
[prev](7.md) [next](9.md) | ||
[prev](007.md) +++ [next](009.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ vs nine for `mov` with operand). | |
|
||
|
||
|
||
[prev](10.md) [next](12.md) | ||
[prev](010.md) +++ [next](012.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ The program exit status (return code). | |
|
||
|
||
|
||
[prev](12.md) [next](14.md) | ||
[prev](012.md) +++ [next](014.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,4 @@ its value, becoming `1111` in binary, or `0xF`. | |
|
||
|
||
|
||
[prev](14.md) [next](16.md) | ||
[prev](014.md) +++ [next](016.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ are exactly the same. | |
|
||
|
||
|
||
[prev](16.md) [next](18.md) | ||
[prev](016.md) +++ [next](018.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,4 +76,4 @@ syscall | |
|
||
|
||
|
||
[prev](18.md) [next](20.md) | ||
[prev](018.md) +++ [next](020.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ TODO | |
|
||
|
||
|
||
[prev](21.md) [next](23.md) | ||
[prev](021.md) +++ [next](023.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ They are parts of the same regiser: | |
|
||
|
||
|
||
[prev](22.md) [next](24.md) | ||
[prev](022.md) +++ [next](024.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ For example, `call`, `ret`, `push`, `pop`. | |
|
||
|
||
|
||
[prev](24.md) [next](26.md) | ||
[prev](024.md) +++ [next](026.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
# Question 26 | ||
|
||
|
||
Which ones of these instructions are incorrect and why? | ||
```asm | ||
mov [rax], 0 | ||
cmp [rdx], bl | ||
mov bh, bl | ||
mov al, al | ||
add bpl, 9 | ||
add [9], spl | ||
mov r8d, r9d | ||
mov r3b, al | ||
mov r9w, r2d | ||
mov rcx, [rax + rbx + rdx] | ||
mov r9, [r9 + 8*rax] | ||
mov [r8+r7+10], 6 | ||
mov [r8+r7+10], r6 | ||
``` | ||
|
||
|
||
# Answer | ||
|
||
|
||
|
||
The incorrect instructions are listed below: | ||
|
||
```asm | ||
mov [rax], 0 ; We don't know whether we should write 8, 4, 2 or 1 byte | ||
; Change to e.g. `mov dword [rax], 0` | ||
mov r3b, al ; NASM does not support r0-r7 names, only r8-r15 | ||
mov r9w, r2d ; NASM does not support r0-r7 names, only r8-r15 | ||
mov rcx, [rax + rbx + rdx] ; displacement should be an immediate value | ||
; can not use register for it | ||
mov [r8+r7+10], 6 ; No size specified, NASM does not support r7 | ||
mov [r8+r7+10], r6 ; NASM does not support r6 or r7 | ||
``` | ||
|
||
|
||
|
||
[prev](025.md) +++ [next](027.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ Enumerate the Callee Saved Registers | |
|
||
|
||
|
||
[prev](26.md) [next](28.md) | ||
[prev](026.md) +++ [next](028.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ them in a general purpose fashion anyway. | |
|
||
|
||
|
||
[prev](27.md) [next](29.md) | ||
[prev](027.md) +++ [next](029.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
# Question 32 | ||
|
||
|
||
Describe the effects of the following instructions: | ||
\beginitemize | ||
\item `sar ` | ||
\item `shr` | ||
\item `xor` | ||
\item `jmp` | ||
\item `ja`, `jb` and similar ones. | ||
\item `cmp` | ||
\item `mov` | ||
\item `inc`,`dec` | ||
\item `add` | ||
\item `imul, mul` | ||
\item `sub` | ||
\item `idiv, div` | ||
\item `call, ret` | ||
\item `push, pop` | ||
\enditemize | ||
|
||
|
||
|
||
# Answer | ||
|
||
|
||
|
||
|
||
Refer to the second volume of [Intel 64 and IA-32 Architectures Software Developer's Manual]. | ||
|
||
|
||
|
||
|
||
[prev](031.md) +++ [next](033.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ own, because it is not stored in memory cells. | |
|
||
|
||
|
||
[prev](32.md) [next](34.md) | ||
[prev](032.md) +++ [next](034.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,4 @@ _no: | |
|
||
|
||
|
||
[prev](33.md) [next](35.md) | ||
[prev](033.md) +++ [next](035.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ are exactly the same. | |
|
||
|
||
|
||
[prev](35.md) [next](37.md) | ||
[prev](035.md) +++ [next](037.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ _label: | |
|
||
|
||
|
||
[prev](36.md) [next](38.md) | ||
[prev](036.md) +++ [next](038.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ lea rax, [rax + rax*8] | |
|
||
|
||
|
||
[prev](38.md) [next](40.md) | ||
[prev](038.md) +++ [next](040.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ jl label | |
|
||
|
||
|
||
[prev](39.md) [next](41.md) | ||
[prev](039.md) +++ [next](041.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ mov rax, [rdx + 8*rcx + 42] | |
``` | ||
|
||
|
||
[prev](41.md) [next](43.md) | ||
[prev](041.md) +++ [next](043.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ Because of __little endian__: | |
|
||
|
||
|
||
[prev](43.md) [next](45.md) | ||
[prev](043.md) +++ [next](045.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
# Question 46 | ||
|
||
|
||
Read about microcode in general and processor pipelines. | ||
|
||
|
||
# Answer | ||
|
||
|
||
|
||
|
||
Microcode is the program code one level _below_ assembly, that is used to | ||
encode the logic of complex instructions. It is not accessible to programmer | ||
and virtually everything about it is a trade secret of computer manufacturer. | ||
|
||
The processor pipeline allows you to execute multiple microcode instructions | ||
at time, if they use different parts of CPU. It is a great performance | ||
booster. | ||
|
||
This document contains a good insight on these topics: | ||
[The microarchitecture of Intel, AMD and VIA CPUs: An optimization guide for assembly programmers and | ||
compiler makers](http://www.agner.org/optimize/microarchitecture.pdf) | ||
|
||
|
||
|
||
[prev](045.md) +++ [next](047.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.