From f4c361e94dde250e3799f9a916b5e77c7d15e3ca Mon Sep 17 00:00:00 2001 From: sayon Date: Thu, 20 Jul 2017 15:17:11 +0200 Subject: [PATCH] more answers --- questions/answers/001.md | 2 +- questions/answers/002.md | 2 +- questions/answers/003.md | 2 +- questions/answers/004.md | 2 +- questions/answers/005.md | 2 +- questions/answers/006.md | 2 +- questions/answers/007.md | 2 +- questions/answers/008.md | 2 +- questions/answers/009.md | 2 +- questions/answers/010.md | 2 +- questions/answers/011.md | 2 +- questions/answers/012.md | 2 +- questions/answers/013.md | 2 +- questions/answers/014.md | 2 +- questions/answers/015.md | 2 +- questions/answers/016.md | 2 +- questions/answers/017.md | 2 +- questions/answers/018.md | 2 +- questions/answers/019.md | 2 +- questions/answers/022.md | 2 +- questions/answers/023.md | 2 +- questions/answers/024.md | 2 +- questions/answers/025.md | 2 +- questions/answers/026.md | 44 ++++++++++++++++++++++++++++++++++++++++ questions/answers/027.md | 2 +- questions/answers/028.md | 2 +- questions/answers/029.md | 2 +- questions/answers/030.md | 2 +- questions/answers/031.md | 2 +- questions/answers/032.md | 35 ++++++++++++++++++++++++++++++++ questions/answers/033.md | 2 +- questions/answers/034.md | 2 +- questions/answers/035.md | 2 +- questions/answers/036.md | 2 +- questions/answers/037.md | 2 +- questions/answers/038.md | 2 +- questions/answers/039.md | 2 +- questions/answers/040.md | 2 +- questions/answers/041.md | 2 +- questions/answers/042.md | 2 +- questions/answers/043.md | 2 +- questions/answers/044.md | 2 +- questions/answers/045.md | 2 +- questions/answers/046.md | 27 ++++++++++++++++++++++++ questions/answers/047.md | 2 +- questions/answers/048.md | 2 +- questions/answers/049.md | 2 +- questions/answers/050.md | 2 +- questions/answers/051.md | 2 +- questions/answers/052.md | 2 +- questions/answers/053.md | 2 +- questions/answers/054.md | 27 ++++++++++++++++++++++++ questions/answers/055.md | 2 +- questions/answers/056.md | 2 +- questions/answers/057.md | 23 +++++++++++++++++++++ questions/answers/058.md | 2 +- questions/answers/059.md | 2 +- questions/answers/060.md | 2 +- questions/answers/061.md | 2 +- questions/answers/062.md | 2 +- questions/answers/063.md | 2 +- questions/answers/064.md | 2 +- questions/answers/065.md | 2 +- questions/answers/068.md | 17 ++++++++++++++++ questions/answers/069.md | 31 ++++++++++++++++++++++++++++ questions/answers/072.md | 28 +++++++++++++++++++++++++ questions/answers/074.md | 16 +++++++++++++++ questions/answers/077.md | 39 +++++++++++++++++++++++++++++++++++ 68 files changed, 345 insertions(+), 58 deletions(-) create mode 100644 questions/answers/026.md create mode 100644 questions/answers/032.md create mode 100644 questions/answers/046.md create mode 100644 questions/answers/054.md create mode 100644 questions/answers/057.md create mode 100644 questions/answers/068.md create mode 100644 questions/answers/069.md create mode 100644 questions/answers/072.md create mode 100644 questions/answers/074.md create mode 100644 questions/answers/077.md diff --git a/questions/answers/001.md b/questions/answers/001.md index f76c45b..55500a3 100644 --- a/questions/answers/001.md +++ b/questions/answers/001.md @@ -50,4 +50,4 @@ The difference is that the CF is a result of an unsigned overflow (not enough bi - [next](2.md) + +++ [next](002.md) diff --git a/questions/answers/002.md b/questions/answers/002.md index cca961a..3590c7a 100644 --- a/questions/answers/002.md +++ b/questions/answers/002.md @@ -27,4 +27,4 @@ There might be additional points, which are of a little importance to us, such a -[prev](1.md) [next](3.md) +[prev](001.md) +++ [next](003.md) diff --git a/questions/answers/003.md b/questions/answers/003.md index 5987e84..40c3a09 100644 --- a/questions/answers/003.md +++ b/questions/answers/003.md @@ -18,4 +18,4 @@ a couple of CPU cycles -[prev](2.md) [next](4.md) +[prev](002.md) +++ [next](004.md) diff --git a/questions/answers/004.md b/questions/answers/004.md index 5ca9193..40a6da6 100644 --- a/questions/answers/004.md +++ b/questions/answers/004.md @@ -36,4 +36,4 @@ Examples of such instructions are: -[prev](3.md) [next](5.md) +[prev](003.md) +++ [next](005.md) diff --git a/questions/answers/005.md b/questions/answers/005.md index df7f9b6..df3cbb1 100644 --- a/questions/answers/005.md +++ b/questions/answers/005.md @@ -25,4 +25,4 @@ representation -- internal interrupt). -[prev](4.md) [next](6.md) +[prev](004.md) +++ [next](006.md) diff --git a/questions/answers/006.md b/questions/answers/006.md index 1b9d7cc..86774d3 100644 --- a/questions/answers/006.md +++ b/questions/answers/006.md @@ -20,4 +20,4 @@ model are trying to solve? -[prev](5.md) [next](7.md) +[prev](005.md) +++ [next](007.md) diff --git a/questions/answers/007.md b/questions/answers/007.md index 529fb54..3ef9e04 100644 --- a/questions/answers/007.md +++ b/questions/answers/007.md @@ -29,4 +29,4 @@ Here is the full list (16 general purpose registers): -[prev](6.md) [next](8.md) +[prev](006.md) +++ [next](008.md) diff --git a/questions/answers/008.md b/questions/answers/008.md index ca09939..4516e4d 100644 --- a/questions/answers/008.md +++ b/questions/answers/008.md @@ -15,4 +15,4 @@ What is the purpose of stack pointer? -[prev](7.md) [next](9.md) +[prev](007.md) +++ [next](009.md) diff --git a/questions/answers/009.md b/questions/answers/009.md index 7ec951f..ba0b730 100644 --- a/questions/answers/009.md +++ b/questions/answers/009.md @@ -20,4 +20,4 @@ Being unable to reason about the amount of elements in stack, this question has -[prev](8.md) [next](10.md) +[prev](008.md) +++ [next](010.md) diff --git a/questions/answers/010.md b/questions/answers/010.md index 731a774..e0c315b 100644 --- a/questions/answers/010.md +++ b/questions/answers/010.md @@ -19,4 +19,4 @@ So, no, we are unable to reason about the amount of elements in stack at all. -[prev](9.md) [next](11.md) +[prev](009.md) +++ [next](011.md) diff --git a/questions/answers/011.md b/questions/answers/011.md index 185979c..8f34d68 100644 --- a/questions/answers/011.md +++ b/questions/answers/011.md @@ -21,4 +21,4 @@ vs nine for `mov` with operand). -[prev](10.md) [next](12.md) +[prev](010.md) +++ [next](012.md) diff --git a/questions/answers/012.md b/questions/answers/012.md index ca7f1c3..69af64c 100644 --- a/questions/answers/012.md +++ b/questions/answers/012.md @@ -20,4 +20,4 @@ The assembly programs return the exit status by passing it to the -[prev](11.md) [next](13.md) +[prev](011.md) +++ [next](013.md) diff --git a/questions/answers/013.md b/questions/answers/013.md index 2b88393..4652431 100644 --- a/questions/answers/013.md +++ b/questions/answers/013.md @@ -17,4 +17,4 @@ The program exit status (return code). -[prev](12.md) [next](14.md) +[prev](012.md) +++ [next](014.md) diff --git a/questions/answers/014.md b/questions/answers/014.md index 40cc757..2953049 100644 --- a/questions/answers/014.md +++ b/questions/answers/014.md @@ -17,4 +17,4 @@ Use `man ascii` to view the full ASCII table with the symbol codes. -[prev](13.md) [next](15.md) +[prev](013.md) +++ [next](015.md) diff --git a/questions/answers/015.md b/questions/answers/015.md index 40f4607..f2d79da 100644 --- a/questions/answers/015.md +++ b/questions/answers/015.md @@ -41,4 +41,4 @@ its value, becoming `1111` in binary, or `0xF`. -[prev](14.md) [next](16.md) +[prev](014.md) +++ [next](016.md) diff --git a/questions/answers/016.md b/questions/answers/016.md index f2c5491..d30f157 100644 --- a/questions/answers/016.md +++ b/questions/answers/016.md @@ -43,4 +43,4 @@ Some examples (all producing exactly the same code): -[prev](15.md) [next](17.md) +[prev](015.md) +++ [next](017.md) diff --git a/questions/answers/017.md b/questions/answers/017.md index 60a27d9..2480c4f 100644 --- a/questions/answers/017.md +++ b/questions/answers/017.md @@ -16,4 +16,4 @@ are exactly the same. -[prev](16.md) [next](18.md) +[prev](016.md) +++ [next](018.md) diff --git a/questions/answers/018.md b/questions/answers/018.md index 7e86779..06c88ff 100644 --- a/questions/answers/018.md +++ b/questions/answers/018.md @@ -46,4 +46,4 @@ stored in reverse order, the least significant byte being the first. -[prev](17.md) [next](19.md) +[prev](017.md) +++ [next](019.md) diff --git a/questions/answers/019.md b/questions/answers/019.md index 0bffbbb..b13f975 100644 --- a/questions/answers/019.md +++ b/questions/answers/019.md @@ -76,4 +76,4 @@ syscall -[prev](18.md) [next](20.md) +[prev](018.md) +++ [next](020.md) diff --git a/questions/answers/022.md b/questions/answers/022.md index 3c886f7..70f0c55 100644 --- a/questions/answers/022.md +++ b/questions/answers/022.md @@ -20,4 +20,4 @@ TODO -[prev](21.md) [next](23.md) +[prev](021.md) +++ [next](023.md) diff --git a/questions/answers/023.md b/questions/answers/023.md index 8274bfe..58d78d4 100644 --- a/questions/answers/023.md +++ b/questions/answers/023.md @@ -25,4 +25,4 @@ They are parts of the same regiser: -[prev](22.md) [next](24.md) +[prev](022.md) +++ [next](024.md) diff --git a/questions/answers/024.md b/questions/answers/024.md index 328980f..fea37a7 100644 --- a/questions/answers/024.md +++ b/questions/answers/024.md @@ -17,4 +17,4 @@ By using `r9d`, `r9w` and `r9b` to access the double word (32 bit), word (16 bit -[prev](23.md) [next](25.md) +[prev](023.md) +++ [next](025.md) diff --git a/questions/answers/025.md b/questions/answers/025.md index d1ec4e0..d074eb0 100644 --- a/questions/answers/025.md +++ b/questions/answers/025.md @@ -14,4 +14,4 @@ For example, `call`, `ret`, `push`, `pop`. -[prev](24.md) [next](26.md) +[prev](024.md) +++ [next](026.md) diff --git a/questions/answers/026.md b/questions/answers/026.md new file mode 100644 index 0000000..394ea1a --- /dev/null +++ b/questions/answers/026.md @@ -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) diff --git a/questions/answers/027.md b/questions/answers/027.md index 2b8b400..c25e849 100644 --- a/questions/answers/027.md +++ b/questions/answers/027.md @@ -19,4 +19,4 @@ Enumerate the Callee Saved Registers -[prev](26.md) [next](28.md) +[prev](026.md) +++ [next](028.md) diff --git a/questions/answers/028.md b/questions/answers/028.md index 48c60e9..6ab91bb 100644 --- a/questions/answers/028.md +++ b/questions/answers/028.md @@ -23,4 +23,4 @@ them in a general purpose fashion anyway. -[prev](27.md) [next](29.md) +[prev](027.md) +++ [next](029.md) diff --git a/questions/answers/029.md b/questions/answers/029.md index a93e7da..79a248b 100644 --- a/questions/answers/029.md +++ b/questions/answers/029.md @@ -15,4 +15,4 @@ It holds the address of the next instruction to be executed. -[prev](28.md) [next](30.md) +[prev](028.md) +++ [next](030.md) diff --git a/questions/answers/030.md b/questions/answers/030.md index afb7870..2d62917 100644 --- a/questions/answers/030.md +++ b/questions/answers/030.md @@ -15,4 +15,4 @@ Sign Flag, it is set when the computation result is negative. -[prev](29.md) [next](31.md) +[prev](029.md) +++ [next](031.md) diff --git a/questions/answers/031.md b/questions/answers/031.md index fb03016..a5973a5 100644 --- a/questions/answers/031.md +++ b/questions/answers/031.md @@ -15,4 +15,4 @@ Zero Flag, it is set when the computation result is zero. -[prev](30.md) [next](32.md) +[prev](030.md) +++ [next](032.md) diff --git a/questions/answers/032.md b/questions/answers/032.md new file mode 100644 index 0000000..4ce0a09 --- /dev/null +++ b/questions/answers/032.md @@ -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) diff --git a/questions/answers/033.md b/questions/answers/033.md index 78138ef..a1cb154 100644 --- a/questions/answers/033.md +++ b/questions/answers/033.md @@ -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) diff --git a/questions/answers/034.md b/questions/answers/034.md index 4ccdee2..07778ba 100644 --- a/questions/answers/034.md +++ b/questions/answers/034.md @@ -35,4 +35,4 @@ _no: -[prev](33.md) [next](35.md) +[prev](033.md) +++ [next](035.md) diff --git a/questions/answers/035.md b/questions/answers/035.md index c7e9f9b..dc2fdd4 100644 --- a/questions/answers/035.md +++ b/questions/answers/035.md @@ -44,4 +44,4 @@ flags are set, the jump occurs. However, from my experience, it is useless. If y -[prev](34.md) [next](36.md) +[prev](034.md) +++ [next](036.md) diff --git a/questions/answers/036.md b/questions/answers/036.md index d2936ce..9a6e449 100644 --- a/questions/answers/036.md +++ b/questions/answers/036.md @@ -16,4 +16,4 @@ are exactly the same. -[prev](35.md) [next](37.md) +[prev](035.md) +++ [next](037.md) diff --git a/questions/answers/037.md b/questions/answers/037.md index 3b5c94f..63832fa 100644 --- a/questions/answers/037.md +++ b/questions/answers/037.md @@ -25,4 +25,4 @@ _label: -[prev](36.md) [next](38.md) +[prev](036.md) +++ [next](038.md) diff --git a/questions/answers/038.md b/questions/answers/038.md index a2eb8ab..3a26f66 100644 --- a/questions/answers/038.md +++ b/questions/answers/038.md @@ -19,4 +19,4 @@ The assembly programs return the exit status by passing it to the -[prev](37.md) [next](39.md) +[prev](037.md) +++ [next](039.md) diff --git a/questions/answers/039.md b/questions/answers/039.md index a0f08dd..f4d6de1 100644 --- a/questions/answers/039.md +++ b/questions/answers/039.md @@ -17,4 +17,4 @@ lea rax, [rax + rax*8] -[prev](38.md) [next](40.md) +[prev](038.md) +++ [next](040.md) diff --git a/questions/answers/040.md b/questions/answers/040.md index 768f48e..a306f69 100644 --- a/questions/answers/040.md +++ b/questions/answers/040.md @@ -21,4 +21,4 @@ jl label -[prev](39.md) [next](41.md) +[prev](039.md) +++ [next](041.md) diff --git a/questions/answers/041.md b/questions/answers/041.md index 258982e..493ab1d 100644 --- a/questions/answers/041.md +++ b/questions/answers/041.md @@ -33,4 +33,4 @@ In Big Endian, the bytes are also stored in a natural order: -[prev](40.md) [next](42.md) +[prev](040.md) +++ [next](042.md) diff --git a/questions/answers/042.md b/questions/answers/042.md index 39b3151..f41db2f 100644 --- a/questions/answers/042.md +++ b/questions/answers/042.md @@ -24,4 +24,4 @@ mov rax, [rdx + 8*rcx + 42] ``` -[prev](41.md) [next](43.md) +[prev](041.md) +++ [next](043.md) diff --git a/questions/answers/043.md b/questions/answers/043.md index c971010..5f7c219 100644 --- a/questions/answers/043.md +++ b/questions/answers/043.md @@ -12,4 +12,4 @@ Where does the program execution start? From the `_start` label. -[prev](42.md) [next](44.md) +[prev](042.md) +++ [next](044.md) diff --git a/questions/answers/044.md b/questions/answers/044.md index b15bb1a..f0d2132 100644 --- a/questions/answers/044.md +++ b/questions/answers/044.md @@ -19,4 +19,4 @@ Because of __little endian__: -[prev](43.md) [next](45.md) +[prev](043.md) +++ [next](045.md) diff --git a/questions/answers/045.md b/questions/answers/045.md index 4cea384..87a703d 100644 --- a/questions/answers/045.md +++ b/questions/answers/045.md @@ -21,4 +21,4 @@ Decypher this segment selector: `0x08`. * ring = 0, this is the 0-th protection ring, we are actually in the most privileged mode. -[prev](44.md) [next](46.md) +[prev](044.md) +++ [next](046.md) diff --git a/questions/answers/046.md b/questions/answers/046.md new file mode 100644 index 0000000..8d9e92b --- /dev/null +++ b/questions/answers/046.md @@ -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) diff --git a/questions/answers/047.md b/questions/answers/047.md index 9c1bd42..af6b427 100644 --- a/questions/answers/047.md +++ b/questions/answers/047.md @@ -17,4 +17,4 @@ There is little difference between these for caches or for virtual memory, because the latter can be viewed as a particular type of cache. -[prev](46.md) [next](48.md) +[prev](046.md) +++ [next](048.md) diff --git a/questions/answers/048.md b/questions/answers/048.md index 2b2bab0..c459de6 100644 --- a/questions/answers/048.md +++ b/questions/answers/048.md @@ -33,4 +33,4 @@ Anonymous pages correspond to no file in filesystem, thus their respective fields contain stub zeros. -[prev](47.md) [next](49.md) +[prev](047.md) +++ [next](049.md) diff --git a/questions/answers/049.md b/questions/answers/049.md index c3ed8f4..15b2382 100644 --- a/questions/answers/049.md +++ b/questions/answers/049.md @@ -13,4 +13,4 @@ We recommend the following article: [https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Memory/fully.html](https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Memory/fully.html) -[prev](48.md) [next](50.md) +[prev](048.md) +++ [next](050.md) diff --git a/questions/answers/050.md b/questions/answers/050.md index 18fb66e..ee7ca01 100644 --- a/questions/answers/050.md +++ b/questions/answers/050.md @@ -15,4 +15,4 @@ A continuous area of memory is called a region if: -[prev](49.md) [next](51.md) +[prev](049.md) +++ [next](051.md) diff --git a/questions/answers/051.md b/questions/answers/051.md index 87535e6..0fb8108 100644 --- a/questions/answers/051.md +++ b/questions/answers/051.md @@ -18,4 +18,4 @@ kills the process right away. You will see the error message `Segmentation fault -[prev](50.md) [next](52.md) +[prev](050.md) +++ [next](052.md) diff --git a/questions/answers/052.md b/questions/answers/052.md index fa3fde3..2d11af8 100644 --- a/questions/answers/052.md +++ b/questions/answers/052.md @@ -16,4 +16,4 @@ handled by OS. It usually involves killing current process right away. You will see the error message `Segmentation fault`. -[prev](51.md) [next](53.md) +[prev](051.md) +++ [next](053.md) diff --git a/questions/answers/053.md b/questions/answers/053.md index e754095..73a6f2e 100644 --- a/questions/answers/053.md +++ b/questions/answers/053.md @@ -19,4 +19,4 @@ is handled by OS, usually by killing the process. You will see an error message `Bus error`. -[prev](52.md) [next](54.md) +[prev](052.md) +++ [next](054.md) diff --git a/questions/answers/054.md b/questions/answers/054.md new file mode 100644 index 0000000..4190d90 --- /dev/null +++ b/questions/answers/054.md @@ -0,0 +1,27 @@ + +# Question 54 + + +What are the translation tables? + + +# Answer + + + + +These tables are used to perform address translation. In case of 4KB pages, +there are four levels of them: +* PML4 +* PDP +* PD +* PT + +There is only one PML4 table per address space (which is unique for each +process). Each table at any level contains up to 512 entries (4 KB / 8 bytes per +entry). Each entry stores either a part of the address of the table of the next +level, or, at the last level, the physical address of the page frame. + + + +[prev](053.md) +++ [next](055.md) diff --git a/questions/answers/055.md b/questions/answers/055.md index 3793087..b2c3e1e 100644 --- a/questions/answers/055.md +++ b/questions/answers/055.md @@ -14,4 +14,4 @@ plugged in. These slots are aligned at boundary equal to the page size. -[prev](54.md) [next](56.md) +[prev](054.md) +++ [next](056.md) diff --git a/questions/answers/056.md b/questions/answers/056.md index 69ab9a6..39c4336 100644 --- a/questions/answers/056.md +++ b/questions/answers/056.md @@ -16,4 +16,4 @@ A continuous area of memory is called a region if: -[prev](55.md) [next](57.md) +[prev](055.md) +++ [next](057.md) diff --git a/questions/answers/057.md b/questions/answers/057.md new file mode 100644 index 0000000..d9c6283 --- /dev/null +++ b/questions/answers/057.md @@ -0,0 +1,23 @@ + +# Question 57 + + +What is the virtual address space? How is it different from the +physical one? + + +# Answer + + + + +Physical address space is unique. It enumerates the cells of physical memory. +Virtual address space is created for each process, and the user programs +operate such virtual addresses. Any address you are using is from the +virtual realm. + +Some of the virtual addresses are then mapped to physical addresses based on +which parts of virtual address spaces are needed right now and in close future. + + +[prev](056.md) +++ [next](058.md) diff --git a/questions/answers/058.md b/questions/answers/058.md index 1f3e991..7d37ef6 100644 --- a/questions/answers/058.md +++ b/questions/answers/058.md @@ -17,4 +17,4 @@ Otherwise we have to crawl through all levels of page tables to perform the full address translation. The latter will add a new entry into TLB and the subsequent accesses will be faster. -[prev](57.md) [next](59.md) +[prev](057.md) +++ [next](059.md) diff --git a/questions/answers/059.md b/questions/answers/059.md index 7e69f5d..8f26c5b 100644 --- a/questions/answers/059.md +++ b/questions/answers/059.md @@ -15,4 +15,4 @@ Because of locality: -[prev](58.md) [next](60.md) +[prev](058.md) +++ [next](060.md) diff --git a/questions/answers/060.md b/questions/answers/060.md index 99fdcf3..b7323c1 100644 --- a/questions/answers/060.md +++ b/questions/answers/060.md @@ -15,4 +15,4 @@ the current address space. -[prev](59.md) [next](61.md) +[prev](059.md) +++ [next](061.md) diff --git a/questions/answers/061.md b/questions/answers/061.md index 6616205..63ca803 100644 --- a/questions/answers/061.md +++ b/questions/answers/061.md @@ -16,4 +16,4 @@ them on or off: * It is possible to forbid access from user mode (any ring besides ring0 -- U bit) -[prev](60.md) [next](62.md) +[prev](060.md) +++ [next](062.md) diff --git a/questions/answers/062.md b/questions/answers/062.md index 88ba5ac..261bbd0 100644 --- a/questions/answers/062.md +++ b/questions/answers/062.md @@ -13,4 +13,4 @@ It forbids execution of code from the respective page. -[prev](61.md) [next](63.md) +[prev](061.md) +++ [next](063.md) diff --git a/questions/answers/063.md b/questions/answers/063.md index cb9c842..e3d3748 100644 --- a/questions/answers/063.md +++ b/questions/answers/063.md @@ -15,4 +15,4 @@ See Figure 4-3 on page 55. -[prev](62.md) [next](64.md) +[prev](062.md) +++ [next](064.md) diff --git a/questions/answers/064.md b/questions/answers/064.md index 8bdaa24..c0a3573 100644 --- a/questions/answers/064.md +++ b/questions/answers/064.md @@ -13,4 +13,4 @@ Yes, the least significant 12 bits denote the offset inside the page. They are similar in physical and virtual address. Refer to Figures 4-1 and 4-2. -[prev](63.md) [next](65.md) +[prev](063.md) +++ [next](065.md) diff --git a/questions/answers/065.md b/questions/answers/065.md index 00d9b8b..082308f 100644 --- a/questions/answers/065.md +++ b/questions/answers/065.md @@ -15,4 +15,4 @@ overwrite it, because the pages that correspond to `.text` are marked read-only via W bit in their Page Table Entries. -[prev](64.md) [next](66.md) +[prev](064.md) +++ [next](066.md) diff --git a/questions/answers/068.md b/questions/answers/068.md new file mode 100644 index 0000000..efe8e29 --- /dev/null +++ b/questions/answers/068.md @@ -0,0 +1,17 @@ + +# Question 68 + + +Find more examples of `%define` and `%macro` usage in NASM +documentation. + + +# Answer + + + + +Refer to: [http://www.nasm.us/doc/nasmdoc4.html](http://www.nasm.us/doc/nasmdoc4.html) + + +[prev](067.md) +++ [next](069.md) diff --git a/questions/answers/069.md b/questions/answers/069.md new file mode 100644 index 0000000..2e10564 --- /dev/null +++ b/questions/answers/069.md @@ -0,0 +1,31 @@ + +# Question 69 + + +Check the preprocessor output on file, shown in Listing +`defining_in_cla.asm`: +```asm +%ifdef flag +hellostring: db "Hello",0 +%endif +``` + + +# Answer + + + + +By launching `nasm -E defining_in_cla.asm` we get the following output: + +```asm +%line 1+1 test.asm +``` + +As we see, the file became empty because `hellostring` is not created. The +lines between `%ifdef` and `%endif` will only be included if `flag` is defined +using `%define flag` directive or `-Dflag` compiler option + + + +[prev](068.md) +++ [next](070.md) diff --git a/questions/answers/072.md b/questions/answers/072.md new file mode 100644 index 0000000..b060513 --- /dev/null +++ b/questions/answers/072.md @@ -0,0 +1,28 @@ + +# Question 72 + + +Find out the `ld` option to automatically strip symbol table after linking. + + +# Answer + + + + +`man ld` suggests `-s` option: + +``` +-s +--strip-all + Omit all symbol information from the output file. + +-S +--strip-debug + Omit debugger symbol information (but not all symbols) from the output file. + +``` + + + +[prev](071.md) +++ [next](073.md) diff --git a/questions/answers/074.md b/questions/answers/074.md new file mode 100644 index 0000000..71034fd --- /dev/null +++ b/questions/answers/074.md @@ -0,0 +1,16 @@ + +# Question 74 + + +What is the meaning behind the environment variable `LD_LIBRARY_PATH`? + + +# Answer + + + +It is used to specify additional directories to search the dynamic libraries +for. These take priority over usual search locations. + + +[prev](073.md) +++ [next](075.md) diff --git a/questions/answers/077.md b/questions/answers/077.md new file mode 100644 index 0000000..a295117 --- /dev/null +++ b/questions/answers/077.md @@ -0,0 +1,39 @@ + +# Question 77 + + +What is the linked list? + + +# Answer + + + +It is a data structure consisting of nodes: + +* Each node contains an element and a link to the next element. +* The address of the first node defines the linked list. +* The last node's next element address is set to 0. By convention no element +can reside at this address. + +For example, here is a hardcoded linked list of integers 1, 2 and 3 in assembly: + +```asm +elem1: + +dq 1 +dq elem2 ; the address of the second element + +elem3: ; The elements can be in whatever order you like, + ; because they all hold addresses of their successors anyway +dq 3 +dq 0 ; no successor for the last element + +elem2: + +dq 2 +dq elem3 +``` + + +[prev](076.md) +++ [next](078.md)