]> nyquistdev.net Git - beginning-low-level-learning.git/commitdiff
first commit
authorA-Larsen <austin.larsen@mailfence.com>
Thu, 15 Oct 2026 22:36:53 +0000 (18:36 -0400)
committerA-Larsen <austin.larsen@mailfence.com>
Thu, 15 Oct 2026 22:36:53 +0000 (18:36 -0400)
35 files changed:
Makefile [new file with mode: 0644]
README.adoc [new file with mode: 0644]
asm_next.gdb [new file with mode: 0644]
circle.nasm [new file with mode: 0644]
circle_other.nasm [new file with mode: 0644]
docs/Makefile [new file with mode: 0644]
docs/Q-and-A.adoc [new file with mode: 0644]
docs/Q-and-A.html [new file with mode: 0644]
docs/c-disassembling.adoc [new file with mode: 0644]
docs/c-disassembling.html [new file with mode: 0644]
docs/diag-ditaa-md5-748c8d76a4b154138a91a12caf43c78a.png [new file with mode: 0644]
docs/docinfo.html [new file with mode: 0644]
docs/docinfo.js [new file with mode: 0644]
docs/index.adoc [new file with mode: 0644]
docs/index.html [new file with mode: 0644]
endianess.nasm [new file with mode: 0644]
example2-3.nasm [new file with mode: 0644]
false.nasm [new file with mode: 0644]
fcalc.nasm [new file with mode: 0644]
function4.nasm [new file with mode: 0644]
function_test1.nasm [new file with mode: 0644]
hello_world.nasm [new file with mode: 0644]
icalc.nasm [new file with mode: 0644]
inline_assembly.c [new file with mode: 0644]
loop.nasm [new file with mode: 0644]
memory.nasm [new file with mode: 0644]
print_call.nasm [new file with mode: 0644]
printf.nasm [new file with mode: 0644]
question_print_int.nasm [new file with mode: 0644]
question_print_int_new.nasm [new file with mode: 0644]
rect.nasm [new file with mode: 0644]
stack.nasm [new file with mode: 0644]
strlen.nasm [new file with mode: 0644]
tst.nasm [new file with mode: 0644]
write_number.nasm [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..571ee79
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,35 @@
+ifeq ($(PROG),function4)
+
+function4: function4.o circle.o rect.o
+       gcc -g -o function4 function4.o circle.o rect.o -no-pie
+
+function4.o: function4.nasm
+       nasm -f elf64 -g -F dwarf function4.nasm -l function4.lst
+
+circle.o: circle.nasm
+       nasm -f elf64 -g -F dwarf circle.nasm -l circle.lst
+
+rect.o: rect.nasm
+       nasm -f elf64 -g -F dwarf rect.nasm -l rect.lst
+
+else ifeq ($(PROG),inline_assembly)
+
+inline_assembly: inline_assembly.c
+       gcc -o inline_assembly inline_assembly.c
+
+else
+
+executatble: binary
+       gcc -o $(PROG) $(PROG).o -no-pie
+
+binary: $(PROG).nasm
+       nasm -f elf64 -g -F dwarf $(PROG).nasm
+
+endif
+
+clean:
+       rm -rf *.o *.lst
+       rm -rf $(shell  find . -maxdepth 1 -type f -executable)
+
+.PHONY: clean  
+
diff --git a/README.adoc b/README.adoc
new file mode 100644 (file)
index 0000000..a9266ca
--- /dev/null
@@ -0,0 +1,12 @@
+== Beginning Low Level Programming
+
+https://html-preview.github.io/?url=https://github.com/A-Larsen/beginning_low_level_learning/blob/main/docs/index.html[Notes]
+
+== building a binary
+
+----
+make PROG=<nasm file without 'nasm' extension>
+----
+
+
+
diff --git a/asm_next.gdb b/asm_next.gdb
new file mode 100644 (file)
index 0000000..4f7ae77
--- /dev/null
@@ -0,0 +1,6 @@
+set language asm
+set disassembly-flavor intel
+define asm_next
+nexti
+disassemble
+end
diff --git a/circle.nasm b/circle.nasm
new file mode 100644 (file)
index 0000000..afd8e5f
--- /dev/null
@@ -0,0 +1,34 @@
+extern pi
+
+global c_area
+global c_circum
+
+section .data
+section .bss
+section .text
+
+c_area:
+    section .text
+    push rbp
+    mov rbp, rsp
+
+    movsd xmm1, qword [pi]
+    mulsd xmm0, xmm0 ; radius in xmm0
+    mulsd xmm0, xmm1
+
+    mov rsp, rbp
+    pop rbp
+    ret
+
+c_circum:
+    section .text
+    push rbp
+    mov rbp, rsp
+
+    movsd xmm1, qword [pi]
+    addsd xmm0, xmm0 ; radius in xmm0
+    mulsd xmm0, xmm1
+
+    mov rsp, rbp
+    pop rbp
+    ret
diff --git a/circle_other.nasm b/circle_other.nasm
new file mode 100644 (file)
index 0000000..0a05cfa
--- /dev/null
@@ -0,0 +1,58 @@
+global main
+extern printf
+
+section .data
+    radius dq 10.0
+
+section .bss
+
+section .text
+
+area:
+section .data
+    .pi dq 3.141592654 ; local to area
+section .text
+    push rbp
+    mov rbp, rsp
+    movsd xmm0, [radius]
+    mulsd xmm0, [radius]
+    mulsd xmm0, [.pi]
+    leave
+    ret
+
+circum:
+section .data
+    .pi dq 3.14 ; local to circum
+section .text
+    push rbp
+    mov rbp, rsp
+    movsd xmm0, [radius]
+    addsd xmm0, [radius]
+    mulsd xmm0, [.pi]
+    leave
+    ret
+
+circle:
+section .data
+    .fmt_area db "The area is %f",10, 0
+    .fmt_circum db "The circumference if %f",10, 0
+section .text
+    push rbp
+    mov rbp, rsp
+    call area
+    mov rdi, .fmt_area
+    mov rax, 1 ; area in xmm0
+    call printf
+    call circum
+    mov rdi, .fmt_circum
+    mov rax, 1 ; circumference in xmm0
+    call printf
+    leave
+    ret
+
+main:
+    push rbp
+    mov rbp, rsp
+    call circle
+    leave
+    ret
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644 (file)
index 0000000..9924424
--- /dev/null
@@ -0,0 +1,5 @@
+FILENAME=*.adoc
+
+build: $(FILENAME)
+       rm -rf diag*.png
+       asciidoctor -r asciidoctor-diagram -b html5 $(FILENAME)
diff --git a/docs/Q-and-A.adoc b/docs/Q-and-A.adoc
new file mode 100644 (file)
index 0000000..f13cf15
--- /dev/null
@@ -0,0 +1,101 @@
+= Q and A
+:docinfo: shared
+:source-highlighter: pygments
+:pygments-style: monokai
+:icons: font
+:stem:
+:toc: left
+
+== Working through Question 21
+to find the number in each decimal place I could use the formula
+
+----
+ floor(mod(num / 10 ^place); 10)
+----
+
+but I also need to find the numbers width
+for that I could use the formula
+
+----
+ round(log(10; num) + 1)
+----
+
+or
+
+----
+ count the number of times I can divide by 10 before reaching zero
+----
+
+make sure to use unsigned math to floor output maybe?
+might try this without tail call optimization first
+
+in this case I think I need to perform my own modulo
+dang forgot an easy way to get remander from a division problem
+
+math for creating modulo
+
+----
+ a / b = c
+ round(c) * b = d
+ a - d = answer
+----
+
+I can look through C's https://en.wikibooks.org/wiki/C_Programming/stdlib.h/itoa[itoa] source code and try something similar.
+
+[source, c]
+----
+ void itoa(int n, char s[])
+ {
+     int i, sign;
+ 
+     if ((sign = n) < 0)  /* record sign */
+         n = -n;          /* make n positive */
+     i = 0;
+     do {       /* generate digits in reverse order */
+         s[i++] = n % 10 + '0';   /* get next digit */
+     } while ((n /= 10) > 0);     /* delete it */
+     if (sign < 0)
+         s[i++] = '-';
+     s[i] = '\0';
+     reverse(s);
+ }
+----
+
+== Q and A
+A19::
+    r13 is not cleared before it is used and could return junk values
+
+Q21::
+    Try to rewrite `print_int` without calling `printf_uint` or copying its
+    code: Hint read about tail call optimization
+
+A21::
+    look at question_print_int.nasm
+
+Q33::
+    What is a label and does it have a size?
+
+A33::
+    labels are address. The size is 8 bytes because pointers
+
+Q45::
+    Decipher this selector: 0x08
+
+A45::
+- https://en.wikipedia.org/wiki/X86_memory_segmentation#Protected_mode
+- https://en.wikipedia.org/wiki/Segment_descriptor
+
+this is the A flag, and it determines if the memory was accessed
+
+== Other
+    From
+    https://en.wikipedia.org/wiki/X86_memory_segmentation[X86_memory_segmentation]:
+
+
+"...The actual location of the beginning of a segment in the linear address
+ space can be calculated with segment×16..."
+-- X86_memory_segmentation, wikipedia
+
+"Each segment begins at a multiple of 16 bytes, called a paragraph, from the
+beginning of the linear (flat) address space..."
+-- X86_memory_segmentation, wikipedia
diff --git a/docs/Q-and-A.html b/docs/Q-and-A.html
new file mode 100644 (file)
index 0000000..2920403
--- /dev/null
@@ -0,0 +1,1028 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="generator" content="Asciidoctor 2.0.16">
+<title>Q and A</title>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
+<style>
+/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
+/* Uncomment the following line when using as a custom stylesheet */
+/* @import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"; */
+html{font-family:sans-serif;-webkit-text-size-adjust:100%}
+a{background:none}
+a:focus{outline:thin dotted}
+a:active,a:hover{outline:0}
+h1{font-size:2em;margin:.67em 0}
+b,strong{font-weight:bold}
+abbr{font-size:.9em}
+abbr[title]{cursor:help;border-bottom:1px dotted #dddddf;text-decoration:none}
+dfn{font-style:italic}
+hr{height:0}
+mark{background:#ff0;color:#000}
+code,kbd,pre,samp{font-family:monospace;font-size:1em}
+pre{white-space:pre-wrap}
+q{quotes:"\201C" "\201D" "\2018" "\2019"}
+small{font-size:80%}
+sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
+sup{top:-.5em}
+sub{bottom:-.25em}
+img{border:0}
+svg:not(:root){overflow:hidden}
+figure{margin:0}
+audio,video{display:inline-block}
+audio:not([controls]){display:none;height:0}
+fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
+legend{border:0;padding:0}
+button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
+button,input{line-height:normal}
+button,select{text-transform:none}
+button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
+button[disabled],html input[disabled]{cursor:default}
+input[type=checkbox],input[type=radio]{padding:0}
+button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
+textarea{overflow:auto;vertical-align:top}
+table{border-collapse:collapse;border-spacing:0}
+*,::before,::after{box-sizing:border-box}
+html,body{font-size:100%}
+body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;line-height:1;position:relative;cursor:auto;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
+a:hover{cursor:pointer}
+img,object,embed{max-width:100%;height:auto}
+object,embed{height:100%}
+img{-ms-interpolation-mode:bicubic}
+.left{float:left!important}
+.right{float:right!important}
+.text-left{text-align:left!important}
+.text-right{text-align:right!important}
+.text-center{text-align:center!important}
+.text-justify{text-align:justify!important}
+.hide{display:none}
+img,object,svg{display:inline-block;vertical-align:middle}
+textarea{height:auto;min-height:50px}
+select{width:100%}
+.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
+div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}
+a{color:#2156a5;text-decoration:underline;line-height:inherit}
+a:hover,a:focus{color:#1d4b8f}
+a img{border:0}
+p{line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
+p aside{font-size:.875em;line-height:1.35;font-style:italic}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
+h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
+h1{font-size:2.125em}
+h2{font-size:1.6875em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
+h4,h5{font-size:1.125em}
+h6{font-size:1em}
+hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em}
+em,i{font-style:italic;line-height:inherit}
+strong,b{font-weight:bold;line-height:inherit}
+small{font-size:60%;line-height:inherit}
+code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
+ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
+ul,ol{margin-left:1.5em}
+ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0}
+ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
+ul.square{list-style-type:square}
+ul.circle{list-style-type:circle}
+ul.disc{list-style-type:disc}
+ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
+dl dt{margin-bottom:.3125em;font-weight:bold}
+dl dd{margin-bottom:1.25em}
+blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
+blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
+@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
+h1{font-size:2.75em}
+h2{font-size:2.3125em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
+h4{font-size:1.4375em}}
+table{background:#fff;margin-bottom:1.25em;border:1px solid #dedede;word-wrap:normal}
+table thead,table tfoot{background:#f7f8f7}
+table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
+table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
+table tr.even,table tr.alt{background:#f8f8f7}
+table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:1.6}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
+h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
+.center{margin-left:auto;margin-right:auto}
+.stretch{width:100%}
+.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
+.clearfix::after,.float-group::after{clear:both}
+:not(pre).nobreak{word-wrap:normal}
+:not(pre).nowrap{white-space:nowrap}
+:not(pre).pre-wrap{white-space:pre-wrap}
+:not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
+pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
+pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
+pre>code{display:block}
+pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
+em em{font-style:normal}
+strong strong{font-weight:400}
+.keyseq{color:rgba(51,51,51,.8)}
+kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;box-shadow:0 1px 0 rgba(0,0,0,.2),inset 0 0 0 .1em #fff;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
+.keyseq kbd:first-child{margin-left:0}
+.keyseq kbd:last-child{margin-right:0}
+.menuseq,.menuref{color:#000}
+.menuseq b:not(.caret),.menuref{font-weight:inherit}
+.menuseq{word-spacing:-.02em}
+.menuseq b.caret{font-size:1.25em;line-height:.8}
+.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
+b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
+b.button::before{content:"[";padding:0 3px 0 2px}
+b.button::after{content:"]";padding:0 2px 0 3px}
+p a>code:hover{color:rgba(0,0,0,.9)}
+#header,#content,#footnotes,#footer{width:100%;margin:0 auto;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
+#header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
+#header::after,#content::after,#footnotes::after,#footer::after{clear:both}
+#content{margin-top:1.25em}
+#content::before{content:none}
+#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
+#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
+#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
+#header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:flex;flex-flow:row wrap}
+#header .details span:first-child{margin-left:-.125em}
+#header .details span.email a{color:rgba(0,0,0,.85)}
+#header .details br{display:none}
+#header .details br+span::before{content:"\00a0\2013\00a0"}
+#header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
+#header .details br+span#revremark::before{content:"\00a0|\00a0"}
+#header #revnumber{text-transform:capitalize}
+#header #revnumber::after{content:"\00a0"}
+#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
+#toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
+#toc>ul{margin-left:.125em}
+#toc ul.sectlevel0>li>a{font-style:italic}
+#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
+#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
+#toc li{line-height:1.3334;margin-top:.3334em}
+#toc a{text-decoration:none}
+#toc a:active{text-decoration:underline}
+#toctitle{color:#7a2518;font-size:1.2em}
+@media screen and (min-width:768px){#toctitle{font-size:1.375em}
+body.toc2{padding-left:15em;padding-right:0}
+#toc.toc2{margin-top:0!important;background:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
+#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
+#toc.toc2>ul{font-size:.9em;margin-bottom:0}
+#toc.toc2 ul ul{margin-left:0;padding-left:1em}
+#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
+body.toc2.toc-right{padding-left:0;padding-right:15em}
+body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
+@media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
+#toc.toc2{width:20em}
+#toc.toc2 #toctitle{font-size:1.375em}
+#toc.toc2>ul{font-size:.95em}
+#toc.toc2 ul ul{padding-left:1.25em}
+body.toc2.toc-right{padding-left:0;padding-right:20em}}
+#content #toc{border:1px solid #e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;border-radius:4px}
+#content #toc>:first-child{margin-top:0}
+#content #toc>:last-child{margin-bottom:0}
+#footer{max-width:none;background:rgba(0,0,0,.8);padding:1.25em}
+#footer-text{color:hsla(0,0%,100%,.8);line-height:1.44}
+#content{margin-bottom:.625em}
+.sect1{padding-bottom:.625em}
+@media screen and (min-width:768px){#content{margin-bottom:1.25em}
+.sect1{padding-bottom:1.25em}}
+.sect1:last-child{padding-bottom:0}
+.sect1+.sect1{border-top:1px solid #e7e7e9}
+#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
+#content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
+#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
+#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
+#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
+details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
+details{margin-left:1.25rem}
+details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;-webkit-tap-highlight-color:transparent}
+details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
+details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
+details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
+.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
+table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
+.paragraph.lead>p,#preamble>.sectionbody>[class=paragraph]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
+.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
+.admonitionblock>table td.icon{text-align:center;width:80px}
+.admonitionblock>table td.icon img{max-width:none}
+.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
+.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6);word-wrap:anywhere}
+.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
+.exampleblock>.content{border:1px solid #e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;border-radius:4px}
+.exampleblock>.content>:first-child{margin-top:0}
+.exampleblock>.content>:last-child{margin-bottom:0}
+.sidebarblock{border:1px solid #dbdbd6;margin-bottom:1.25em;padding:1.25em;background:#f3f3f2;border-radius:4px}
+.sidebarblock>:first-child{margin-top:0}
+.sidebarblock>:last-child{margin-bottom:0}
+.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
+.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
+.literalblock pre,.listingblock>.content>pre{border-radius:4px;overflow-x:auto;padding:1em;font-size:.8125em}
+@media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
+@media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
+.literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class=highlight],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
+.literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
+.listingblock>.content{position:relative}
+.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
+.listingblock:hover code[data-lang]::before{display:block}
+.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
+.listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
+.listingblock pre.highlightjs{padding:0}
+.listingblock pre.highlightjs>code{padding:1em;border-radius:4px}
+.listingblock pre.prettyprint{border-width:0}
+.prettyprint{background:#f7f7f8}
+pre.prettyprint .linenums{line-height:1.45;margin-left:2em}
+pre.prettyprint li{background:none;list-style-type:inherit;padding-left:0}
+pre.prettyprint li code[data-lang]::before{opacity:1}
+pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
+table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
+table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
+table.linenotable td.code{padding-left:.75em}
+table.linenotable td.linenos{border-right:1px solid;opacity:.35;padding-right:.5em}
+pre.pygments .lineno{border-right:1px solid;opacity:.35;display:inline-block;margin-right:.75em}
+pre.pygments .lineno::before{content:"";margin-right:-.125em}
+.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
+.quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
+.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
+.quoteblock blockquote{margin:0;padding:0;border:0}
+.quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
+.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
+.quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
+.verseblock{margin:0 1em 1.25em}
+.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans-serif;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
+.verseblock pre strong{font-weight:400}
+.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
+.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
+.quoteblock .attribution br,.verseblock .attribution br{display:none}
+.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
+.quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
+.quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
+.quoteblock.abstract{margin:0 1em 1.25em;display:block}
+.quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
+.quoteblock.excerpt>blockquote,.quoteblock .quoteblock{padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
+.quoteblock.excerpt,.quoteblock .quoteblock{margin-left:0}
+.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
+.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:.85rem;text-align:left;margin-right:0}
+p.tableblock:last-child{margin-bottom:0}
+td.tableblock>.content{margin-bottom:1.25em;word-wrap:anywhere}
+td.tableblock>.content>:last-child{margin-bottom:-1.25em}
+table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
+table.grid-all>*>tr>*{border-width:1px}
+table.grid-cols>*>tr>*{border-width:0 1px}
+table.grid-rows>*>tr>*{border-width:1px 0}
+table.frame-all{border-width:1px}
+table.frame-ends{border-width:1px 0}
+table.frame-sides{border-width:0 1px}
+table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}
+table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
+table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
+table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
+table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd),table.stripes-even tr:nth-of-type(even),table.stripes-hover tr:hover{background:#f8f8f7}
+th.halign-left,td.halign-left{text-align:left}
+th.halign-right,td.halign-right{text-align:right}
+th.halign-center,td.halign-center{text-align:center}
+th.valign-top,td.valign-top{vertical-align:top}
+th.valign-bottom,td.valign-bottom{vertical-align:bottom}
+th.valign-middle,td.valign-middle{vertical-align:middle}
+table thead th,table tfoot th{font-weight:bold}
+tbody tr th{background:#f7f8f7}
+tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
+p.tableblock>code:only-child{background:none;padding:0}
+p.tableblock{font-size:1em}
+ol{margin-left:1.75em}
+ul li ol{margin-left:1.5em}
+dl dd{margin-left:1.125em}
+dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
+ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
+ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
+ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
+ul.unstyled,ol.unstyled{margin-left:0}
+ul.checklist>li>p:first-child{margin-left:-1em}
+ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
+ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
+ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
+ul.inline>li{margin-left:1.25em}
+.unstyled dl dt{font-weight:400;font-style:normal}
+ol.arabic{list-style-type:decimal}
+ol.decimal{list-style-type:decimal-leading-zero}
+ol.loweralpha{list-style-type:lower-alpha}
+ol.upperalpha{list-style-type:upper-alpha}
+ol.lowerroman{list-style-type:lower-roman}
+ol.upperroman{list-style-type:upper-roman}
+ol.lowergreek{list-style-type:lower-greek}
+.hdlist>table,.colist>table{border:0;background:none}
+.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
+td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
+td.hdlist1{font-weight:bold;padding-bottom:1.25em}
+td.hdlist2{word-wrap:anywhere}
+.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
+.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
+.colist td:not([class]):first-child img{max-width:none}
+.colist td:not([class]):last-child{padding:.25em 0}
+.thumb,.th{line-height:0;display:inline-block;border:4px solid #fff;box-shadow:0 0 0 1px #ddd}
+.imageblock.left{margin:.25em .625em 1.25em 0}
+.imageblock.right{margin:.25em 0 1.25em .625em}
+.imageblock>.title{margin-bottom:0}
+.imageblock.thumb,.imageblock.th{border-width:6px}
+.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
+.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
+.image.left{margin-right:.625em}
+.image.right{margin-left:.625em}
+a.image{text-decoration:none;display:inline-block}
+a.image object{pointer-events:none}
+sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
+sup.footnote a,sup.footnoteref a{text-decoration:none}
+sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
+#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
+#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
+#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
+#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
+#footnotes .footnote:last-of-type{margin-bottom:0}
+#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
+.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
+.gist .file-data>table td.line-data{width:99%}
+div.unbreakable{page-break-inside:avoid}
+.big{font-size:larger}
+.small{font-size:smaller}
+.underline{text-decoration:underline}
+.overline{text-decoration:overline}
+.line-through{text-decoration:line-through}
+.aqua{color:#00bfbf}
+.aqua-background{background:#00fafa}
+.black{color:#000}
+.black-background{background:#000}
+.blue{color:#0000bf}
+.blue-background{background:#0000fa}
+.fuchsia{color:#bf00bf}
+.fuchsia-background{background:#fa00fa}
+.gray{color:#606060}
+.gray-background{background:#7d7d7d}
+.green{color:#006000}
+.green-background{background:#007d00}
+.lime{color:#00bf00}
+.lime-background{background:#00fa00}
+.maroon{color:#600000}
+.maroon-background{background:#7d0000}
+.navy{color:#000060}
+.navy-background{background:#00007d}
+.olive{color:#606000}
+.olive-background{background:#7d7d00}
+.purple{color:#600060}
+.purple-background{background:#7d007d}
+.red{color:#bf0000}
+.red-background{background:#fa0000}
+.silver{color:#909090}
+.silver-background{background:#bcbcbc}
+.teal{color:#006060}
+.teal-background{background:#007d7d}
+.white{color:#bfbfbf}
+.white-background{background:#fafafa}
+.yellow{color:#bfbf00}
+.yellow-background{background:#fafa00}
+span.icon>.fa{cursor:default}
+a span.icon>.fa{cursor:inherit}
+.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
+.admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
+.admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
+.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
+.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
+.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
+.conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);border-radius:50%;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
+.conum[data-value] *{color:#fff!important}
+.conum[data-value]+b{display:none}
+.conum[data-value]::after{content:attr(data-value)}
+pre .conum[data-value]{position:relative;top:-.125em}
+b.conum *{color:inherit!important}
+.conum:not([data-value]):empty{display:none}
+dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
+h1,h2,p,td.content,span.alt,summary{letter-spacing:-.01em}
+p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
+p,blockquote,dt,td.content,span.alt,summary{font-size:1.0625rem}
+p{margin-bottom:1.25rem}
+.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
+.exampleblock>.content{background:#fffef7;border-color:#e0e0dc;box-shadow:0 1px 4px #e0e0dc}
+.print-only{display:none!important}
+@page{margin:1.25cm .75cm}
+@media print{*{box-shadow:none!important;text-shadow:none!important}
+html{font-size:80%}
+a{color:inherit!important;text-decoration:underline!important}
+a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
+a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
+abbr[title]{border-bottom:1px dotted}
+abbr[title]::after{content:" (" attr(title) ")"}
+pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
+thead{display:table-header-group}
+svg{max-width:100%}
+p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
+h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
+#header,#content,#footnotes,#footer{max-width:none}
+#toc,.sidebarblock,.exampleblock>.content{background:none!important}
+#toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
+body.book #header{text-align:center}
+body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
+body.book #header .details{border:0!important;display:block;padding:0!important}
+body.book #header .details span:first-child{margin-left:0!important}
+body.book #header .details br{display:block}
+body.book #header .details br+span::before{content:none!important}
+body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
+body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
+.listingblock code[data-lang]::before{display:block}
+#footer{padding:0 .9375em}
+.hide-on-print{display:none!important}
+.print-only{display:block!important}
+.hide-for-print{display:none!important}
+.show-for-print{display:inherit!important}}
+@media amzn-kf8,print{#header>h1:first-child{margin-top:1.25rem}
+.sect1{padding:0!important}
+.sect1+.sect1{border:0}
+#footer{background:none}
+#footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
+@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
+</style>
+<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
+<style>
+pre { line-height: 125%; }
+td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+pre.pygments .hll { background-color: #49483e }
+pre.pygments { background: #272822; color: #f8f8f2 }
+pre.pygments .tok-c { color: #75715e } /* Comment */
+pre.pygments .tok-err { color: #960050; background-color: #1e0010 } /* Error */
+pre.pygments .tok-k { color: #66d9ef } /* Keyword */
+pre.pygments .tok-l { color: #ae81ff } /* Literal */
+pre.pygments .tok-n { color: #f8f8f2 } /* Name */
+pre.pygments .tok-o { color: #f92672 } /* Operator */
+pre.pygments .tok-p { color: #f8f8f2 } /* Punctuation */
+pre.pygments .tok-ch { color: #75715e } /* Comment.Hashbang */
+pre.pygments .tok-cm { color: #75715e } /* Comment.Multiline */
+pre.pygments .tok-cp { color: #75715e } /* Comment.Preproc */
+pre.pygments .tok-cpf { color: #75715e } /* Comment.PreprocFile */
+pre.pygments .tok-c1 { color: #75715e } /* Comment.Single */
+pre.pygments .tok-cs { color: #75715e } /* Comment.Special */
+pre.pygments .tok-gd { color: #f92672 } /* Generic.Deleted */
+pre.pygments .tok-ge { font-style: italic } /* Generic.Emph */
+pre.pygments .tok-gi { color: #a6e22e } /* Generic.Inserted */
+pre.pygments .tok-go { color: #66d9ef } /* Generic.Output */
+pre.pygments .tok-gp { color: #f92672; font-weight: bold } /* Generic.Prompt */
+pre.pygments .tok-gs { font-weight: bold } /* Generic.Strong */
+pre.pygments .tok-gu { color: #75715e } /* Generic.Subheading */
+pre.pygments .tok-kc { color: #66d9ef } /* Keyword.Constant */
+pre.pygments .tok-kd { color: #66d9ef } /* Keyword.Declaration */
+pre.pygments .tok-kn { color: #f92672 } /* Keyword.Namespace */
+pre.pygments .tok-kp { color: #66d9ef } /* Keyword.Pseudo */
+pre.pygments .tok-kr { color: #66d9ef } /* Keyword.Reserved */
+pre.pygments .tok-kt { color: #66d9ef } /* Keyword.Type */
+pre.pygments .tok-ld { color: #e6db74 } /* Literal.Date */
+pre.pygments .tok-m { color: #ae81ff } /* Literal.Number */
+pre.pygments .tok-s { color: #e6db74 } /* Literal.String */
+pre.pygments .tok-na { color: #a6e22e } /* Name.Attribute */
+pre.pygments .tok-nb { color: #f8f8f2 } /* Name.Builtin */
+pre.pygments .tok-nc { color: #a6e22e } /* Name.Class */
+pre.pygments .tok-no { color: #66d9ef } /* Name.Constant */
+pre.pygments .tok-nd { color: #a6e22e } /* Name.Decorator */
+pre.pygments .tok-ni { color: #f8f8f2 } /* Name.Entity */
+pre.pygments .tok-ne { color: #a6e22e } /* Name.Exception */
+pre.pygments .tok-nf { color: #a6e22e } /* Name.Function */
+pre.pygments .tok-nl { color: #f8f8f2 } /* Name.Label */
+pre.pygments .tok-nn { color: #f8f8f2 } /* Name.Namespace */
+pre.pygments .tok-nx { color: #a6e22e } /* Name.Other */
+pre.pygments .tok-py { color: #f8f8f2 } /* Name.Property */
+pre.pygments .tok-nt { color: #f92672 } /* Name.Tag */
+pre.pygments .tok-nv { color: #f8f8f2 } /* Name.Variable */
+pre.pygments .tok-ow { color: #f92672 } /* Operator.Word */
+pre.pygments .tok-w { color: #f8f8f2 } /* Text.Whitespace */
+pre.pygments .tok-mb { color: #ae81ff } /* Literal.Number.Bin */
+pre.pygments .tok-mf { color: #ae81ff } /* Literal.Number.Float */
+pre.pygments .tok-mh { color: #ae81ff } /* Literal.Number.Hex */
+pre.pygments .tok-mi { color: #ae81ff } /* Literal.Number.Integer */
+pre.pygments .tok-mo { color: #ae81ff } /* Literal.Number.Oct */
+pre.pygments .tok-sa { color: #e6db74 } /* Literal.String.Affix */
+pre.pygments .tok-sb { color: #e6db74 } /* Literal.String.Backtick */
+pre.pygments .tok-sc { color: #e6db74 } /* Literal.String.Char */
+pre.pygments .tok-dl { color: #e6db74 } /* Literal.String.Delimiter */
+pre.pygments .tok-sd { color: #e6db74 } /* Literal.String.Doc */
+pre.pygments .tok-s2 { color: #e6db74 } /* Literal.String.Double */
+pre.pygments .tok-se { color: #ae81ff } /* Literal.String.Escape */
+pre.pygments .tok-sh { color: #e6db74 } /* Literal.String.Heredoc */
+pre.pygments .tok-si { color: #e6db74 } /* Literal.String.Interpol */
+pre.pygments .tok-sx { color: #e6db74 } /* Literal.String.Other */
+pre.pygments .tok-sr { color: #e6db74 } /* Literal.String.Regex */
+pre.pygments .tok-s1 { color: #e6db74 } /* Literal.String.Single */
+pre.pygments .tok-ss { color: #e6db74 } /* Literal.String.Symbol */
+pre.pygments .tok-bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
+pre.pygments .tok-fm { color: #a6e22e } /* Name.Function.Magic */
+pre.pygments .tok-vc { color: #f8f8f2 } /* Name.Variable.Class */
+pre.pygments .tok-vg { color: #f8f8f2 } /* Name.Variable.Global */
+pre.pygments .tok-vi { color: #f8f8f2 } /* Name.Variable.Instance */
+pre.pygments .tok-vm { color: #f8f8f2 } /* Name.Variable.Magic */
+pre.pygments .tok-il { color: #ae81ff } /* Literal.Number.Integer.Long */
+</style>
+<head>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=DotGothic16">
+<link rel="icon" type="image/png" href="N2DE_favicon.png"/>
+
+<style>
+
+/*--------------------------------------------------------------*/
+/*use '!important' to override default css used by asciidoctor*/
+/*--------------------------------------------------------------*/
+
+:root {
+    --gruvbox-black: #282828;
+    --gruvbox-black2: #1d2021;
+    --gruvbox-black3: #463f39;
+    --gruvbox-red: #fb4934;
+    --gruvbox-yellow: #fabd2f;
+    --gruvbox-white: #ebdbb2;
+    --gruvbox-white2: #fbf1c7;
+    --gruvbox-blue: #83a598;
+    --gruvbox-green: #b8bb26;
+    --gruvbox-bg1: #7c6f64;
+    --gruvbox-bg2: #665c54;
+
+}
+
+.title {
+  color: var(--gruvbox-red) !important;
+}
+
+blockquote {
+    color: var(--gruvbox-white) !important;
+}
+
+.hdlist1 {
+  font-size: 1.3em;
+}
+
+cite {
+    color: var(--gruvbox-green) !important;
+}
+
+.tableblock {
+    background-color: inherit;
+    color: var(--gruvbox-white);
+    max-width: 95%;
+}
+
+.tableblock th {
+    background-color: var(--gruvbox-black3);
+    color: var(--gruvbox-white);
+    max-width: 97%;
+}
+
+code:not([data-lang]) {
+    background-color: var(--gruvbox-bg2) !important;
+    color: var(--gruvbox-white);
+    text-shadow: none;
+}
+
+.checklist {
+    text-align: left;
+    font-size: .8em;
+}
+
+.checklist li ul { margin-left: 3%;
+}
+
+#content, h1, pre {
+    border-radius: 8px !important;
+}
+
+#header, #content, #footnotes, #footer {
+  padding-left: 0 !important;
+  padding-right: 0 !important;
+}
+
+.api-type a:hover {
+    text-decoration: underline;
+}
+
+.api-type, .api-type a {
+    color: var(--gruvbox-green);
+    text-decoration: none;
+}
+
+pre {
+    border-style: solid !important;
+    border-color: white !important;
+    border-width: 2px !important;
+}
+
+h1 {
+    font-family: "DotGothic16", sans-serif !important;
+    background-color: var(--gruvbox-bg2) !important;
+    color: var(--gruvbox-white) !important;
+    opacity: .6;
+}
+
+.admonitionblock > table td.content {
+    color: var(--gruvbox-white) !important;
+}
+
+/*
+html {
+    margin: 0;
+    height: 100%;
+    width: 100%;
+}
+
+*/
+/*html {*/
+body {
+    /*background: black url("background-image-space.jpeg") no-repeat fixed center;*/
+    /*background-color: black;*/
+    background-color: var(--gruvbox-black);
+    background-attachment: fixed;
+    background-size: cover;
+    overflow-y: scroll;
+    /*
+    margin: 0;
+    height: 100%;
+    width: 100%;
+    overflow: hidden;
+    */
+}
+
+
+/*
+body {
+    overflow-y: scroll;
+    background: rgba(0,0,0,0);
+    height: 100%;
+    margin: 2%;
+}
+*/
+
+#toc {
+    background-color: var(--gruvbox-black2) !important;
+    /*opacity: .9;*/
+}
+
+#toctitle {
+    color: var(--gruvbox-red);
+}
+
+a {
+    color: var(--gruvbox-blue);
+}
+
+#content {
+    color: #ebdbb2;
+    background: var(--gruvbox-black);
+    /*opacity: .9;*/
+}
+
+#header > h1:nth-last-child(2) {
+    border-bottom: none !important;
+    background-color: rgba(0, 0, 0, .1);
+    padding-left: 2%;
+}
+
+.sect1 + .sect1 {
+  border-top: none !important;
+}
+
+.sect1 h2 {
+    background-size: cover;
+    background-attachment: fixed;
+    border-bottom: 1px solid var(--gruvbox-white);
+    border-top: 1px solid var(--gruvbox-white);
+    text-align: center;
+    color: var(--gruvbox-white) !important;
+    /*
+    text-shadow: 1px 1px 1px var(--gruvbox-black);
+    text-shadow: 3px 3px 3px var(--gruvbox-black);
+    text-shadow: 5px 5px 5px var(--gruvbox-blue);
+    */
+}
+
+h3, h4, h5 {
+    /*
+    text-shadow: 1px 1px 1px var(--gruvbox-white);
+    */
+}
+
+h3 {
+  color: var(--gruvbox-red) !important;
+}
+
+h4 {
+  color: var(--gruvbox-yellow) !important;
+}
+
+h5 {
+  color: #83a598 !important;
+}
+
+h2 ~ *:not(h1) {
+  margin-left: .5em;
+}
+
+.pygments {
+    max-width: 97% !important;
+    white-space: pre;
+    overflow-x: scroll !important;
+}
+
+::before {
+    /*makes sure that the programming language that show up on hover is within
+      pre tag*/
+    padding-right: 3%;
+}
+
+@media screen and (max-width: 800px) {
+    .checklist li ul {
+        margin-left: 6% !important;
+    }
+    #toc {
+        padding-left: 10px;
+    }
+
+    footer {
+        margin-bottom: 10px !important;
+    }
+    html {
+        margin-bottom: 10px !important;
+    }
+}
+@media screen and (max-width: 535px) {
+    h3 ~ *:not(h2):not(h3) {
+      margin-left: 0 !important;
+    }
+
+    h4 ~ *:not(h2):not(h3):not(.h3):not(h4) {
+      margin-left: 0 !important;
+    }
+    h5 ~ *:not(h2):not(h3):not(.h3):not(h4):not(.h4):not(h5) {
+      margin-left: 0 !important;
+    }
+
+    footer {
+        margin-bottom: 10px !important;
+    }
+    html {
+        margin-bottom: 10px !important;
+    }
+}
+h3 ~ *:not(h2):not(h3) {
+  margin-left: 1.5em;
+}
+
+h4 ~ *:not(h2):not(h3):not(.h3):not(h4) {
+  margin-left: 2em;
+}
+h5 ~ *:not(h2):not(h3):not(.h3):not(h4):not(.h4):not(h5) {
+  margin-left: 2.5em;
+}
+
+
+.sect1 h2 {
+    background: linear-gradient(
+        to bottom,
+        rgba(251, 189, 47, 0.2), /* yellow */
+        rgba(0, 0, 0, 0.4)       /* black */
+    );
+    /*opacity: .9;*/
+  }
+
+#preamble p{
+  padding-left: 10px;
+  color: var(--gruvbox-white) !important;
+}
+
+#footer {
+    max-width: 62.5em !important;
+    padding-left: 10px !important;
+    text-align: center;
+}
+
+.logo img {
+    display: block !important;
+    margin-left: auto !important;
+    margin-right: auto !important;
+}
+
+#header > h1:first-child {
+  margin-top: .3em !important;
+  padding-top: .2em !important;
+  padding-bottom: .3em !important;
+}
+
+footer {
+    max-width: 62.5em;
+    margin-left: auto;
+    margin-right: auto;
+    display: block;
+
+}
+
+details[open] > summary::before {
+   /* display: none;*/
+    border-top: none;
+    content: "▼";
+    margin-top: -12px;
+}
+
+</style>
+
+</head>
+
+<script src="docinfo.js"></script>
+
+
+</head>
+<body class="article toc2 toc-left">
+<div id="header">
+<h1>Q and A</h1>
+<div id="toc" class="toc2">
+<div id="toctitle">Table of Contents</div>
+<ul class="sectlevel1">
+<li><a href="#_working_through_question_21">Working through Question 21</a></li>
+<li><a href="#_q_and_a">Q and A</a></li>
+<li><a href="#_other">Other</a></li>
+</ul>
+</div>
+</div>
+<div id="content">
+<div class="sect1">
+<h2 id="_working_through_question_21">Working through Question 21</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>to find the number in each decimal place I could use the formula</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre> floor(mod(num / 10 ^place); 10)</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>but I also need to find the numbers width
+for that I could use the formula</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre> round(log(10; num) + 1)</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>or</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre> count the number of times I can divide by 10 before reaching zero</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>make sure to use unsigned math to floor output maybe?
+might try this without tail call optimization first</p>
+</div>
+<div class="paragraph">
+<p>in this case I think I need to perform my own modulo
+dang forgot an easy way to get remander from a division problem</p>
+</div>
+<div class="paragraph">
+<p>math for creating modulo</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre> a / b = c
+ round(c) * b = d
+ a - d = answer</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>I can look through C&#8217;s <a href="https://en.wikibooks.org/wiki/C_Programming/stdlib.h/itoa">itoa</a> source code and try something similar.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c"><span></span><span class="tok-w"> </span><span class="tok-kt">void</span><span class="tok-w"> </span><span class="tok-nf">itoa</span><span class="tok-p">(</span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-kt">char</span><span class="tok-w"> </span><span class="tok-n">s</span><span class="tok-p">[])</span><span class="tok-w"></span>
+<span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
+<span class="tok-w">     </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">i</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">sign</span><span class="tok-p">;</span><span class="tok-w"></span>
+
+<span class="tok-w">     </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">((</span><span class="tok-n">sign</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w">  </span><span class="tok-cm">/* record sign */</span><span class="tok-w"></span>
+<span class="tok-w">         </span><span class="tok-n">n</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-o">-</span><span class="tok-n">n</span><span class="tok-p">;</span><span class="tok-w">          </span><span class="tok-cm">/* make n positive */</span><span class="tok-w"></span>
+<span class="tok-w">     </span><span class="tok-n">i</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">;</span><span class="tok-w"></span>
+<span class="tok-w">     </span><span class="tok-k">do</span><span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w">       </span><span class="tok-cm">/* generate digits in reverse order */</span><span class="tok-w"></span>
+<span class="tok-w">         </span><span class="tok-n">s</span><span class="tok-p">[</span><span class="tok-n">i</span><span class="tok-o">++</span><span class="tok-p">]</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-n">n</span><span class="tok-w"> </span><span class="tok-o">%</span><span class="tok-w"> </span><span class="tok-mi">10</span><span class="tok-w"> </span><span class="tok-o">+</span><span class="tok-w"> </span><span class="tok-sc">&#39;0&#39;</span><span class="tok-p">;</span><span class="tok-w">   </span><span class="tok-cm">/* get next digit */</span><span class="tok-w"></span>
+<span class="tok-w">     </span><span class="tok-p">}</span><span class="tok-w"> </span><span class="tok-k">while</span><span class="tok-w"> </span><span class="tok-p">((</span><span class="tok-n">n</span><span class="tok-w"> </span><span class="tok-o">/=</span><span class="tok-w"> </span><span class="tok-mi">10</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">&gt;</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">);</span><span class="tok-w">     </span><span class="tok-cm">/* delete it */</span><span class="tok-w"></span>
+<span class="tok-w">     </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-n">sign</span><span class="tok-w"> </span><span class="tok-o">&lt;</span><span class="tok-w"> </span><span class="tok-mi">0</span><span class="tok-p">)</span><span class="tok-w"></span>
+<span class="tok-w">         </span><span class="tok-n">s</span><span class="tok-p">[</span><span class="tok-n">i</span><span class="tok-o">++</span><span class="tok-p">]</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-sc">&#39;-&#39;</span><span class="tok-p">;</span><span class="tok-w"></span>
+<span class="tok-w">     </span><span class="tok-n">s</span><span class="tok-p">[</span><span class="tok-n">i</span><span class="tok-p">]</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-sc">&#39;\0&#39;</span><span class="tok-p">;</span><span class="tok-w"></span>
+<span class="tok-w">     </span><span class="tok-n">reverse</span><span class="tok-p">(</span><span class="tok-n">s</span><span class="tok-p">);</span><span class="tok-w"></span>
+<span class="tok-w"> </span><span class="tok-p">}</span><span class="tok-w"></span></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_q_and_a">Q and A</h2>
+<div class="sectionbody">
+<div class="dlist">
+<dl>
+<dt class="hdlist1">A19</dt>
+<dd>
+<p>r13 is not cleared before it is used and could return junk values</p>
+</dd>
+<dt class="hdlist1">Q21</dt>
+<dd>
+<p>Try to rewrite <code>print_int</code> without calling <code>printf_uint</code> or copying its
+code: Hint read about tail call optimization</p>
+</dd>
+<dt class="hdlist1">A21</dt>
+<dd>
+<p>look at question_print_int.nasm</p>
+</dd>
+<dt class="hdlist1">Q33</dt>
+<dd>
+<p>What is a label and does it have a size?</p>
+</dd>
+<dt class="hdlist1">A33</dt>
+<dd>
+<p>labels are address. The size is 8 bytes because pointers</p>
+</dd>
+<dt class="hdlist1">Q45</dt>
+<dd>
+<p>Decipher this selector: 0x08</p>
+</dd>
+<dt class="hdlist1">A45</dt>
+<dd>
+<div class="ulist">
+<ul>
+<li>
+<p><a href="https://en.wikipedia.org/wiki/X86_memory_segmentation#Protected_mode" class="bare">https://en.wikipedia.org/wiki/X86_memory_segmentation#Protected_mode</a></p>
+</li>
+<li>
+<p><a href="https://en.wikipedia.org/wiki/Segment_descriptor" class="bare">https://en.wikipedia.org/wiki/Segment_descriptor</a></p>
+</li>
+</ul>
+</div>
+</dd>
+</dl>
+</div>
+<div class="paragraph">
+<p>this is the A flag, and it determines if the memory was accessed</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_other">Other</h2>
+<div class="sectionbody">
+<div class="literalblock">
+<div class="content">
+<pre>From
+https://en.wikipedia.org/wiki/X86_memory_segmentation[X86_memory_segmentation]:</pre>
+</div>
+</div>
+<div class="quoteblock">
+<blockquote>
+&#8230;&#8203;The actual location of the beginning of a segment in the linear address
+ space can be calculated with segment×16&#8230;&#8203;
+</blockquote>
+<div class="attribution">
+&#8212; X86_memory_segmentation<br>
+<cite>wikipedia</cite>
+</div>
+</div>
+<div class="quoteblock">
+<blockquote>
+Each segment begins at a multiple of 16 bytes, called a paragraph, from the
+beginning of the linear (flat) address space&#8230;&#8203;
+</blockquote>
+<div class="attribution">
+&#8212; X86_memory_segmentation<br>
+<cite>wikipedia</cite>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2024-03-26 19:00:34 -0400
+</div>
+</div>
+<script type="text/x-mathjax-config">
+MathJax.Hub.Config({
+  messageStyle: "none",
+  tex2jax: {
+    inlineMath: [["\\(", "\\)"]],
+    displayMath: [["\\[", "\\]"]],
+    ignoreClass: "nostem|nolatexmath"
+  },
+  asciimath2jax: {
+    delimiters: [["\\$", "\\$"]],
+    ignoreClass: "nostem|noasciimath"
+  },
+  TeX: { equationNumbers: { autoNumber: "none" } }
+})
+MathJax.Hub.Register.StartupHook("AsciiMath Jax Ready", function () {
+  MathJax.InputJax.AsciiMath.postfilterHooks.Add(function (data, node) {
+    if ((node = data.script.parentNode) && (node = node.parentNode) && node.classList.contains("stemblock")) {
+      data.math.root.display = "block"
+    }
+    return data
+  })
+})
+</script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/docs/c-disassembling.adoc b/docs/c-disassembling.adoc
new file mode 100644 (file)
index 0000000..7a5303c
--- /dev/null
@@ -0,0 +1,73 @@
+= C Disassembling
+:docinfo: shared
+:source-highlighter: pygments
+:pygments-style: monokai
+:icons: font
+:stem:
+:toc: left
+
+== Floating Points
+
+.assign_float.c
+[source, c]
+----
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(void){
+    float a = 10.0f;
+    return 1;
+}
+----
+
+.gdb disassemble
+[source, gdb]
+----
+(gdb) disass
+----
+
+.output
+[%collapsible]
+====
+       0x0000555555555129 <+0>:     endbr64 
+       0x000055555555512d <+4>:     push   rbp
+       0x000055555555512e <+5>:     mov    rbp,rsp
+       0x0000555555555131 <+8>:     movss  xmm0,DWORD PTR [rip+0xecb]        # 0x5555555560
+    04
+       0x0000555555555139 <+16>:    movss  DWORD PTR [rbp-0x4],xmm0
+    => 0x000055555555513e <+21>:    mov    eax,0x1
+       0x0000555555555143 <+26>:    pop    rbp
+       0x0000555555555144 <+27>:    ret    
+====
+
+`push rbp`,`mov rbp, rsp` is the function prologue for the stack frame.
+`pop rbp` is the function epilogue for the stack frame. In `mov eax, 0x1` eax is
+the return value for the function which we are setting to one. `xmm0` is the
+floating point register that has the value of `a` in single percision mode.
+
+.gdb print xmm0 register
+[source, gdb]
+----
+(gdb) p $xmm0
+----
+
+.output
+[%collapsible]
+====
+    $2 = {
+      v8_bfloat16 = {0, 10, 0, 0, 0, 0, 0, 0},
+      v8_half = {0, 2.5625, 0, 0, 0, 0, 0, 0},
+      v4_float = {10, 0, 0, 0},
+      v2_double = {5.3982412455708344e-315, 0},
+      v16_int8 = {0, 0, 32, 65, 0 <repeats 12 times>},
+      v8_int16 = {0, 16672, 0, 0, 0, 0, 0, 0},
+      v4_int32 = {1092616192, 0, 0, 0},
+      v2_int64 = {1092616192, 0},
+      uint128 = 1092616192
+    }
+====
+
+We can see `uint128` is 1092616192, which is the how the binary actually looks
+in single point percision. We can also see that `v4_float` stores the value of
+the number as we understand it.
diff --git a/docs/c-disassembling.html b/docs/c-disassembling.html
new file mode 100644 (file)
index 0000000..3feef72
--- /dev/null
@@ -0,0 +1,954 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="generator" content="Asciidoctor 2.0.16">
+<title>C Disassembling</title>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
+<style>
+/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
+/* Uncomment the following line when using as a custom stylesheet */
+/* @import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"; */
+html{font-family:sans-serif;-webkit-text-size-adjust:100%}
+a{background:none}
+a:focus{outline:thin dotted}
+a:active,a:hover{outline:0}
+h1{font-size:2em;margin:.67em 0}
+b,strong{font-weight:bold}
+abbr{font-size:.9em}
+abbr[title]{cursor:help;border-bottom:1px dotted #dddddf;text-decoration:none}
+dfn{font-style:italic}
+hr{height:0}
+mark{background:#ff0;color:#000}
+code,kbd,pre,samp{font-family:monospace;font-size:1em}
+pre{white-space:pre-wrap}
+q{quotes:"\201C" "\201D" "\2018" "\2019"}
+small{font-size:80%}
+sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
+sup{top:-.5em}
+sub{bottom:-.25em}
+img{border:0}
+svg:not(:root){overflow:hidden}
+figure{margin:0}
+audio,video{display:inline-block}
+audio:not([controls]){display:none;height:0}
+fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
+legend{border:0;padding:0}
+button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
+button,input{line-height:normal}
+button,select{text-transform:none}
+button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
+button[disabled],html input[disabled]{cursor:default}
+input[type=checkbox],input[type=radio]{padding:0}
+button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
+textarea{overflow:auto;vertical-align:top}
+table{border-collapse:collapse;border-spacing:0}
+*,::before,::after{box-sizing:border-box}
+html,body{font-size:100%}
+body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;line-height:1;position:relative;cursor:auto;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
+a:hover{cursor:pointer}
+img,object,embed{max-width:100%;height:auto}
+object,embed{height:100%}
+img{-ms-interpolation-mode:bicubic}
+.left{float:left!important}
+.right{float:right!important}
+.text-left{text-align:left!important}
+.text-right{text-align:right!important}
+.text-center{text-align:center!important}
+.text-justify{text-align:justify!important}
+.hide{display:none}
+img,object,svg{display:inline-block;vertical-align:middle}
+textarea{height:auto;min-height:50px}
+select{width:100%}
+.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
+div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}
+a{color:#2156a5;text-decoration:underline;line-height:inherit}
+a:hover,a:focus{color:#1d4b8f}
+a img{border:0}
+p{line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
+p aside{font-size:.875em;line-height:1.35;font-style:italic}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
+h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
+h1{font-size:2.125em}
+h2{font-size:1.6875em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
+h4,h5{font-size:1.125em}
+h6{font-size:1em}
+hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em}
+em,i{font-style:italic;line-height:inherit}
+strong,b{font-weight:bold;line-height:inherit}
+small{font-size:60%;line-height:inherit}
+code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
+ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
+ul,ol{margin-left:1.5em}
+ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0}
+ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
+ul.square{list-style-type:square}
+ul.circle{list-style-type:circle}
+ul.disc{list-style-type:disc}
+ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
+dl dt{margin-bottom:.3125em;font-weight:bold}
+dl dd{margin-bottom:1.25em}
+blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
+blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
+@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
+h1{font-size:2.75em}
+h2{font-size:2.3125em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
+h4{font-size:1.4375em}}
+table{background:#fff;margin-bottom:1.25em;border:1px solid #dedede;word-wrap:normal}
+table thead,table tfoot{background:#f7f8f7}
+table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
+table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
+table tr.even,table tr.alt{background:#f8f8f7}
+table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:1.6}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
+h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
+.center{margin-left:auto;margin-right:auto}
+.stretch{width:100%}
+.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
+.clearfix::after,.float-group::after{clear:both}
+:not(pre).nobreak{word-wrap:normal}
+:not(pre).nowrap{white-space:nowrap}
+:not(pre).pre-wrap{white-space:pre-wrap}
+:not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
+pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
+pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
+pre>code{display:block}
+pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
+em em{font-style:normal}
+strong strong{font-weight:400}
+.keyseq{color:rgba(51,51,51,.8)}
+kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;box-shadow:0 1px 0 rgba(0,0,0,.2),inset 0 0 0 .1em #fff;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
+.keyseq kbd:first-child{margin-left:0}
+.keyseq kbd:last-child{margin-right:0}
+.menuseq,.menuref{color:#000}
+.menuseq b:not(.caret),.menuref{font-weight:inherit}
+.menuseq{word-spacing:-.02em}
+.menuseq b.caret{font-size:1.25em;line-height:.8}
+.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
+b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
+b.button::before{content:"[";padding:0 3px 0 2px}
+b.button::after{content:"]";padding:0 2px 0 3px}
+p a>code:hover{color:rgba(0,0,0,.9)}
+#header,#content,#footnotes,#footer{width:100%;margin:0 auto;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
+#header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
+#header::after,#content::after,#footnotes::after,#footer::after{clear:both}
+#content{margin-top:1.25em}
+#content::before{content:none}
+#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
+#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
+#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
+#header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:flex;flex-flow:row wrap}
+#header .details span:first-child{margin-left:-.125em}
+#header .details span.email a{color:rgba(0,0,0,.85)}
+#header .details br{display:none}
+#header .details br+span::before{content:"\00a0\2013\00a0"}
+#header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
+#header .details br+span#revremark::before{content:"\00a0|\00a0"}
+#header #revnumber{text-transform:capitalize}
+#header #revnumber::after{content:"\00a0"}
+#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
+#toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
+#toc>ul{margin-left:.125em}
+#toc ul.sectlevel0>li>a{font-style:italic}
+#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
+#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
+#toc li{line-height:1.3334;margin-top:.3334em}
+#toc a{text-decoration:none}
+#toc a:active{text-decoration:underline}
+#toctitle{color:#7a2518;font-size:1.2em}
+@media screen and (min-width:768px){#toctitle{font-size:1.375em}
+body.toc2{padding-left:15em;padding-right:0}
+#toc.toc2{margin-top:0!important;background:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
+#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
+#toc.toc2>ul{font-size:.9em;margin-bottom:0}
+#toc.toc2 ul ul{margin-left:0;padding-left:1em}
+#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
+body.toc2.toc-right{padding-left:0;padding-right:15em}
+body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
+@media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
+#toc.toc2{width:20em}
+#toc.toc2 #toctitle{font-size:1.375em}
+#toc.toc2>ul{font-size:.95em}
+#toc.toc2 ul ul{padding-left:1.25em}
+body.toc2.toc-right{padding-left:0;padding-right:20em}}
+#content #toc{border:1px solid #e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;border-radius:4px}
+#content #toc>:first-child{margin-top:0}
+#content #toc>:last-child{margin-bottom:0}
+#footer{max-width:none;background:rgba(0,0,0,.8);padding:1.25em}
+#footer-text{color:hsla(0,0%,100%,.8);line-height:1.44}
+#content{margin-bottom:.625em}
+.sect1{padding-bottom:.625em}
+@media screen and (min-width:768px){#content{margin-bottom:1.25em}
+.sect1{padding-bottom:1.25em}}
+.sect1:last-child{padding-bottom:0}
+.sect1+.sect1{border-top:1px solid #e7e7e9}
+#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
+#content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
+#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
+#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
+#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
+details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
+details{margin-left:1.25rem}
+details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;-webkit-tap-highlight-color:transparent}
+details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
+details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
+details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
+.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
+table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
+.paragraph.lead>p,#preamble>.sectionbody>[class=paragraph]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
+.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
+.admonitionblock>table td.icon{text-align:center;width:80px}
+.admonitionblock>table td.icon img{max-width:none}
+.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
+.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6);word-wrap:anywhere}
+.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
+.exampleblock>.content{border:1px solid #e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;border-radius:4px}
+.exampleblock>.content>:first-child{margin-top:0}
+.exampleblock>.content>:last-child{margin-bottom:0}
+.sidebarblock{border:1px solid #dbdbd6;margin-bottom:1.25em;padding:1.25em;background:#f3f3f2;border-radius:4px}
+.sidebarblock>:first-child{margin-top:0}
+.sidebarblock>:last-child{margin-bottom:0}
+.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
+.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
+.literalblock pre,.listingblock>.content>pre{border-radius:4px;overflow-x:auto;padding:1em;font-size:.8125em}
+@media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
+@media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
+.literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class=highlight],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
+.literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
+.listingblock>.content{position:relative}
+.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
+.listingblock:hover code[data-lang]::before{display:block}
+.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
+.listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
+.listingblock pre.highlightjs{padding:0}
+.listingblock pre.highlightjs>code{padding:1em;border-radius:4px}
+.listingblock pre.prettyprint{border-width:0}
+.prettyprint{background:#f7f7f8}
+pre.prettyprint .linenums{line-height:1.45;margin-left:2em}
+pre.prettyprint li{background:none;list-style-type:inherit;padding-left:0}
+pre.prettyprint li code[data-lang]::before{opacity:1}
+pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
+table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
+table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
+table.linenotable td.code{padding-left:.75em}
+table.linenotable td.linenos{border-right:1px solid;opacity:.35;padding-right:.5em}
+pre.pygments .lineno{border-right:1px solid;opacity:.35;display:inline-block;margin-right:.75em}
+pre.pygments .lineno::before{content:"";margin-right:-.125em}
+.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
+.quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
+.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
+.quoteblock blockquote{margin:0;padding:0;border:0}
+.quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
+.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
+.quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
+.verseblock{margin:0 1em 1.25em}
+.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans-serif;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
+.verseblock pre strong{font-weight:400}
+.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
+.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
+.quoteblock .attribution br,.verseblock .attribution br{display:none}
+.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
+.quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
+.quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
+.quoteblock.abstract{margin:0 1em 1.25em;display:block}
+.quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
+.quoteblock.excerpt>blockquote,.quoteblock .quoteblock{padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
+.quoteblock.excerpt,.quoteblock .quoteblock{margin-left:0}
+.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
+.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:.85rem;text-align:left;margin-right:0}
+p.tableblock:last-child{margin-bottom:0}
+td.tableblock>.content{margin-bottom:1.25em;word-wrap:anywhere}
+td.tableblock>.content>:last-child{margin-bottom:-1.25em}
+table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
+table.grid-all>*>tr>*{border-width:1px}
+table.grid-cols>*>tr>*{border-width:0 1px}
+table.grid-rows>*>tr>*{border-width:1px 0}
+table.frame-all{border-width:1px}
+table.frame-ends{border-width:1px 0}
+table.frame-sides{border-width:0 1px}
+table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}
+table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
+table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
+table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
+table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd),table.stripes-even tr:nth-of-type(even),table.stripes-hover tr:hover{background:#f8f8f7}
+th.halign-left,td.halign-left{text-align:left}
+th.halign-right,td.halign-right{text-align:right}
+th.halign-center,td.halign-center{text-align:center}
+th.valign-top,td.valign-top{vertical-align:top}
+th.valign-bottom,td.valign-bottom{vertical-align:bottom}
+th.valign-middle,td.valign-middle{vertical-align:middle}
+table thead th,table tfoot th{font-weight:bold}
+tbody tr th{background:#f7f8f7}
+tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
+p.tableblock>code:only-child{background:none;padding:0}
+p.tableblock{font-size:1em}
+ol{margin-left:1.75em}
+ul li ol{margin-left:1.5em}
+dl dd{margin-left:1.125em}
+dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
+ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
+ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
+ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
+ul.unstyled,ol.unstyled{margin-left:0}
+ul.checklist>li>p:first-child{margin-left:-1em}
+ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
+ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
+ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
+ul.inline>li{margin-left:1.25em}
+.unstyled dl dt{font-weight:400;font-style:normal}
+ol.arabic{list-style-type:decimal}
+ol.decimal{list-style-type:decimal-leading-zero}
+ol.loweralpha{list-style-type:lower-alpha}
+ol.upperalpha{list-style-type:upper-alpha}
+ol.lowerroman{list-style-type:lower-roman}
+ol.upperroman{list-style-type:upper-roman}
+ol.lowergreek{list-style-type:lower-greek}
+.hdlist>table,.colist>table{border:0;background:none}
+.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
+td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
+td.hdlist1{font-weight:bold;padding-bottom:1.25em}
+td.hdlist2{word-wrap:anywhere}
+.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
+.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
+.colist td:not([class]):first-child img{max-width:none}
+.colist td:not([class]):last-child{padding:.25em 0}
+.thumb,.th{line-height:0;display:inline-block;border:4px solid #fff;box-shadow:0 0 0 1px #ddd}
+.imageblock.left{margin:.25em .625em 1.25em 0}
+.imageblock.right{margin:.25em 0 1.25em .625em}
+.imageblock>.title{margin-bottom:0}
+.imageblock.thumb,.imageblock.th{border-width:6px}
+.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
+.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
+.image.left{margin-right:.625em}
+.image.right{margin-left:.625em}
+a.image{text-decoration:none;display:inline-block}
+a.image object{pointer-events:none}
+sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
+sup.footnote a,sup.footnoteref a{text-decoration:none}
+sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
+#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
+#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
+#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
+#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
+#footnotes .footnote:last-of-type{margin-bottom:0}
+#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
+.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
+.gist .file-data>table td.line-data{width:99%}
+div.unbreakable{page-break-inside:avoid}
+.big{font-size:larger}
+.small{font-size:smaller}
+.underline{text-decoration:underline}
+.overline{text-decoration:overline}
+.line-through{text-decoration:line-through}
+.aqua{color:#00bfbf}
+.aqua-background{background:#00fafa}
+.black{color:#000}
+.black-background{background:#000}
+.blue{color:#0000bf}
+.blue-background{background:#0000fa}
+.fuchsia{color:#bf00bf}
+.fuchsia-background{background:#fa00fa}
+.gray{color:#606060}
+.gray-background{background:#7d7d7d}
+.green{color:#006000}
+.green-background{background:#007d00}
+.lime{color:#00bf00}
+.lime-background{background:#00fa00}
+.maroon{color:#600000}
+.maroon-background{background:#7d0000}
+.navy{color:#000060}
+.navy-background{background:#00007d}
+.olive{color:#606000}
+.olive-background{background:#7d7d00}
+.purple{color:#600060}
+.purple-background{background:#7d007d}
+.red{color:#bf0000}
+.red-background{background:#fa0000}
+.silver{color:#909090}
+.silver-background{background:#bcbcbc}
+.teal{color:#006060}
+.teal-background{background:#007d7d}
+.white{color:#bfbfbf}
+.white-background{background:#fafafa}
+.yellow{color:#bfbf00}
+.yellow-background{background:#fafa00}
+span.icon>.fa{cursor:default}
+a span.icon>.fa{cursor:inherit}
+.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
+.admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
+.admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
+.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
+.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
+.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
+.conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);border-radius:50%;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
+.conum[data-value] *{color:#fff!important}
+.conum[data-value]+b{display:none}
+.conum[data-value]::after{content:attr(data-value)}
+pre .conum[data-value]{position:relative;top:-.125em}
+b.conum *{color:inherit!important}
+.conum:not([data-value]):empty{display:none}
+dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
+h1,h2,p,td.content,span.alt,summary{letter-spacing:-.01em}
+p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
+p,blockquote,dt,td.content,span.alt,summary{font-size:1.0625rem}
+p{margin-bottom:1.25rem}
+.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
+.exampleblock>.content{background:#fffef7;border-color:#e0e0dc;box-shadow:0 1px 4px #e0e0dc}
+.print-only{display:none!important}
+@page{margin:1.25cm .75cm}
+@media print{*{box-shadow:none!important;text-shadow:none!important}
+html{font-size:80%}
+a{color:inherit!important;text-decoration:underline!important}
+a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
+a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
+abbr[title]{border-bottom:1px dotted}
+abbr[title]::after{content:" (" attr(title) ")"}
+pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
+thead{display:table-header-group}
+svg{max-width:100%}
+p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
+h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
+#header,#content,#footnotes,#footer{max-width:none}
+#toc,.sidebarblock,.exampleblock>.content{background:none!important}
+#toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
+body.book #header{text-align:center}
+body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
+body.book #header .details{border:0!important;display:block;padding:0!important}
+body.book #header .details span:first-child{margin-left:0!important}
+body.book #header .details br{display:block}
+body.book #header .details br+span::before{content:none!important}
+body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
+body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
+.listingblock code[data-lang]::before{display:block}
+#footer{padding:0 .9375em}
+.hide-on-print{display:none!important}
+.print-only{display:block!important}
+.hide-for-print{display:none!important}
+.show-for-print{display:inherit!important}}
+@media amzn-kf8,print{#header>h1:first-child{margin-top:1.25rem}
+.sect1{padding:0!important}
+.sect1+.sect1{border:0}
+#footer{background:none}
+#footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
+@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
+</style>
+<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
+<style>
+pre { line-height: 125%; }
+td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+pre.pygments .hll { background-color: #49483e }
+pre.pygments { background: #272822; color: #f8f8f2 }
+pre.pygments .tok-c { color: #75715e } /* Comment */
+pre.pygments .tok-err { color: #960050; background-color: #1e0010 } /* Error */
+pre.pygments .tok-k { color: #66d9ef } /* Keyword */
+pre.pygments .tok-l { color: #ae81ff } /* Literal */
+pre.pygments .tok-n { color: #f8f8f2 } /* Name */
+pre.pygments .tok-o { color: #f92672 } /* Operator */
+pre.pygments .tok-p { color: #f8f8f2 } /* Punctuation */
+pre.pygments .tok-ch { color: #75715e } /* Comment.Hashbang */
+pre.pygments .tok-cm { color: #75715e } /* Comment.Multiline */
+pre.pygments .tok-cp { color: #75715e } /* Comment.Preproc */
+pre.pygments .tok-cpf { color: #75715e } /* Comment.PreprocFile */
+pre.pygments .tok-c1 { color: #75715e } /* Comment.Single */
+pre.pygments .tok-cs { color: #75715e } /* Comment.Special */
+pre.pygments .tok-gd { color: #f92672 } /* Generic.Deleted */
+pre.pygments .tok-ge { font-style: italic } /* Generic.Emph */
+pre.pygments .tok-gi { color: #a6e22e } /* Generic.Inserted */
+pre.pygments .tok-go { color: #66d9ef } /* Generic.Output */
+pre.pygments .tok-gp { color: #f92672; font-weight: bold } /* Generic.Prompt */
+pre.pygments .tok-gs { font-weight: bold } /* Generic.Strong */
+pre.pygments .tok-gu { color: #75715e } /* Generic.Subheading */
+pre.pygments .tok-kc { color: #66d9ef } /* Keyword.Constant */
+pre.pygments .tok-kd { color: #66d9ef } /* Keyword.Declaration */
+pre.pygments .tok-kn { color: #f92672 } /* Keyword.Namespace */
+pre.pygments .tok-kp { color: #66d9ef } /* Keyword.Pseudo */
+pre.pygments .tok-kr { color: #66d9ef } /* Keyword.Reserved */
+pre.pygments .tok-kt { color: #66d9ef } /* Keyword.Type */
+pre.pygments .tok-ld { color: #e6db74 } /* Literal.Date */
+pre.pygments .tok-m { color: #ae81ff } /* Literal.Number */
+pre.pygments .tok-s { color: #e6db74 } /* Literal.String */
+pre.pygments .tok-na { color: #a6e22e } /* Name.Attribute */
+pre.pygments .tok-nb { color: #f8f8f2 } /* Name.Builtin */
+pre.pygments .tok-nc { color: #a6e22e } /* Name.Class */
+pre.pygments .tok-no { color: #66d9ef } /* Name.Constant */
+pre.pygments .tok-nd { color: #a6e22e } /* Name.Decorator */
+pre.pygments .tok-ni { color: #f8f8f2 } /* Name.Entity */
+pre.pygments .tok-ne { color: #a6e22e } /* Name.Exception */
+pre.pygments .tok-nf { color: #a6e22e } /* Name.Function */
+pre.pygments .tok-nl { color: #f8f8f2 } /* Name.Label */
+pre.pygments .tok-nn { color: #f8f8f2 } /* Name.Namespace */
+pre.pygments .tok-nx { color: #a6e22e } /* Name.Other */
+pre.pygments .tok-py { color: #f8f8f2 } /* Name.Property */
+pre.pygments .tok-nt { color: #f92672 } /* Name.Tag */
+pre.pygments .tok-nv { color: #f8f8f2 } /* Name.Variable */
+pre.pygments .tok-ow { color: #f92672 } /* Operator.Word */
+pre.pygments .tok-w { color: #f8f8f2 } /* Text.Whitespace */
+pre.pygments .tok-mb { color: #ae81ff } /* Literal.Number.Bin */
+pre.pygments .tok-mf { color: #ae81ff } /* Literal.Number.Float */
+pre.pygments .tok-mh { color: #ae81ff } /* Literal.Number.Hex */
+pre.pygments .tok-mi { color: #ae81ff } /* Literal.Number.Integer */
+pre.pygments .tok-mo { color: #ae81ff } /* Literal.Number.Oct */
+pre.pygments .tok-sa { color: #e6db74 } /* Literal.String.Affix */
+pre.pygments .tok-sb { color: #e6db74 } /* Literal.String.Backtick */
+pre.pygments .tok-sc { color: #e6db74 } /* Literal.String.Char */
+pre.pygments .tok-dl { color: #e6db74 } /* Literal.String.Delimiter */
+pre.pygments .tok-sd { color: #e6db74 } /* Literal.String.Doc */
+pre.pygments .tok-s2 { color: #e6db74 } /* Literal.String.Double */
+pre.pygments .tok-se { color: #ae81ff } /* Literal.String.Escape */
+pre.pygments .tok-sh { color: #e6db74 } /* Literal.String.Heredoc */
+pre.pygments .tok-si { color: #e6db74 } /* Literal.String.Interpol */
+pre.pygments .tok-sx { color: #e6db74 } /* Literal.String.Other */
+pre.pygments .tok-sr { color: #e6db74 } /* Literal.String.Regex */
+pre.pygments .tok-s1 { color: #e6db74 } /* Literal.String.Single */
+pre.pygments .tok-ss { color: #e6db74 } /* Literal.String.Symbol */
+pre.pygments .tok-bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
+pre.pygments .tok-fm { color: #a6e22e } /* Name.Function.Magic */
+pre.pygments .tok-vc { color: #f8f8f2 } /* Name.Variable.Class */
+pre.pygments .tok-vg { color: #f8f8f2 } /* Name.Variable.Global */
+pre.pygments .tok-vi { color: #f8f8f2 } /* Name.Variable.Instance */
+pre.pygments .tok-vm { color: #f8f8f2 } /* Name.Variable.Magic */
+pre.pygments .tok-il { color: #ae81ff } /* Literal.Number.Integer.Long */
+</style>
+<head>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=DotGothic16">
+<link rel="icon" type="image/png" href="N2DE_favicon.png"/>
+
+<style>
+
+/*--------------------------------------------------------------*/
+/*use '!important' to override default css used by asciidoctor*/
+/*--------------------------------------------------------------*/
+
+:root {
+    --gruvbox-black: #282828;
+    --gruvbox-black2: #1d2021;
+    --gruvbox-black3: #463f39;
+    --gruvbox-red: #fb4934;
+    --gruvbox-yellow: #fabd2f;
+    --gruvbox-white: #ebdbb2;
+    --gruvbox-white2: #fbf1c7;
+    --gruvbox-blue: #83a598;
+    --gruvbox-green: #b8bb26;
+    --gruvbox-bg1: #7c6f64;
+    --gruvbox-bg2: #665c54;
+
+}
+
+.title {
+  color: var(--gruvbox-red) !important;
+}
+
+blockquote {
+    color: var(--gruvbox-white) !important;
+}
+
+.hdlist1 {
+  font-size: 1.3em;
+}
+
+cite {
+    color: var(--gruvbox-green) !important;
+}
+
+.tableblock {
+    background-color: inherit;
+    color: var(--gruvbox-white);
+    max-width: 95%;
+}
+
+.tableblock th {
+    background-color: var(--gruvbox-black3);
+    color: var(--gruvbox-white);
+    max-width: 97%;
+}
+
+code:not([data-lang]) {
+    background-color: var(--gruvbox-bg2) !important;
+    color: var(--gruvbox-white);
+    text-shadow: none;
+}
+
+.checklist {
+    text-align: left;
+    font-size: .8em;
+}
+
+.checklist li ul { margin-left: 3%;
+}
+
+#content, h1, pre {
+    border-radius: 8px !important;
+}
+
+#header, #content, #footnotes, #footer {
+  padding-left: 0 !important;
+  padding-right: 0 !important;
+}
+
+.api-type a:hover {
+    text-decoration: underline;
+}
+
+.api-type, .api-type a {
+    color: var(--gruvbox-green);
+    text-decoration: none;
+}
+
+pre {
+    border-style: solid !important;
+    border-color: white !important;
+    border-width: 2px !important;
+}
+
+h1 {
+    font-family: "DotGothic16", sans-serif !important;
+    background-color: var(--gruvbox-bg2) !important;
+    color: var(--gruvbox-white) !important;
+    opacity: .6;
+}
+
+.admonitionblock > table td.content {
+    color: var(--gruvbox-white) !important;
+}
+
+/*
+html {
+    margin: 0;
+    height: 100%;
+    width: 100%;
+}
+
+*/
+/*html {*/
+body {
+    /*background: black url("background-image-space.jpeg") no-repeat fixed center;*/
+    /*background-color: black;*/
+    background-color: var(--gruvbox-black);
+    background-attachment: fixed;
+    background-size: cover;
+    overflow-y: scroll;
+    /*
+    margin: 0;
+    height: 100%;
+    width: 100%;
+    overflow: hidden;
+    */
+}
+
+
+/*
+body {
+    overflow-y: scroll;
+    background: rgba(0,0,0,0);
+    height: 100%;
+    margin: 2%;
+}
+*/
+
+#toc {
+    background-color: var(--gruvbox-black2) !important;
+    /*opacity: .9;*/
+}
+
+#toctitle {
+    color: var(--gruvbox-red);
+}
+
+a {
+    color: var(--gruvbox-blue);
+}
+
+#content {
+    color: #ebdbb2;
+    background: var(--gruvbox-black);
+    /*opacity: .9;*/
+}
+
+#header > h1:nth-last-child(2) {
+    border-bottom: none !important;
+    background-color: rgba(0, 0, 0, .1);
+    padding-left: 2%;
+}
+
+.sect1 + .sect1 {
+  border-top: none !important;
+}
+
+.sect1 h2 {
+    background-size: cover;
+    background-attachment: fixed;
+    border-bottom: 1px solid var(--gruvbox-white);
+    border-top: 1px solid var(--gruvbox-white);
+    text-align: center;
+    color: var(--gruvbox-white) !important;
+    /*
+    text-shadow: 1px 1px 1px var(--gruvbox-black);
+    text-shadow: 3px 3px 3px var(--gruvbox-black);
+    text-shadow: 5px 5px 5px var(--gruvbox-blue);
+    */
+}
+
+h3, h4, h5 {
+    /*
+    text-shadow: 1px 1px 1px var(--gruvbox-white);
+    */
+}
+
+h3 {
+  color: var(--gruvbox-red) !important;
+}
+
+h4 {
+  color: var(--gruvbox-yellow) !important;
+}
+
+h5 {
+  color: #83a598 !important;
+}
+
+h2 ~ *:not(h1) {
+  margin-left: .5em;
+}
+
+.pygments {
+    max-width: 97% !important;
+    white-space: pre;
+    overflow-x: scroll !important;
+}
+
+::before {
+    /*makes sure that the programming language that show up on hover is within
+      pre tag*/
+    padding-right: 3%;
+}
+
+@media screen and (max-width: 800px) {
+    .checklist li ul {
+        margin-left: 6% !important;
+    }
+    #toc {
+        padding-left: 10px;
+    }
+
+    footer {
+        margin-bottom: 10px !important;
+    }
+    html {
+        margin-bottom: 10px !important;
+    }
+}
+@media screen and (max-width: 535px) {
+    h3 ~ *:not(h2):not(h3) {
+      margin-left: 0 !important;
+    }
+
+    h4 ~ *:not(h2):not(h3):not(.h3):not(h4) {
+      margin-left: 0 !important;
+    }
+    h5 ~ *:not(h2):not(h3):not(.h3):not(h4):not(.h4):not(h5) {
+      margin-left: 0 !important;
+    }
+
+    footer {
+        margin-bottom: 10px !important;
+    }
+    html {
+        margin-bottom: 10px !important;
+    }
+}
+h3 ~ *:not(h2):not(h3) {
+  margin-left: 1.5em;
+}
+
+h4 ~ *:not(h2):not(h3):not(.h3):not(h4) {
+  margin-left: 2em;
+}
+h5 ~ *:not(h2):not(h3):not(.h3):not(h4):not(.h4):not(h5) {
+  margin-left: 2.5em;
+}
+
+
+.sect1 h2 {
+    background: linear-gradient(
+        to bottom,
+        rgba(251, 189, 47, 0.2), /* yellow */
+        rgba(0, 0, 0, 0.4)       /* black */
+    );
+    /*opacity: .9;*/
+  }
+
+#preamble p{
+  padding-left: 10px;
+  color: var(--gruvbox-white) !important;
+}
+
+#footer {
+    max-width: 62.5em !important;
+    padding-left: 10px !important;
+    text-align: center;
+}
+
+.logo img {
+    display: block !important;
+    margin-left: auto !important;
+    margin-right: auto !important;
+}
+
+#header > h1:first-child {
+  margin-top: .3em !important;
+  padding-top: .2em !important;
+  padding-bottom: .3em !important;
+}
+
+footer {
+    max-width: 62.5em;
+    margin-left: auto;
+    margin-right: auto;
+    display: block;
+
+}
+
+details[open] > summary::before {
+   /* display: none;*/
+    border-top: none;
+    content: "▼";
+    margin-top: -12px;
+}
+
+</style>
+
+</head>
+
+<script src="docinfo.js"></script>
+
+
+</head>
+<body class="article toc2 toc-left">
+<div id="header">
+<h1>C Disassembling</h1>
+<div id="toc" class="toc2">
+<div id="toctitle">Table of Contents</div>
+<ul class="sectlevel1">
+<li><a href="#_floating_points">Floating Points</a></li>
+</ul>
+</div>
+</div>
+<div id="content">
+<div class="sect1">
+<h2 id="_floating_points">Floating Points</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="title">assign_float.c</div>
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c"><span></span><span class="tok-cp">#include</span><span class="tok-w"> </span><span class="tok-cpf">&lt;stdio.h&gt;</span><span class="tok-cp"></span>
+<span class="tok-cp">#include</span><span class="tok-w"> </span><span class="tok-cpf">&lt;stdlib.h&gt;</span><span class="tok-cp"></span>
+
+<span class="tok-kt">int</span><span class="tok-w"></span>
+<span class="tok-nf">main</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-p">){</span><span class="tok-w"></span>
+<span class="tok-w">    </span><span class="tok-kt">float</span><span class="tok-w"> </span><span class="tok-n">a</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mf">10.0f</span><span class="tok-p">;</span><span class="tok-w"></span>
+<span class="tok-w">    </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-mi">1</span><span class="tok-p">;</span><span class="tok-w"></span>
+<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="title">gdb disassemble</div>
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) disass</code></pre>
+</div>
+</div>
+<details>
+<summary class="title">output</summary>
+<div class="content">
+<div class="literalblock">
+<div class="content">
+<pre>   0x0000555555555129 &lt;+0&gt;:     endbr64
+   0x000055555555512d &lt;+4&gt;:     push   rbp
+   0x000055555555512e &lt;+5&gt;:     mov    rbp,rsp
+   0x0000555555555131 &lt;+8&gt;:     movss  xmm0,DWORD PTR [rip+0xecb]        # 0x5555555560
+04
+   0x0000555555555139 &lt;+16&gt;:    movss  DWORD PTR [rbp-0x4],xmm0
+=&gt; 0x000055555555513e &lt;+21&gt;:    mov    eax,0x1
+   0x0000555555555143 &lt;+26&gt;:    pop    rbp
+   0x0000555555555144 &lt;+27&gt;:    ret</pre>
+</div>
+</div>
+</div>
+</details>
+<div class="paragraph">
+<p><code>push rbp</code>,<code>mov rbp, rsp</code> is the function prologue for the stack frame.
+<code>pop rbp</code> is the function epilogue for the stack frame. In <code>mov eax, 0x1</code> eax is
+the return value for the function which we are setting to one. <code>xmm0</code> is the
+floating point register that has the value of <code>a</code> in single percision mode.</p>
+</div>
+<div class="listingblock">
+<div class="title">gdb print xmm0 register</div>
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) p $xmm0</code></pre>
+</div>
+</div>
+<details>
+<summary class="title">output</summary>
+<div class="content">
+<div class="literalblock">
+<div class="content">
+<pre>$2 = {
+  v8_bfloat16 = {0, 10, 0, 0, 0, 0, 0, 0},
+  v8_half = {0, 2.5625, 0, 0, 0, 0, 0, 0},
+  v4_float = {10, 0, 0, 0},
+  v2_double = {5.3982412455708344e-315, 0},
+  v16_int8 = {0, 0, 32, 65, 0 &lt;repeats 12 times&gt;},
+  v8_int16 = {0, 16672, 0, 0, 0, 0, 0, 0},
+  v4_int32 = {1092616192, 0, 0, 0},
+  v2_int64 = {1092616192, 0},
+  uint128 = 1092616192
+}</pre>
+</div>
+</div>
+</div>
+</details>
+<div class="paragraph">
+<p>We can see <code>uint128</code> is 1092616192, which is the how the binary actually looks
+in single point percision. We can also see that <code>v4_float</code> stores the value of
+the number as we understand it.</p>
+</div>
+</div>
+</div>
+</div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2024-03-26 18:37:45 -0400
+</div>
+</div>
+<script type="text/x-mathjax-config">
+MathJax.Hub.Config({
+  messageStyle: "none",
+  tex2jax: {
+    inlineMath: [["\\(", "\\)"]],
+    displayMath: [["\\[", "\\]"]],
+    ignoreClass: "nostem|nolatexmath"
+  },
+  asciimath2jax: {
+    delimiters: [["\\$", "\\$"]],
+    ignoreClass: "nostem|noasciimath"
+  },
+  TeX: { equationNumbers: { autoNumber: "none" } }
+})
+MathJax.Hub.Register.StartupHook("AsciiMath Jax Ready", function () {
+  MathJax.InputJax.AsciiMath.postfilterHooks.Add(function (data, node) {
+    if ((node = data.script.parentNode) && (node = node.parentNode) && node.classList.contains("stemblock")) {
+      data.math.root.display = "block"
+    }
+    return data
+  })
+})
+</script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/docs/diag-ditaa-md5-748c8d76a4b154138a91a12caf43c78a.png b/docs/diag-ditaa-md5-748c8d76a4b154138a91a12caf43c78a.png
new file mode 100644 (file)
index 0000000..c289e70
Binary files /dev/null and b/docs/diag-ditaa-md5-748c8d76a4b154138a91a12caf43c78a.png differ
diff --git a/docs/docinfo.html b/docs/docinfo.html
new file mode 100644 (file)
index 0000000..217edb0
--- /dev/null
@@ -0,0 +1,313 @@
+<head>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=DotGothic16">
+<link rel="icon" type="image/png" href="N2DE_favicon.png"/>
+
+<style>
+
+/*--------------------------------------------------------------*/
+/*use '!important' to override default css used by asciidoctor*/
+/*--------------------------------------------------------------*/
+
+:root {
+    --gruvbox-black: #282828;
+    --gruvbox-black2: #1d2021;
+    --gruvbox-black3: #463f39;
+    --gruvbox-red: #fb4934;
+    --gruvbox-yellow: #fabd2f;
+    --gruvbox-white: #ebdbb2;
+    --gruvbox-white2: #fbf1c7;
+    --gruvbox-blue: #83a598;
+    --gruvbox-green: #b8bb26;
+    --gruvbox-bg1: #7c6f64;
+    --gruvbox-bg2: #665c54;
+
+}
+
+.title {
+  color: var(--gruvbox-red) !important;
+}
+
+blockquote {
+    color: var(--gruvbox-white) !important;
+}
+
+.hdlist1 {
+  font-size: 1.3em;
+}
+
+cite {
+    color: var(--gruvbox-green) !important;
+}
+
+.tableblock {
+    background-color: inherit;
+    color: var(--gruvbox-white);
+    max-width: 95%;
+}
+
+.tableblock th {
+    background-color: var(--gruvbox-black3);
+    color: var(--gruvbox-white);
+    max-width: 97%;
+}
+
+code:not([data-lang]) {
+    background-color: var(--gruvbox-bg2) !important;
+    color: var(--gruvbox-white);
+    text-shadow: none;
+}
+
+.checklist {
+    text-align: left;
+    font-size: .8em;
+}
+
+.checklist li ul { margin-left: 3%;
+}
+
+#content, h1, pre {
+    border-radius: 8px !important;
+}
+
+#header, #content, #footnotes, #footer {
+  padding-left: 0 !important;
+  padding-right: 0 !important;
+}
+
+.api-type a:hover {
+    text-decoration: underline;
+}
+
+.api-type, .api-type a {
+    color: var(--gruvbox-green);
+    text-decoration: none;
+}
+
+pre {
+    border-style: solid !important;
+    border-color: white !important;
+    border-width: 2px !important;
+}
+
+h1 {
+    font-family: "DotGothic16", sans-serif !important;
+    background-color: var(--gruvbox-bg2) !important;
+    color: var(--gruvbox-white) !important;
+    opacity: .6;
+}
+
+.admonitionblock > table td.content {
+    color: var(--gruvbox-white) !important;
+}
+
+/*
+html {
+    margin: 0;
+    height: 100%;
+    width: 100%;
+}
+
+*/
+/*html {*/
+body {
+    /*background: black url("background-image-space.jpeg") no-repeat fixed center;*/
+    /*background-color: black;*/
+    background-color: var(--gruvbox-black);
+    background-attachment: fixed;
+    background-size: cover;
+    overflow-y: scroll;
+    /*
+    margin: 0;
+    height: 100%;
+    width: 100%;
+    overflow: hidden;
+    */
+}
+
+
+/*
+body {
+    overflow-y: scroll;
+    background: rgba(0,0,0,0);
+    height: 100%;
+    margin: 2%;
+}
+*/
+
+#toc {
+    background-color: var(--gruvbox-black2) !important;
+    /*opacity: .9;*/
+}
+
+#toctitle {
+    color: var(--gruvbox-red);
+}
+
+a {
+    color: var(--gruvbox-blue);
+}
+
+#content {
+    color: #ebdbb2;
+    background: var(--gruvbox-black);
+    /*opacity: .9;*/
+}
+
+#header > h1:nth-last-child(2) {
+    border-bottom: none !important;
+    background-color: rgba(0, 0, 0, .1);
+    padding-left: 2%;
+}
+
+.sect1 + .sect1 {
+  border-top: none !important;
+}
+
+.sect1 h2 {
+    background-size: cover;
+    background-attachment: fixed;
+    border-bottom: 1px solid var(--gruvbox-white);
+    border-top: 1px solid var(--gruvbox-white);
+    text-align: center;
+    color: var(--gruvbox-white) !important;
+    /*
+    text-shadow: 1px 1px 1px var(--gruvbox-black);
+    text-shadow: 3px 3px 3px var(--gruvbox-black);
+    text-shadow: 5px 5px 5px var(--gruvbox-blue);
+    */
+}
+
+h3, h4, h5 {
+    /*
+    text-shadow: 1px 1px 1px var(--gruvbox-white);
+    */
+}
+
+h3 {
+  color: var(--gruvbox-red) !important;
+}
+
+h4 {
+  color: var(--gruvbox-yellow) !important;
+}
+
+h5 {
+  color: #83a598 !important;
+}
+
+h2 ~ *:not(h1) {
+  margin-left: .5em;
+}
+
+.pygments {
+    max-width: 97% !important;
+    white-space: pre;
+    overflow-x: scroll !important;
+}
+
+::before {
+    /*makes sure that the programming language that show up on hover is within
+      pre tag*/
+    padding-right: 3%;
+}
+
+@media screen and (max-width: 800px) {
+    .checklist li ul {
+        margin-left: 6% !important;
+    }
+    #toc {
+        padding-left: 10px;
+    }
+
+    footer {
+        margin-bottom: 10px !important;
+    }
+    html {
+        margin-bottom: 10px !important;
+    }
+}
+@media screen and (max-width: 535px) {
+    h3 ~ *:not(h2):not(h3) {
+      margin-left: 0 !important;
+    }
+
+    h4 ~ *:not(h2):not(h3):not(.h3):not(h4) {
+      margin-left: 0 !important;
+    }
+    h5 ~ *:not(h2):not(h3):not(.h3):not(h4):not(.h4):not(h5) {
+      margin-left: 0 !important;
+    }
+
+    footer {
+        margin-bottom: 10px !important;
+    }
+    html {
+        margin-bottom: 10px !important;
+    }
+}
+h3 ~ *:not(h2):not(h3) {
+  margin-left: 1.5em;
+}
+
+h4 ~ *:not(h2):not(h3):not(.h3):not(h4) {
+  margin-left: 2em;
+}
+h5 ~ *:not(h2):not(h3):not(.h3):not(h4):not(.h4):not(h5) {
+  margin-left: 2.5em;
+}
+
+
+.sect1 h2 {
+    background: linear-gradient(
+        to bottom,
+        rgba(251, 189, 47, 0.2), /* yellow */
+        rgba(0, 0, 0, 0.4)       /* black */
+    );
+    /*opacity: .9;*/
+  }
+
+#preamble p{
+  padding-left: 10px;
+  color: var(--gruvbox-white) !important;
+}
+
+#footer {
+    max-width: 62.5em !important;
+    padding-left: 10px !important;
+    text-align: center;
+}
+
+.logo img {
+    display: block !important;
+    margin-left: auto !important;
+    margin-right: auto !important;
+}
+
+#header > h1:first-child {
+  margin-top: .3em !important;
+  padding-top: .2em !important;
+  padding-bottom: .3em !important;
+}
+
+footer {
+    max-width: 62.5em;
+    margin-left: auto;
+    margin-right: auto;
+    display: block;
+
+}
+
+details[open] > summary::before {
+   /* display: none;*/
+    border-top: none;
+    content: "▼";
+    margin-top: -12px;
+}
+
+</style>
+
+</head>
+
+<script src="docinfo.js"></script>
+
+
diff --git a/docs/docinfo.js b/docs/docinfo.js
new file mode 100644 (file)
index 0000000..eb3839e
--- /dev/null
@@ -0,0 +1,97 @@
+const link_variable = "https://www.lua.org/manual/5.3/manual.html#2.1";
+const link_table = "https://www.lua.org/manual/5.3/manual.html#3.4.9";
+
+function setTypeHtml(type, link) {
+    type.innerHTML = `<a href=\"${link}\">&#60;${type.outerText}&#62;</a>`
+}
+
+function zebraChecklist(element) {
+    let f = 0;
+    for (let i = 0; i < element.length; ++i) {
+        children = element[i].children;
+        if (children) {
+            for (let i = 0; i < children.length; ++i) {
+                if (f % 2 == 0) {
+                    children[i].querySelector("p").style.backgroundColor = "black";
+                }
+                let innerChild = children[i].querySelector("ul.checklist");
+                if (innerChild) {
+                    zebraChecklist(innerChild);
+                }
+                f++;
+            }
+        }
+        f++;
+    }
+}
+
+function hideTocChildren() {
+    const tocList = document.querySelector(".sectlevel1");
+
+    for (let i =0; i < tocList.children.length; ++i) {
+        let child = tocList.children[i];
+        let lis = child.querySelectorAll("li");
+        for (let j = 0; j < lis.length; ++j) {
+            lis[j].style.display = "none";
+        }
+    }
+}
+
+window.onload = function() {
+    const class_api_type = document.querySelectorAll(".api-type");
+    const class_checklist = document.querySelectorAll("ul.checklist");
+    const class_download = document.querySelectorAll(".download");
+    const id_footer = document.querySelector("#footer");
+    const tocList = document.querySelector(".sectlevel1");
+    // document.querySelector(".sectlevel1").children[1].querySelectorAll("li")[0] 
+
+    class_api_type.forEach(type => {
+        switch(type.outerText) {
+            case "number" : {
+                setTypeHtml(type, link_variable);
+                break;
+            }
+            case "string" : {
+                setTypeHtml(type, link_variable);
+                break;
+            }
+            case "table" : {
+                setTypeHtml(type, link_table);
+                break;
+            }
+        }
+    });
+
+    class_download.forEach(span => {
+        let atag = span.querySelector("a");
+        let href = atag.getAttribute("href");
+        let regex_FileAtEndOfPath = /\/[\w-_]*.\w*$/;
+        let fileName = href.match(regex_FileAtEndOfPath)[0].slice(1);
+        atag.setAttribute("download", fileName);
+        atag.innerHTML = fileName;
+    })
+
+    zebraChecklist(class_checklist);
+    let footer = document.createElement("footer");
+    footer.style.color = "black";
+    footer.style.textAlign = "center";
+    footer.style.backgroundColor = "white";
+    footer.style.opacity = ".5"
+    footer.innerHTML = "<p>powered by <a href='https://asciidoctor.org/'>asciidoctor</a></p>";
+    document.body.appendChild(footer);
+
+    for (let i =0; i < tocList.children.length; ++i) {
+        let child = tocList.children[i];
+        let lis = child.querySelectorAll("li");
+        for (let j = 0; j < lis.length; ++j) {
+            lis[j].style.display = "none";
+        }
+
+        child.addEventListener("click", event => {
+            hideTocChildren();
+            for (let j = 0; j < lis.length; ++j) {
+                lis[j].style.display = "block";
+            }
+        })
+    }
+}
diff --git a/docs/index.adoc b/docs/index.adoc
new file mode 100644 (file)
index 0000000..281d451
--- /dev/null
@@ -0,0 +1,1348 @@
+= Low Level Learning
+:docinfo: shared
+:source-highlighter: pygments
+:pygments-style: monokai
+:icons: font
+:stem:
+:toc: left
+
+== Related Links
+- https://html-preview.github.io/?url=https://github.com/A-Larsen/beginning_low_level_learning/blob/main/docs/c-disassembling.html[c-disassemebling]
+- https://html-preview.github.io/?url=https://github.com/A-Larsen/beginning_low_level_learning/blob/main/docs/Q-and-A.html[Q and A]
+
+== Looking at the OpCode tables
+
+Ex.
+
+
+.SAL/SHL
+[%header cols="1,1,1,1,1,4"]
+|===
+| Opcode   | Instruction      | Op/En | 64-bit Mode | Compat/Leg Mode | Description
+
+| D0/4     | SAL r/m8, 1      | M1    | Valid       | valid           | Multiply r/m8 by 2, once
+
+| C1 /4 ib | SHL r/m16,imm8   | M1    | Valid       | valid           | Multiply r/m32 by 2, once
+|===
+
+
+This is an example of an instruction table that you might see, In this case I
+took this from the
+https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html[Intel 64 and IA-32 Architectures software Developer's Manual].
+
+=== Instructions
+r::
+    "r" stands for a general purpose register, "r/m8" mean a 8 bit register,
+    "r/m16" means a 16 bit register.
+
+m::
+    A 16-, 32- or 64-bit operand in memory
+
+imm::
+    stands for immediate value (e.g., integer constant like 42 or 1335).
+
+rel8::
+    A relative address in the range from 128 bytes before the end of the
+    instruction to 127 bytes after the end of the instruction.
+
+rel16, rel32::
+    A relative address within the same code segment as the instruction
+    assembled. The rel16 symbol applies to instructions with an operand-size
+    attribute of 16 bits; the rel32 symbol applies to instructions with an
+    operand-size attribute of 32 bits
+
+=== Opcodes
+REX.W::
+    Indicates the use of a REX prefix that affects operand size or instruction
+    semantics. The ordering of the REX prefix and other optional/mandatory
+    instruction perfixes are discussed in Chapter 2. Note that REX prefixes
+    promote legacy instructions to 64-bit behavor are not listed explicitly in
+    the opcode column
+
+/Digit::
+    A digit between 0 and 7 indicates that the ModR/M byte of the instruction
+    uses only the r/m (register or memory) operand. The reg field contains the
+    digit that provides an extension to the instruction's opcode.
+
+/r::
+    Indicates that the ModR/M byte of the instruction contains a register
+    operand and an r/m operand.
+
+cb, cw, cd, cp, co, ct::
+     A 1-byte (cb), 2-byte (cw), 4-byte (cd), 6-byte (cp), 8-byte (co) or
+     10-byte (ct) value following the opcode. This value is used to specify a
+     code offset and possibly a new value for the code segment register.
+
+ib, iw, id, io:: 
+    A 1-byte (ib), 2-byte (iw), 4-byte (id) or 8-byte (io) immediate operand to
+    the instruction that follows the opcode, ModR/M bytes or scale-indexing
+    bytes. The opcode determines if the operand is a signed value. All words,
+    doublewords and quadwords are given with the low-order byte first.
+
++rb, +rw, +rd, +ro::
+    Indicates the lower 3 bits of the opcode byte is used to encode the register
+    operand without a modR/M byte. The instruction lists the corresponding
+    hexadecimal value of the opcode byte with low 3 bits as 000b. In non-64-bit
+    mode, a register code, from 0 through 7, is added to the hexadecimal value
+    of the opcode byte. In 64-bit mode, indicates the four bit field of REX.b
+    and opcode[2:0] field encodes the register operand of the instruction. “+ro”
+    is applicable only in 64-bit mode. See Table 3-1 for the codes.
+
++i::
+    A number used in floating-point instructions when one of the operands is
+    ST(i) from the FPU register stack. The number i (which can range from 0 to
+    7) is added to the hexadecimal byte given at the left of the plus sign to
+    form a single opcode byte.
+
+
+NOTE: Look at Intel 64 and IA-32 Architectures Software Developer's Manual page
+      2839
+
+
+== Data types
+.datatypes
+[%header]
+|===
+| Type | Length  | Name
+| db   | 8 bits  | Byte
+| dw   | 16 bits | Word
+| dd   | 32 bits | Double Word
+| dq   | 64 bits | Quadword
+|===
+
+== Registers
+
+=== R_X vs E_X vs _X vs _H vs _L
+R_X:: all 64 bits
+E_X:: lower 32 bits
+_X:: lower 16 bits
+_H:: top 4 bits of last byte
+_L:: bottom 4 bits of last byte
+
+=== General Purpose Registers
+
+[%header]
+|===
+| 64-bit | 32-bit | 16-bit | low 8-bit | high 8-bit | comment
+| rax    | eax    | ax     | al        | ah         |
+| rbx    | ebx    | bx     | bl        | bh         |
+| rcx    | ecx    | cx     | cl        | ch         |
+| rdx    | edx    | dx     | dl        | dh         |
+| rsi    | esi    | si     | sil       |            |
+| rdi    | edi    | di     | dil       |            |
+| rbp    | ebp    | bp     | bpl       |            | Base Pointer
+| rsp    | esp    | sp     | spl       |            | Stack Pointer
+| r8     | r8d    | r8w    | r8b       |            |
+| r9     | r9d    | r9w    | r9b       |            |
+| r10    | r10d   | r10w   | r10b      |            |
+| r11    | r11d   | r11w   | r11b      |            |
+| r12    | r12d   | r12w   | r12b      |            |
+| r13    | r13d   | r13w   | r13b      |            |
+| r14    | r14d   | r14w   | r14b      |            |
+| r15    | r15d   | r15w   | r15b      |            |
+|===
+
+=== Flag Registers
+|===
+| Name     | Symbol | Bit | Content
+
+| Carry    | CF     | 0   | Previous instruction had a carry
+
+| parity   | PF     | 2   | Last byte has even number of 1s
+
+| Adjust   | AF     | 4   | BCD operations
+
+| Zero     | ZF     | 6   | Pervious instruction resulted in zero
+
+| Sign     | SF     | 8   | Previous instruction resulted in most significant
+                            bit equal to 1
+
+| Overflow | OF     | 11  | Previous instruction resulted in overflow
+|===
+
+=== Instruction Pointer Register (rip)
+The processor keeps trakc of the next instruction to be executed by storing the
+address of the next instruction in rip.
+
+=== xmm and ymm Registers
+These registers are used for floating-point calculations and SIMD.
+
+== Main
+One file in your assembly program needs "main" defined. This seems to be defined
+in the `.text` section.
+
+[source, nasm]
+----
+section .text
+global main
+main:
+----
+
+== Labels
+- Labels look like this `<description>:`
+- Local lablels Look like this `.<description>:`
+
+If there is a local label within a global label then the full label name
+could loop like this `main.loop`. Like in this example:
+
+[source, nasm]
+----
+section .text
+global main
+main:
+    .loop
+    ; do somethings
+    jnz .loop
+
+----
+
+== Jumping / looping
+
+`cmp` sets the approriate flags. `jl` jumps if rax < 42. `jmp` jumps straight to
+the `ex` label.
+
+[source, nasm]
+----
+    cmp rax, 42
+    jl yes
+    mov rbx, 0
+    jmp ex
+yes:
+    mov rbx, 1
+ex:
+----
+
+`ja`:: (jump if above)/ `jb` (jump if below) for a jump after a comparison
+   of _unsigned numbers with cmp_.
+
+`jg`:: (Jump if greater) / `jl` (jump if less) for _signed_.
+
+`jae`:: (jump if above or equal), jle (jump if less or equal) and similar
+
+https://www.felixcloutier.com/x86/loop:loopcc[loop]::
+    checks RCX/ECX/CX register as a counter. Each time the LOOP instruction is
+    executed, the count register is decremented, the check for 0. If the count
+    is 0, the loop is terminated. If the count is not zero, a near jump is
+    performed.
+
+=== https://www.felixcloutier.com/x86/jmp[Different Types of Jumps]
+
+Near Jump::
+    A jump to an instruction within the current code segment (the segment
+    currently pointed to by the CS register), sometimes referred to as an
+    intrasegment jump
+
+Short Jump::
+    A near jump where the jump range is limited to –128 to +127 from the current
+    EIP value
+
+Far Jump::
+    A jump to an instruction located in a different segment than the current
+    code segment but at the same privilege level, sometimes referred to as an
+    intersegment jump
+
+Task Switch::
+    A jump to an instruction located in a different task
+
+== Function Calls
+=== Requirements
+
+Must start wih a function prologue and end with a function epilogue followed by
+a `pop rip`.
+
+.function prologue
+[source, nasm]
+----
+push rbp
+mov rbp,rsp
+----
+
+.function epilogue
+[source, nasm]
+----
+mov rsp, rbp
+pop rbp
+----
+
+Must move to the the function label with a jmp, like so:
+
+[source, nasm]
+----
+push rip
+jmp <address>
+----
+
+The address now stored in the stack (for rip contents) is called *return*
+*address*.
+
+The first six arguments must be rdi, rsi, rdx, rcx, r8, and r9, respectively.
+
+One should not invoke `ret` (`pop rip`) unless the stack is in exactly the same
+state as when the function started.
+
+Must restore all other register that where not arguments.
+
+Callee-saved registers::
+    must be restored by the procedure being called.
+    rbx, rbp, rsp, r12-r15
+
+Caller-saved registers::
+    Should be saved before invoking a function and restored after. All other
+    registers are caller-saved.
+
+=== Pattern of Calling a Function
+- Save all caller-saved registers you want to survive function call (you can use
+  push for that)
+
+- Store arguments in the relevent register (rdi, rsi, etc).
+
+- If you return a value from a function, you use xmm0 for floating point values
+  and use rax for other values, such as integers or addresses.
+
+- Restore caller-saved registers stored before the function call.
+
+NOTE: some system calls also return values - be careful to read the docs!
+
+=== Function Related Instructions
+`ret`::
+    Denotes the function end. same as `pop rip`.
+
+`leave`::
+    Is the the same as `mov rsp, rbp` and `pop rbp` (the epilogue).
+
+`call <address>`::
+    Is the same as `push rip` and `jmp <address>`
+
+`enter 0, 0`::
+    Is the same as `push rbp` and `mov rbp, rsp` (the prologue). It
+    is said to have poor performance.
+
+=== Locality
+Functions can have their own sections, such as `.data`, `.bss`, and `.text`. A
+period before a variable means that variable is local to that function.
+
+=== Function types
+Branch Functions::
+    Contain calls to other functions
+
+Leaf Functions::
+    Execute some commands and then return to the parent function.
+
+=== Alignment
+The stack has to have 16-byte alignment when you call a function. Inside a leaf
+function, you can in general ignore stack from and stack alignment; it is not
+necessary as long as you don't mess with the stack. Similarly, if your function
+does not use SIMD instructions, you do not need to care about alignment.
+Compilers have optimizing functionality, and sometimes when you look at code
+generated by compilers, you will find that there was no stack from used. That
+happens when the compilers noticed during optimization that a stack form is no
+needed. It **IS** a good habit to always include a stack from and check the
+stack alignment; it can save you a lot of trouble later. A good reaason to
+include a stack frome is the fact that GDB and GDB-based debugges (such as DDD
+and SASM) expect to find a stack frame. If there is no stacfk form in your code,
+the debugger will behave unpredictably, such as ignoring breakpoints or jumping
+over instructions.
+
+== Syscalls
+syscall instructions implicitly uses rcx. System calls cannot accept more than
+six arguments.
+
+All the syscalls are listed in _/usr/include/nasm/unistd.h_ (or something
+similar), together with their numbers (the value to put in EAX before you call
+int 80h). In ubuntu I found the file in
+_/usr/include/x86_64-linux-gnu/asm/unistd_64.h_.
+
+You can checkout https://www.man7.org/linux/man-pages/man2/syscalls.2.html[man syscalls] on links to lookup a syscall.
+
+checkout this https://hackeradam.com/x86-64-linux-syscalls/[syscall table] for
+linux
+
+== Different Addressing types
+
+=== Immediate
+use the specified value
+
+ex.
+
+[source, nasm]
+----
+mov rax, 10
+----
+
+=== Register
+Use the value in teh specified register
+
+[source, nasm]
+----
+mov rax, rbx
+----
+
+[source, nasm]
+----
+mov rax, [10]; transfers 8 bytes starting at the tenth address into rax
+----
+
+[source, nasm]
+----
+mov r9, 10
+mov rax, [r9] ; take the address from the register
+----
+
+=== Direct Memory
+Use the value at the specified memory address
+
+[source, nasm]
+----
+mov rdi, 0x172 ; not 100% sure about this
+----
+
+=== Base-indexed with scale and discplacement
+Most addressing modes are generalized by this mode. The address here is
+calculated based on the following components:
+
+----
+Address = base + index * scale + displacement
+----
+
+- Base is either immediate or a register
+- Scale can only be immediate equal to 1, 2, 4, or 8
+- Index is immediate or a register 
+- Displacement is always immediate
+
+[source, nasm]
+----
+mov rax, [rbx + 4 * rcx + 9]
+mov rax, [4 * r9]
+mov rdx, [rax + rbx]
+lea rax, [rbx + rbx * 4] ; rax = rbx * 5
+add r8, [9 + rbx * 8 + 7]
+----
+
+
+== Endianness
+=== Least significant vs Most significant
+This is dependent on the endianness of the system. Most systems are little
+endian meaning that the less significant bits are further the the right. More
+signifacant bits are further to the right.
+
+=== Text
+This instruction
+
+[source, gdb]
+----
+mov rax, [text1]
+----
+
+stores `text1` into rax in little endian mode
+
+.gdb rax register
+[source, gdb]
+----
+(gdb) i r
+rax            0x5452455000636261  6075995057182433889
+----
+
+0x61 is a, 0x62 is b, and 0x63 is c.
+
+=== Change a number from little endian to big endian in C
+[source, c]
+----
+#include <stdio.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+
+int
+main(void){
+    unsigned int num = 0x12345678;
+    printf("%x\n", htonl(num));
+}
+----
+
+== Pointers and Differnt Addressing Types
+Pointers are 8 bytes.
+
+you need to specify operation size, when trying to write shomewhere a value
+whose size is not specified.
+
+[source, nasm]
+----
+section .data
+    test: dq -1
+section .bss
+section .text
+       global main
+main:
+   mov byte[test], 1 
+    ;mov [test], 1 ; gives an error
+   mov word[test], 1
+   mov dword[test], 1
+   mov qword[test], 1
+
+       mov  rax, 60
+       mov rdi, 0 
+       syscall
+----
+
+== Instructions
+=== https://www.felixcloutier.com/x86/neg[NEG]
+The https://www.felixcloutier.com/x86/neg[NEG] instruction applys two complement. It sets the CF falgs to zero if the
+source operand is 0; otherwise it is set to 1.
+
+=== https://www.felixcloutier.com/x86/imul[IMUL]
+signed multiplication
+
+One-operand form::
+    secound operand is in AL, AX, EAX, or RAX, depending on the
+    size
+
+Two-operand form::
+    With this form the destination operand (the first operand) is multiplied by
+    the source operand
+
+Three-operand form::
+    with `mul a, b, c`, the multiplication of `b` and `c` is
+    stored in `a`
+
+=== https://www.felixcloutier.com/x86/mul[MUL]
+unsigned multiply
+
+the source operand is located in either AL, AX, or EAX, dending on the size of
+the operand.
+
+The result is stored in RDX:RAX meaning that the lower 64 bits are stored in RAX
+and the upper 64 bits are stored in RDX. This is because the result of two
+numbers can be larger bit size they originaly had.
+
+=== https://www.felixcloutier.com/x86/sub[SUB]
+subtract source operand from the destination operand and stores the result in
+the destination operand.
+
+- integer subraction; signed and unsigned
+
+- sets OF flags to indicate an overflow in the signed or unsigned result,
+  respectively.
+
+- The SF flag indicates the sign of the signed result
+
+In 64-bit mode the instruction's default operation size is 32 bits
+
+=== https://www.felixcloutier.com/x86/idiv[IDIV]
+signed divide. Divides the value in AX, DX:AX, or EDX:EAX (dividend) by the
+source operand (divisor) and stores the result in AX (AH:AL), DX:AX, or EDX:EAX
+registers.
+
+- Overflow is indicated withthe #DE (divide error) exception rather than with
+  the CF flag
+
+The **modulo** can be found in rdx.
+
+WARNING: Remember to set rdx to zero every time before you use idiv or the
+         resulting quotient may be wrong.
+
+
+=== https://www.felixcloutier.com/x86/lea[LEA]
+[source, nasm]
+----
+lea rsi, [variable]
+----
+
+square brackets represent *indirect addressing*.
+
+=== https://www.felixcloutier.com/x86/div[DIV]
+Divids unsigned the value in the AX, DX:AX, EDX:EAX, or RDX:RAX registers
+(dividend) by the source operand (divisor) and stores the result in AX (AH:AL),
+DX:AX, EDX:EAX, or RDX:RAX register
+
+=== https://www.felixcloutier.com/x86/test[TEST]
+Computes the bit-wise logical AND of first operand (source 1 operand) and the
+second operand (source 2 operand) and sets the SF, ZF, and PF status flags
+according to the result. The result is then discarded.
+
+If the result of AND is zero then the ZF flag is set.
+
+=== https://www.felixcloutier.com/x86/nop[NOP]
+The x86-64 ISA includes several no-op (no operation) instructions, including
+`nop`, `nop A,` (no-op with an argument), and `data16`. No-ops do pretty much
+nothing, but do set the rflags. The main reason for no-ops is to optimize
+instruction memory (e.g., code size, alignment).
+
+=== MOVSD
+move a double precision floating point value
+
+=== MOVSS
+move a single precision floating point value
+
+=== What is the differnce between SAR and SHR?
+SAR sets or clears the most significant bit depending on the sign, While SHR
+just clears the most significant bit.
+
+
+
+=== What's the difference between the CF flag and OF flag.
+Carry Flag::
+    bits that are carried over in *UNSIGNED* integer arithmetic
+
+Overflow Flag::
+    bits that are carried over in *SIGNED* integer arithmetic
+
+== NASM and GDB
+=== Get Memory Allocated On The Heap
+
+List memory regions mapped by the specified process
+- https://www.baeldung.com/linux/find-heap-memory-running-process[find-heap-memory-running-process]
+
+[source, gdb]
+----
+(gdb) info proc mappings
+----
+
+.output
+[%collapsible]
+====
+    (gdb) info proc mappings
+    process 56173
+    Mapped address spaces:
+              Start Addr           End Addr       Size     Offset  Perms  objfile
+          0x555555554000     0x555555555000     0x1000        0x0  r--p   /usr/local/share/tst/c/tst
+          0x555555555000     0x555555556000     0x1000     0x1000  r-xp   /usr/local/share/tst/c/tst
+          0x555555556000     0x555555557000     0x1000     0x2000  r--p   /usr/local/share/tst/c/tst
+          0x555555557000     0x555555558000     0x1000     0x2000  r--p   /usr/local/share/tst/c/tst
+          0x555555558000     0x555555559000     0x1000     0x3000  rw-p   /usr/local/share/tst/c/tst
+          0x555555559000     0x55555557a000    0x21000        0x0  rw-p   [heap]
+          0x7fffb7d74000     0x7ffff7d78000 0x40004000        0x0  rw-p   
+          0x7ffff7d78000     0x7ffff7da0000    0x28000        0x0  r--p   /usr/lib/x86_64-linux-gnu/libc.so.6
+          0x7ffff7da0000     0x7ffff7f35000   0x195000    0x28000  r-xp   /usr/lib/x86_64-linux-gnu/libc.so.6
+          0x7ffff7f35000     0x7ffff7f8d000    0x58000   0x1bd000  r--p   /usr/lib/x86_64-linux-gnu/libc.so.6
+          0x7ffff7f8d000     0x7ffff7f8e000     0x1000   0x215000  ---p   /usr/lib/x86_64-linux-gnu/libc.so.6
+          0x7ffff7f8e000     0x7ffff7f92000     0x4000   0x215000  r--p   /usr/lib/x86_64-linux-gnu/libc.so.6
+          0x7ffff7f92000     0x7ffff7f94000     0x2000   0x219000  rw-p   /usr/lib/x86_64-linux-gnu/libc.so.6
+          0x7ffff7f94000     0x7ffff7fa1000     0xd000        0x0  rw-p   
+          0x7ffff7fbb000     0x7ffff7fbd000     0x2000        0x0  rw-p   
+          0x7ffff7fbd000     0x7ffff7fc1000     0x4000        0x0  r--p   [vvar]
+          0x7ffff7fc1000     0x7ffff7fc3000     0x2000        0x0  r-xp   [vdso]
+          0x7ffff7fc3000     0x7ffff7fc5000     0x2000        0x0  r--p   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+    o.2
+          0x7ffff7fc5000     0x7ffff7fef000    0x2a000     0x2000  r-xp   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+    --Type <RET> for more, q to quit, c to continue without paging--
+    o.2
+          0x7ffff7fef000     0x7ffff7ffa000     0xb000    0x2c000  r--p   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+    o.2
+          0x7ffff7ffb000     0x7ffff7ffd000     0x2000    0x37000  r--p   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+    o.2
+          0x7ffff7ffd000     0x7ffff7fff000     0x2000    0x39000  rw-p   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+    o.2
+          0x7ffffffdd000     0x7ffffffff000    0x22000        0x0  rw-p   [stack]
+      0xffffffffff600000 0xffffffffff601000     0x1000        0x0  --xp   [vsyscall]
+====
+
+
+From the heap memory addresses we can use `find` to find a string within the heap
+
+[source, gdb]
+----
+find 0x555555559000, 0x55555557a000, 'h', 'e', 'l', 'l', 'o', '1'
+----
+
+=== Get type of
+[source, gdb]
+----
+(gdb) ptype  0x404034
+type = int
+----
+
+=== Breaking at local labels
+[source, gdb]
+----
+b main.string_size
+----
+
+=== Looking at flags
+To get flag values:
+[source, gdb]
+----
+info registers eflags
+----
+
+An output like this:
+
+[source, gdb]
+----
+eflags  0x41  [ CF ZF ]
+----
+
+means that the carry and zero flag are set
+
+=== Next instruction
+assembly:
+[source, gdb]
+----
+(gdb) ni
+----
+
+C:
+[source, gdb]
+----
+(gdb) n
+----
+
+=== Steping into a function
+To step into an assembly function
+[source, gdb]
+----
+(gdb) stepi
+----
+
+To step into an C function
+[source, gdb]
+----
+(gdb) step
+----
+
+=== Make Printing Look Nice
+[source, gdb]
+----
+(gdb) set print pretty
+----
+
+=== Get current line
+[source, gdb]
+----
+(gdb) frame
+----
+
+=== Break at specific instruction number
+[source, gdb]
+----
+ (gdb) b * 0x0000000000401110
+----
+
+=== Flavor
+to set dissasembly flavor to intel instead of AT&T:
+
+[source, gdb]
+----
+(gdb) set disassembly-flavor intel
+----
+
+=== Dissassembly a function
+
+[source, gdb]
+----
+disassemble <function name>
+----
+
+* **function name** - can be the name of any function (i.e main)
+
+
+=== Finding Immediate / registers / label values
+If you have
+
+[source, nasm]
+----
+msg db "hello, world", 10, 0
+----
+
+In the `.data` section and use it later with
+
+[source, nasm]
+----
+mov rsi, msg
+----
+
+The output of `(gdb) dissassembly <function name>` might look something like
+this
+
+[source, nasm]
+----
+0x000000000040111a <+10>:    movabs rsi,0x404028
+----
+
+You can see what is inside the memory address `0x404028` with
+
+[source, gdb]
+----
+(gdb) x/s 0x404028
+0x404028 <msg>: "hello, world\n"
+----
+
+As you can see that is the address is where `msg` is located
+
+* **get register value** -> `(gdb) x/s $rax`
+* **get register value** -> `(gdb) p $rax`
+* **get label value** -> `(gdb) x/s &codes`
+* **get label value** -> `(gdb) p &codes`
+* **x/s** -> output string
+* **x/c** -> output character
+* **x/13c** -> output 13 characters
+* **x/13d** -> output 13 characters in decimal representation
+
+NOTE: checkout `(gdb) help x`
+
+=== TUI
+[source, gdb]
+----
+(gdb) tui <enable/disable>
+----
+
+=== Registers
+[source, gdb]
+----
+(gdb) info registers
+----
+
+=== Source code
+[source, gdb]
+----
+(gdb) list <nothing or line number>
+----
+
+=== Steping through Instructions
+.next_asm.gdb
+[source, gdb]
+----
+set language asm
+set disassembly-flavor intel
+define asm_next
+nexti
+disassemble
+end
+----
+
+[source, sh]
+----
+$ gdb -x next_asm.gdb <executable>
+----
+
+=== Step out of function
+[source, gdb]
+----
+(gdb) finish
+----
+
+
+== Segment Registers
+
+Logical addresses can be explicitly specified in *x86 assembly language
+
+all segments have a base of zero
+
+In protected mode, code may always modify all segment registers except CS (the
+code segment selector). This is because the current privilege level (CPL) of the
+processor is stored in the lower 2 bits of the CS register
+
+The only ways to raise the processor privilege level (and reload CS) are through
+the lcall (far call) and int (interrupt) instructions. Similarly, the only ways
+to lower the privilege level (and reload CS) are through lret (far return) and
+iret (interrupt return) instructions. In real mode, code may also modify the CS
+register by making a far jump (or using an undocumented POP CS instruction on
+the 8086 or 8088).[4] Of course, in real mode, there are no privilege levels;
+all programs have absolute unchecked access to all of memory and all CPU
+instructions
+
+[source, asm]
+----
+movl $42, %fs:(%eax)  ; Equivalent to M[fs:eax]<-42) in RTL
+----
+
+or in intel syntax
+
+[source, nasm]
+----
+mov dword [fs:eax], 42
+----
+
+* What data is in each segment
+    - All CPU instructions are implicitly fetched from the code segment
+      specified by the segment selector held in the CS register.
+
+    - Most memory references come from the data segment specified by the segment
+      selector held in the DS register. These may also come from the extra
+      segment specified by the segment selector held in the ES register, if a
+      segment-override prefix precedes the instruction that makes the memory
+      reference. Most, but not all, instructions that use DS by default will
+      accept an ES override prefix.
+
+    - Processor stack references, either implicitly (e.g. push and pop
+      instructions) or explicitly (memory accesses using the (E)SP or (E)BP
+      registers) use the stack segment specified by the segment selector held in
+      the SS register.
+
+    - String instructions (e.g. stos, movs), along with data segment, also use
+      the extra segment specified by the segment selector held in the ES
+      register.
+
+    - mov is used to manipulate data, so the address is relative to the data
+      segment
+
+=== SHDR
+From https://linux.die.net/man/5/elf[man elf] we can see that the `Elf32_Shdr` or `Elf32_Shdr` structs, can
+contain info about `.bss`, `.data`, etc.
+
+=== Data segment
+
+==== Example 1
+
+[source, nasm]
+----
+global main
+section .data
+    bNum db 123
+section .text
+main:
+lea rax, [bNum]
+----
+
+.gdb disassembly
+[source, gdb]
+----
+ lea    rax,ds:0x404028
+----
+
+ds:: data segment
+0x404028:: address of bNum
+
+== Compiling and Linking
+=== Makefile
+The `-f` is follow by the output format, in our case elf64, which means
+Executable and Linkable Format for 64-bit. The `-g` mains that we include debug
+information in a debug format specified adter the `-F` option. We use dwarf
+debug format. The `-l` tells NASM to generate a _.lst_ file. Nasm will create an
+object file with a _.o_ extension. That object file is used by the linker.
+
+DWARF::
+    **D**ebug With **A**rbitrary **R**ecord **F**ormat
+
+STABS::
+    Debug with **S**ymbol **Tab**le **S**trings.
+
+elf64::
+    **E**xecutable and **l**inkable **F**ormat for **64**-bit
+
+PIE::
+    **P**osition-**I**ndependant **E**xecutables
+
+== Modes
+Real mode::
+* the most ancient, 16-bit
+* Computer is booted into this mode
+* Can access pretty much any memory location
+* No virtual memory
+
+Protected::
+* commonly referred as 32-bit one
+* Virtual memory
+* Protection rings
+* Improved segmentation
+
+Virtual::
+* emulate real mode inside protected
+
+System management mode::
+* for sleep mode, power management, etc
+
+Long Mode::
+* Virtual memory
+
+"A 386 CPU can be put back into real mode by clearing a bit in the CR0 control
+register, however this is a privileged operation in order to enforce security
+and robustness"
+-- X86_memory_segmentation, Wikipedia
+
+
+== Memory 
+The memory size has a theoretical limit of 2^64 address.
+
+If you look at this _.lst_ file you can see the each memory address (second
+column) has 8 hexadecimal digits meaning that there are 64 bits per instruction.
+This is because we are using 64 bit assembler.
+
+.\.lst file
+[code, lst]
+----
+    11 00000000 B801000000                  mov rax, 1
+    12 00000005 BF01000000                  mov rdi, 1
+----
+
+
+=== Layout
+
+The stack in high memory can grow; it grows in the downward directection toward
+`section .bss`. The available free memory between the stack and the other
+sections is called the heap.
+
+The memory in `section .bss` is asigned at runtime.
+
+[ditaa]
+----
++----------------------------+ high address
+|    environment variables   |
+|   command line arguments   |
++----------------------------+
+|          stack             |
+|                            |
+|                            |
+|                            |
+|                            |
+|                            |
+|                            |
+|           heap             |
++----------------------------+
+|                            |
+|           .bss             |
++----------------------------+
+|                            |
+|          .data             |
++----------------------------+
+|                            |
+|          .text             |
++----------------------------+ low address (executable code)
+----
+
+[source, gdb]
+----
+readelf --symbols ./memory | tail +10 | sort -k 2 -r
+----
+
+.output
+[%collapsible]
+====
+    38: 0000000000404090     0 NOTYPE  GLOBAL DEFAULT   23 _end
+    23: 0000000000404071     8 OBJECT  LOCAL  DEFAULT   23 qvar
+    22: 000000000040405d     2 OBJECT  LOCAL  DEFAULT   23 wvar
+    21: 0000000000404059     4 OBJECT  LOCAL  DEFAULT   23 dvar
+    20: 0000000000404058     1 OBJECT  LOCAL  DEFAULT   23 bvar
+    43: 0000000000404058     0 OBJECT  GLOBAL HIDDEN    22 __TMC_END__
+     7: 0000000000404054     1 OBJECT  LOCAL  DEFAULT   23 completed.0
+    41: 0000000000404051     0 NOTYPE  GLOBAL DEFAULT   23 __bss_start
+    32: 0000000000404051     0 NOTYPE  GLOBAL DEFAULT   22 _edata
+    19: 000000000040404d     1 OBJECT  LOCAL  DEFAULT   22 text2
+    18: 0000000000404045     8 OBJECT  LOCAL  DEFAULT   22 qNum2
+    17: 0000000000404041     1 OBJECT  LOCAL  DEFAULT   22 text1
+    16: 0000000000404039     8 OBJECT  LOCAL  DEFAULT   22 qNum1
+    15: 0000000000404035     4 OBJECT  LOCAL  DEFAULT   22 dNum
+    14: 000000000040402b     2 OBJECT  LOCAL  DEFAULT   22 warray
+    13: 0000000000404029     2 OBJECT  LOCAL  DEFAULT   22 wNum
+    12: 0000000000404028     1 OBJECT  LOCAL  DEFAULT   22 bNum
+    36: 0000000000404020     0 OBJECT  GLOBAL HIDDEN    22 __dso_handle
+    31: 0000000000404018     0 NOTYPE  WEAK   DEFAULT   22 data_start
+    34: 0000000000404018     0 NOTYPE  GLOBAL DEFAULT   22 __data_start
+    29: 0000000000404000     0 OBJECT  LOCAL  DEFAULT   21 _GLOBAL_OFFSET_TABLE_
+    27: 0000000000403e60     0 OBJECT  LOCAL  DEFAULT   19 _DYNAMIC
+     8: 0000000000403e58     0 OBJECT  LOCAL  DEFAULT   18 __do_global_dtor[...]
+    10: 0000000000403e50     0 OBJECT  LOCAL  DEFAULT   17 __frame_dummy_in[...]
+    25: 0000000000402060     0 OBJECT  LOCAL  DEFAULT   16 __FRAME_END__
+    28: 0000000000402004     0 NOTYPE  LOCAL  DEFAULT   15 __GNU_EH_FRAME_HDR
+    37: 0000000000402000     4 OBJECT  GLOBAL DEFAULT   14 _IO_stdin_used
+    33: 0000000000401190     0 FUNC    GLOBAL HIDDEN    13 _fini
+    42: 0000000000401110     0 NOTYPE  GLOBAL DEFAULT   12 main
+     9: 0000000000401100     0 FUNC    LOCAL  DEFAULT   12 frame_dummy
+     6: 00000000004010d0     0 FUNC    LOCAL  DEFAULT   12 __do_global_dtors_aux
+     5: 0000000000401090     0 FUNC    LOCAL  DEFAULT   12 register_tm_clones
+     4: 0000000000401060     0 FUNC    LOCAL  DEFAULT   12 deregister_tm_clones
+    39: 0000000000401050     5 FUNC    GLOBAL HIDDEN    12 _dl_relocate_sta[...]
+    40: 0000000000401020    38 FUNC    GLOBAL DEFAULT   12 _start
+    44: 0000000000401000     0 FUNC    GLOBAL HIDDEN    11 _init
+     2: 000000000040037c    32 OBJECT  LOCAL  DEFAULT    4 __abi_tag
+    35: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
+     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
+    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_mai[...]
+    11: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS memory.nasm
+    24: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
+     3: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
+     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crt1.o
+    26: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS
+====
+
+- **main**  -> 0x0000000000401110.
+- **.bss**  -> 0x0000000000404051
+- **.data** -> 0x0000000000404018
+
+=== Stack
+The stack segment starts in high memory, and when it grows, it grows in the
+downward direction. Items are placed on the stack with the
+https://www.felixcloutier.com/x86/push[push] instruction and removed from the
+stack with the https://www.felixcloutier.com/x86/pop[pop] instruction. Every
+time you push, the stack grows, every time you pop, the stack shrinks.
+
+The stack can be used as temporary storage to save values in registers and call
+them back later or, more importantly, to transfer values to functions.
+
+The stack has to have a 16-byte alignment when you call a function. The reason
+for this is that there are SIMD instructions that perform parallel operations on
+larger blocks of data, and these SIMD instructions may require that these data
+are located in memory on addresses that are multiples of 16 bytes.
+
+[source, nasm]
+----
+section .data
+    string db "ABCDE", 0
+    stringLen equ $ - string - 1
+
+main:
+    xor rax, rax
+    mov rbx, string
+    mov rcx, stringLen
+    mov r12, 0
+    pushLoop:
+        mov al, byte [rbx + r12]
+        push rax
+        inc r12
+        loop pushLoop
+----
+
+[source, gdb]
+----
+(gdb) i s
+----
+
+.output
+[%collapsible]
+====
+    #0  0x000000000040116a in pushLoop ()
+    #1  0x0000000000000044 in ?? ()
+    #2  0x0000000000000043 in ?? ()
+    #3  0x0000000000000042 in ?? ()
+    #4  0x0000000000000041 in ?? ()
+    #5  0x0000000000000001 in ?? ()
+    #6  0x00007ffff7da1d90 in __libc_start_call_main (main=main@entry=0x401130 <main>,
+        argc=1, argc@entry=-10544, argv=0x7fffffffd7e8, argv@entry=0x4)
+        at ../sysdeps/nptl/libc_start_call_main.h:58
+    #7  0x00007ffff7da1e40 in __libc_start_main_impl (main=0x401130 <main>, argc=-10544,
+        argv=0x4, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
+        stack_end=0x7fffffffd7d8) at ../csu/libc-start.c:392
+    #8  0x0000000000401065 in _start ()
+====
+
+Here you can see the stack, and can see 0x0000000000000041 (A),
+0x0000000000000042 (B), 0x0000000000000042 \(C), 0x0000000000000043 (D)
+0x0000000000000044 (E), being pushed onto the stack.
+
+=== Virtual Memory
+From https://linux.die.net/man/5/elf[man elf] or `info elf` we can see that
+`e_entry` from the `ElfN_Ehdr` struct gives the virtual address to which the
+system first transfers control.
+
+=== What is that D Flag
+The "D" flag determines the size of each element in the stack. It can be
+changed, but changing it can result in an unaligned stack if you are not
+careful.
+
+
+== Strings and Symbol Tables
+From https://linux.die.net/man/5/elf[man elf] we see that `Elf32_Sym` or `Elf64_Sym` can hold these tables.
+
+== Elf File Header
+
+[source, sh]
+----
+$ readelf --file-header ./memory
+----
+
+.output
+[%collapsible]
+====
+  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
+  Class:                             ELF64
+  Data:                              2's complement, little endian
+  Version:                           1 (current)
+  OS/ABI:                            UNIX - System V
+  ABI Version:                       0
+  Type:                              EXEC (Executable file)
+  Machine:                           Advanced Micro Devices X86-64
+  Version:                           0x1
+  Entry point address:               0x401020
+  Start of program headers:          64 (bytes into file)
+  Start of section headers:          14520 (bytes into file)
+  Flags:                             0x0
+  Size of this header:               64 (bytes)
+  Size of program headers:           56 (bytes)
+  Number of program headers:         13
+====
+
+[source, gdb]
+----
+(gdb) disass
+----
+
+.output
+[%collapsible]
+====
+    Dump of assembler code for function main:
+       0x0000000000401110 <+0>:     push   %rbp
+       0x0000000000401111 <+1>:     mov    %rsp,%rbp
+    => 0x0000000000401114 <+4>:     lea    0x404028,%rax
+       0x000000000040111c <+12>:    movabs $0x404028,%rax
+       0x0000000000401126 <+22>:    mov    0x404028,%rax
+       0x000000000040112e <+30>:    mov    %rax,0x404058
+       0x0000000000401136 <+38>:    lea    0x404058,%rax
+       0x000000000040113e <+46>:    lea    0x404029,%rax
+       0x0000000000401146 <+54>:    mov    0x404029,%rax
+       0x000000000040114e <+62>:    lea    0x404041,%rax
+       0x0000000000401156 <+70>:    movabs $0x404041,%rax
+       0x0000000000401160 <+80>:    movabs $0x404042,%rax
+       0x000000000040116a <+90>:    lea    0x404042,%rax
+       0x0000000000401172 <+98>:    mov    0x404041,%rax
+       0x000000000040117a <+106>:   mov    0x404042,%rax
+       0x0000000000401182 <+114>:   mov    %rbp,%rsp
+       0x0000000000401185 <+117>:   pop    %rbp
+       0x0000000000401186 <+118>:   mov    $0x3c,%eax
+       0x000000000040118b <+123>:   xor    %rdi,%rdi
+       0x000000000040118e <+126>:   syscall
+====
+
+The entry point from `readelf` is smaller then the entry point from `disass`.
+This is because their is a header for elf executables.
+
+
+== Numerical
+=== What does the most significant bit mean in numbers?
+It can either be a part of the bit of the number or thing it is trying to
+represent if it is a unsigned number. Or it can represent whether a number is
+"signed" or "unsigned" if it is a signed number.
+
+=== Single vs. Double Precision
+I decimal number has three parts:
+
+SIGN::
+Specifies a negitive or positive number, 0 being positive and 1 being
+negative.
+
+EXPONENT::
+Takes the non-decimal version of the number and counts the first bit to the
+right of most signicant on bit all the way to the least significant bit and
+then adds 127 if it is single percision or 1023 if it is double percision.
+
+FRACTION::
+Takes the non-decimal version number and stores the first bit to the right
+of most signicant on bit all the way to the least significant bit.
+
+If the exponent part of a single percision number is above 127 it is a positive
+exponent, otherwise it is a negative exponent.
+
+If the exponent part of a double percision number is above 1023 it is a positive
+exponent, otherwise it is a negative exponent.
+
+A single-precision number is stored in 32 bits: 1 sign bit, 8 exponent bits,
+and 23 fraction bits
+
+----
+S   EEEEEEEE   FFFFFFFFFFFFFFFFFFFFFFF 
+0   1      8   9                     31
+----
+
+A double-percision number is stored in 64-bits: 1 sign bit, 11 exponent bits,
+and 52 fractin bits.
+
+----
+S  EEEEEEEEEEE   FFFFFFFFFFFFFF...FFFFFFFFFFFFFFF 
+0  1         11  12                             63
+----
+=== Two's complement
+Two's complement is used to represent negative numbers.This is the steps to get
+the negative version of a number.
+
+1. Do a logical not to all the bits
+2. add 1
+
+Binary 4294967296 is zero, anything above this number is positive, anything
+below this is negative.
+
+For example, I can convert the number 500 into the negative version of the
+number in c.
+
+[source, c]
+----
+#include <stdio.h>
+
+#define NUM 500
+
+int
+main(void){
+unsigned int a = (~NUM) + 1;
+printf("%d\n", a);
+}
+----
+
+=== Checking if Signed Number is negative
+==== binary
+check if the most significant bit is 1
+
+==== hexidecimal
+check if lefmost byte is 8, 9, A, B, C D, E, or F. Break number into multiple
+bytes or this will not work. For example 0xd12 would appear to be negative if
+you didn't break it up into byte chunks, doing so you get:
+
+----
+0x0d, 0x12 
+----
+
+or
+
+----
+0x0d << 8 | 0x12
+----
+
+Notice how the leftmost byte actually starts with a zero. Also notice how each
+byte is two digits long.
+
+you can or bytes together to get the original answer by doing
+
+----
+byte4 << 24 | byte3 << 16 | byte2 << 8 | byte1
+----
+
+In this case I or'ed together 4 bytes to get a 24 bit number. bitshift right 8,
+16, 24 are offsets; shifting by one byte, two bytes, and then three.
+
+== Syntax
+=== ATT vs. Intel Syntax
+gdb uses ATT syntax by default, but you can change it to intel (nasm's syntax)
+with the command `set disassembly-flavor intel`
+
+=== Strings
+To explicitly state the length of a string:
+
+[source, nasm]
+----
+db 27, 'Selling England by the Pound'
+----
+
+=== Constant Precomputation
+The math in the code belows is calculated at compile time and turned into a
+constant
+
+[source, nasm]
+----
+lab: db 0
+
+mov rax, lab + 1 + 2 *3 
+----
+
+== Books
+- "Learn to Program with Assembly by Jonathan Bartlett"
+    * learning AT&T syntax with GNU assembler
+
+- "Low-Level Programming by Igor Zhirkov" 
+    * intel syntax
+
+- "Linkers and Loaders, John R. Levine, 1999, The Morgan Kaufmann Series in
+  Sofware Engineering and Programming"
+
+- "Assembly Language for x86 Processors 6th Edition by Kip R. Irvine"
+
+- "Beginning x64 Assembly Programming from Novice to AVX Professional by Jo Van
+   Hoey"
+
+== Links
+- https://www.felixcloutier.com/x86/[x86 and amd64 instruction reference]
+- https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html[intel 64 IA-32 architectures Software Developer's Manual]
+- https://redirect.cs.umbc.edu/portal/help/nasm/nasm.shtml[nasm and gdb]
+- https://refspecs.linuxfoundation.org/elf/x86_64-abi-0.99.pdf[System V Application Binary Interface AMD64]
+- https://electronicsreference.com/assembly-language/linux_syscalls/[linux syscalls]
+- https://blog.packagecloud.io/the-definitive-guide-to-linux-system-calls/[more on linux syscalls]
+- https://github.com/torvalds/linux/blob/v3.13/arch/x86/syscalls/syscall_32.tbl[linux source code syscall table]
+- https://stackoverflow.com/questions/15017659/how-to-read-the-intel-opcode-notation[op code notation]
+- https://stackoverflow.com/questions/10684468/missing-debugging-information-with-gdb-and-nasm[debugging asm_next script nasm and gdb]
+
+== Asciidoctor
+- https://docs.asciidoctor.org/diagram-extension/latest/diagram_types/bytefield/[bytefield extension]
diff --git a/docs/index.html b/docs/index.html
new file mode 100644 (file)
index 0000000..166faf7
--- /dev/null
@@ -0,0 +1,3241 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="generator" content="Asciidoctor 2.0.16">
+<title>Low Level Learning</title>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
+<style>
+/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
+/* Uncomment the following line when using as a custom stylesheet */
+/* @import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"; */
+html{font-family:sans-serif;-webkit-text-size-adjust:100%}
+a{background:none}
+a:focus{outline:thin dotted}
+a:active,a:hover{outline:0}
+h1{font-size:2em;margin:.67em 0}
+b,strong{font-weight:bold}
+abbr{font-size:.9em}
+abbr[title]{cursor:help;border-bottom:1px dotted #dddddf;text-decoration:none}
+dfn{font-style:italic}
+hr{height:0}
+mark{background:#ff0;color:#000}
+code,kbd,pre,samp{font-family:monospace;font-size:1em}
+pre{white-space:pre-wrap}
+q{quotes:"\201C" "\201D" "\2018" "\2019"}
+small{font-size:80%}
+sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
+sup{top:-.5em}
+sub{bottom:-.25em}
+img{border:0}
+svg:not(:root){overflow:hidden}
+figure{margin:0}
+audio,video{display:inline-block}
+audio:not([controls]){display:none;height:0}
+fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
+legend{border:0;padding:0}
+button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
+button,input{line-height:normal}
+button,select{text-transform:none}
+button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
+button[disabled],html input[disabled]{cursor:default}
+input[type=checkbox],input[type=radio]{padding:0}
+button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
+textarea{overflow:auto;vertical-align:top}
+table{border-collapse:collapse;border-spacing:0}
+*,::before,::after{box-sizing:border-box}
+html,body{font-size:100%}
+body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;line-height:1;position:relative;cursor:auto;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
+a:hover{cursor:pointer}
+img,object,embed{max-width:100%;height:auto}
+object,embed{height:100%}
+img{-ms-interpolation-mode:bicubic}
+.left{float:left!important}
+.right{float:right!important}
+.text-left{text-align:left!important}
+.text-right{text-align:right!important}
+.text-center{text-align:center!important}
+.text-justify{text-align:justify!important}
+.hide{display:none}
+img,object,svg{display:inline-block;vertical-align:middle}
+textarea{height:auto;min-height:50px}
+select{width:100%}
+.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
+div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}
+a{color:#2156a5;text-decoration:underline;line-height:inherit}
+a:hover,a:focus{color:#1d4b8f}
+a img{border:0}
+p{line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
+p aside{font-size:.875em;line-height:1.35;font-style:italic}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
+h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
+h1{font-size:2.125em}
+h2{font-size:1.6875em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
+h4,h5{font-size:1.125em}
+h6{font-size:1em}
+hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em}
+em,i{font-style:italic;line-height:inherit}
+strong,b{font-weight:bold;line-height:inherit}
+small{font-size:60%;line-height:inherit}
+code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
+ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
+ul,ol{margin-left:1.5em}
+ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0}
+ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
+ul.square{list-style-type:square}
+ul.circle{list-style-type:circle}
+ul.disc{list-style-type:disc}
+ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
+dl dt{margin-bottom:.3125em;font-weight:bold}
+dl dd{margin-bottom:1.25em}
+blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
+blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
+@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
+h1{font-size:2.75em}
+h2{font-size:2.3125em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
+h4{font-size:1.4375em}}
+table{background:#fff;margin-bottom:1.25em;border:1px solid #dedede;word-wrap:normal}
+table thead,table tfoot{background:#f7f8f7}
+table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
+table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
+table tr.even,table tr.alt{background:#f8f8f7}
+table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:1.6}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
+h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
+.center{margin-left:auto;margin-right:auto}
+.stretch{width:100%}
+.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
+.clearfix::after,.float-group::after{clear:both}
+:not(pre).nobreak{word-wrap:normal}
+:not(pre).nowrap{white-space:nowrap}
+:not(pre).pre-wrap{white-space:pre-wrap}
+:not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
+pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
+pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
+pre>code{display:block}
+pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
+em em{font-style:normal}
+strong strong{font-weight:400}
+.keyseq{color:rgba(51,51,51,.8)}
+kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;box-shadow:0 1px 0 rgba(0,0,0,.2),inset 0 0 0 .1em #fff;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
+.keyseq kbd:first-child{margin-left:0}
+.keyseq kbd:last-child{margin-right:0}
+.menuseq,.menuref{color:#000}
+.menuseq b:not(.caret),.menuref{font-weight:inherit}
+.menuseq{word-spacing:-.02em}
+.menuseq b.caret{font-size:1.25em;line-height:.8}
+.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
+b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
+b.button::before{content:"[";padding:0 3px 0 2px}
+b.button::after{content:"]";padding:0 2px 0 3px}
+p a>code:hover{color:rgba(0,0,0,.9)}
+#header,#content,#footnotes,#footer{width:100%;margin:0 auto;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
+#header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
+#header::after,#content::after,#footnotes::after,#footer::after{clear:both}
+#content{margin-top:1.25em}
+#content::before{content:none}
+#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
+#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
+#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
+#header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:flex;flex-flow:row wrap}
+#header .details span:first-child{margin-left:-.125em}
+#header .details span.email a{color:rgba(0,0,0,.85)}
+#header .details br{display:none}
+#header .details br+span::before{content:"\00a0\2013\00a0"}
+#header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
+#header .details br+span#revremark::before{content:"\00a0|\00a0"}
+#header #revnumber{text-transform:capitalize}
+#header #revnumber::after{content:"\00a0"}
+#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
+#toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
+#toc>ul{margin-left:.125em}
+#toc ul.sectlevel0>li>a{font-style:italic}
+#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
+#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
+#toc li{line-height:1.3334;margin-top:.3334em}
+#toc a{text-decoration:none}
+#toc a:active{text-decoration:underline}
+#toctitle{color:#7a2518;font-size:1.2em}
+@media screen and (min-width:768px){#toctitle{font-size:1.375em}
+body.toc2{padding-left:15em;padding-right:0}
+#toc.toc2{margin-top:0!important;background:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
+#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
+#toc.toc2>ul{font-size:.9em;margin-bottom:0}
+#toc.toc2 ul ul{margin-left:0;padding-left:1em}
+#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
+body.toc2.toc-right{padding-left:0;padding-right:15em}
+body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
+@media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
+#toc.toc2{width:20em}
+#toc.toc2 #toctitle{font-size:1.375em}
+#toc.toc2>ul{font-size:.95em}
+#toc.toc2 ul ul{padding-left:1.25em}
+body.toc2.toc-right{padding-left:0;padding-right:20em}}
+#content #toc{border:1px solid #e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;border-radius:4px}
+#content #toc>:first-child{margin-top:0}
+#content #toc>:last-child{margin-bottom:0}
+#footer{max-width:none;background:rgba(0,0,0,.8);padding:1.25em}
+#footer-text{color:hsla(0,0%,100%,.8);line-height:1.44}
+#content{margin-bottom:.625em}
+.sect1{padding-bottom:.625em}
+@media screen and (min-width:768px){#content{margin-bottom:1.25em}
+.sect1{padding-bottom:1.25em}}
+.sect1:last-child{padding-bottom:0}
+.sect1+.sect1{border-top:1px solid #e7e7e9}
+#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
+#content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
+#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
+#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
+#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
+details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
+details{margin-left:1.25rem}
+details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;-webkit-tap-highlight-color:transparent}
+details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
+details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
+details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
+.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
+table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
+.paragraph.lead>p,#preamble>.sectionbody>[class=paragraph]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
+.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
+.admonitionblock>table td.icon{text-align:center;width:80px}
+.admonitionblock>table td.icon img{max-width:none}
+.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
+.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6);word-wrap:anywhere}
+.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
+.exampleblock>.content{border:1px solid #e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;border-radius:4px}
+.exampleblock>.content>:first-child{margin-top:0}
+.exampleblock>.content>:last-child{margin-bottom:0}
+.sidebarblock{border:1px solid #dbdbd6;margin-bottom:1.25em;padding:1.25em;background:#f3f3f2;border-radius:4px}
+.sidebarblock>:first-child{margin-top:0}
+.sidebarblock>:last-child{margin-bottom:0}
+.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
+.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
+.literalblock pre,.listingblock>.content>pre{border-radius:4px;overflow-x:auto;padding:1em;font-size:.8125em}
+@media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
+@media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
+.literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class=highlight],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
+.literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
+.listingblock>.content{position:relative}
+.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
+.listingblock:hover code[data-lang]::before{display:block}
+.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
+.listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
+.listingblock pre.highlightjs{padding:0}
+.listingblock pre.highlightjs>code{padding:1em;border-radius:4px}
+.listingblock pre.prettyprint{border-width:0}
+.prettyprint{background:#f7f7f8}
+pre.prettyprint .linenums{line-height:1.45;margin-left:2em}
+pre.prettyprint li{background:none;list-style-type:inherit;padding-left:0}
+pre.prettyprint li code[data-lang]::before{opacity:1}
+pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
+table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
+table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
+table.linenotable td.code{padding-left:.75em}
+table.linenotable td.linenos{border-right:1px solid;opacity:.35;padding-right:.5em}
+pre.pygments .lineno{border-right:1px solid;opacity:.35;display:inline-block;margin-right:.75em}
+pre.pygments .lineno::before{content:"";margin-right:-.125em}
+.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
+.quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
+.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
+.quoteblock blockquote{margin:0;padding:0;border:0}
+.quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
+.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
+.quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
+.verseblock{margin:0 1em 1.25em}
+.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans-serif;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
+.verseblock pre strong{font-weight:400}
+.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
+.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
+.quoteblock .attribution br,.verseblock .attribution br{display:none}
+.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
+.quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
+.quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
+.quoteblock.abstract{margin:0 1em 1.25em;display:block}
+.quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
+.quoteblock.excerpt>blockquote,.quoteblock .quoteblock{padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
+.quoteblock.excerpt,.quoteblock .quoteblock{margin-left:0}
+.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
+.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:.85rem;text-align:left;margin-right:0}
+p.tableblock:last-child{margin-bottom:0}
+td.tableblock>.content{margin-bottom:1.25em;word-wrap:anywhere}
+td.tableblock>.content>:last-child{margin-bottom:-1.25em}
+table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
+table.grid-all>*>tr>*{border-width:1px}
+table.grid-cols>*>tr>*{border-width:0 1px}
+table.grid-rows>*>tr>*{border-width:1px 0}
+table.frame-all{border-width:1px}
+table.frame-ends{border-width:1px 0}
+table.frame-sides{border-width:0 1px}
+table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}
+table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
+table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
+table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
+table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd),table.stripes-even tr:nth-of-type(even),table.stripes-hover tr:hover{background:#f8f8f7}
+th.halign-left,td.halign-left{text-align:left}
+th.halign-right,td.halign-right{text-align:right}
+th.halign-center,td.halign-center{text-align:center}
+th.valign-top,td.valign-top{vertical-align:top}
+th.valign-bottom,td.valign-bottom{vertical-align:bottom}
+th.valign-middle,td.valign-middle{vertical-align:middle}
+table thead th,table tfoot th{font-weight:bold}
+tbody tr th{background:#f7f8f7}
+tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
+p.tableblock>code:only-child{background:none;padding:0}
+p.tableblock{font-size:1em}
+ol{margin-left:1.75em}
+ul li ol{margin-left:1.5em}
+dl dd{margin-left:1.125em}
+dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
+ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
+ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
+ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
+ul.unstyled,ol.unstyled{margin-left:0}
+ul.checklist>li>p:first-child{margin-left:-1em}
+ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
+ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
+ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
+ul.inline>li{margin-left:1.25em}
+.unstyled dl dt{font-weight:400;font-style:normal}
+ol.arabic{list-style-type:decimal}
+ol.decimal{list-style-type:decimal-leading-zero}
+ol.loweralpha{list-style-type:lower-alpha}
+ol.upperalpha{list-style-type:upper-alpha}
+ol.lowerroman{list-style-type:lower-roman}
+ol.upperroman{list-style-type:upper-roman}
+ol.lowergreek{list-style-type:lower-greek}
+.hdlist>table,.colist>table{border:0;background:none}
+.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
+td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
+td.hdlist1{font-weight:bold;padding-bottom:1.25em}
+td.hdlist2{word-wrap:anywhere}
+.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
+.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
+.colist td:not([class]):first-child img{max-width:none}
+.colist td:not([class]):last-child{padding:.25em 0}
+.thumb,.th{line-height:0;display:inline-block;border:4px solid #fff;box-shadow:0 0 0 1px #ddd}
+.imageblock.left{margin:.25em .625em 1.25em 0}
+.imageblock.right{margin:.25em 0 1.25em .625em}
+.imageblock>.title{margin-bottom:0}
+.imageblock.thumb,.imageblock.th{border-width:6px}
+.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
+.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
+.image.left{margin-right:.625em}
+.image.right{margin-left:.625em}
+a.image{text-decoration:none;display:inline-block}
+a.image object{pointer-events:none}
+sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
+sup.footnote a,sup.footnoteref a{text-decoration:none}
+sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
+#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
+#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
+#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
+#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
+#footnotes .footnote:last-of-type{margin-bottom:0}
+#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
+.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
+.gist .file-data>table td.line-data{width:99%}
+div.unbreakable{page-break-inside:avoid}
+.big{font-size:larger}
+.small{font-size:smaller}
+.underline{text-decoration:underline}
+.overline{text-decoration:overline}
+.line-through{text-decoration:line-through}
+.aqua{color:#00bfbf}
+.aqua-background{background:#00fafa}
+.black{color:#000}
+.black-background{background:#000}
+.blue{color:#0000bf}
+.blue-background{background:#0000fa}
+.fuchsia{color:#bf00bf}
+.fuchsia-background{background:#fa00fa}
+.gray{color:#606060}
+.gray-background{background:#7d7d7d}
+.green{color:#006000}
+.green-background{background:#007d00}
+.lime{color:#00bf00}
+.lime-background{background:#00fa00}
+.maroon{color:#600000}
+.maroon-background{background:#7d0000}
+.navy{color:#000060}
+.navy-background{background:#00007d}
+.olive{color:#606000}
+.olive-background{background:#7d7d00}
+.purple{color:#600060}
+.purple-background{background:#7d007d}
+.red{color:#bf0000}
+.red-background{background:#fa0000}
+.silver{color:#909090}
+.silver-background{background:#bcbcbc}
+.teal{color:#006060}
+.teal-background{background:#007d7d}
+.white{color:#bfbfbf}
+.white-background{background:#fafafa}
+.yellow{color:#bfbf00}
+.yellow-background{background:#fafa00}
+span.icon>.fa{cursor:default}
+a span.icon>.fa{cursor:inherit}
+.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
+.admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
+.admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
+.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
+.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
+.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
+.conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);border-radius:50%;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
+.conum[data-value] *{color:#fff!important}
+.conum[data-value]+b{display:none}
+.conum[data-value]::after{content:attr(data-value)}
+pre .conum[data-value]{position:relative;top:-.125em}
+b.conum *{color:inherit!important}
+.conum:not([data-value]):empty{display:none}
+dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
+h1,h2,p,td.content,span.alt,summary{letter-spacing:-.01em}
+p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
+p,blockquote,dt,td.content,span.alt,summary{font-size:1.0625rem}
+p{margin-bottom:1.25rem}
+.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
+.exampleblock>.content{background:#fffef7;border-color:#e0e0dc;box-shadow:0 1px 4px #e0e0dc}
+.print-only{display:none!important}
+@page{margin:1.25cm .75cm}
+@media print{*{box-shadow:none!important;text-shadow:none!important}
+html{font-size:80%}
+a{color:inherit!important;text-decoration:underline!important}
+a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
+a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
+abbr[title]{border-bottom:1px dotted}
+abbr[title]::after{content:" (" attr(title) ")"}
+pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
+thead{display:table-header-group}
+svg{max-width:100%}
+p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
+h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
+#header,#content,#footnotes,#footer{max-width:none}
+#toc,.sidebarblock,.exampleblock>.content{background:none!important}
+#toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
+body.book #header{text-align:center}
+body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
+body.book #header .details{border:0!important;display:block;padding:0!important}
+body.book #header .details span:first-child{margin-left:0!important}
+body.book #header .details br{display:block}
+body.book #header .details br+span::before{content:none!important}
+body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
+body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
+.listingblock code[data-lang]::before{display:block}
+#footer{padding:0 .9375em}
+.hide-on-print{display:none!important}
+.print-only{display:block!important}
+.hide-for-print{display:none!important}
+.show-for-print{display:inherit!important}}
+@media amzn-kf8,print{#header>h1:first-child{margin-top:1.25rem}
+.sect1{padding:0!important}
+.sect1+.sect1{border:0}
+#footer{background:none}
+#footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
+@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
+</style>
+<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
+<style>
+pre { line-height: 125%; }
+td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
+td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
+pre.pygments .hll { background-color: #49483e }
+pre.pygments { background: #272822; color: #f8f8f2 }
+pre.pygments .tok-c { color: #75715e } /* Comment */
+pre.pygments .tok-err { color: #960050; background-color: #1e0010 } /* Error */
+pre.pygments .tok-k { color: #66d9ef } /* Keyword */
+pre.pygments .tok-l { color: #ae81ff } /* Literal */
+pre.pygments .tok-n { color: #f8f8f2 } /* Name */
+pre.pygments .tok-o { color: #f92672 } /* Operator */
+pre.pygments .tok-p { color: #f8f8f2 } /* Punctuation */
+pre.pygments .tok-ch { color: #75715e } /* Comment.Hashbang */
+pre.pygments .tok-cm { color: #75715e } /* Comment.Multiline */
+pre.pygments .tok-cp { color: #75715e } /* Comment.Preproc */
+pre.pygments .tok-cpf { color: #75715e } /* Comment.PreprocFile */
+pre.pygments .tok-c1 { color: #75715e } /* Comment.Single */
+pre.pygments .tok-cs { color: #75715e } /* Comment.Special */
+pre.pygments .tok-gd { color: #f92672 } /* Generic.Deleted */
+pre.pygments .tok-ge { font-style: italic } /* Generic.Emph */
+pre.pygments .tok-gi { color: #a6e22e } /* Generic.Inserted */
+pre.pygments .tok-go { color: #66d9ef } /* Generic.Output */
+pre.pygments .tok-gp { color: #f92672; font-weight: bold } /* Generic.Prompt */
+pre.pygments .tok-gs { font-weight: bold } /* Generic.Strong */
+pre.pygments .tok-gu { color: #75715e } /* Generic.Subheading */
+pre.pygments .tok-kc { color: #66d9ef } /* Keyword.Constant */
+pre.pygments .tok-kd { color: #66d9ef } /* Keyword.Declaration */
+pre.pygments .tok-kn { color: #f92672 } /* Keyword.Namespace */
+pre.pygments .tok-kp { color: #66d9ef } /* Keyword.Pseudo */
+pre.pygments .tok-kr { color: #66d9ef } /* Keyword.Reserved */
+pre.pygments .tok-kt { color: #66d9ef } /* Keyword.Type */
+pre.pygments .tok-ld { color: #e6db74 } /* Literal.Date */
+pre.pygments .tok-m { color: #ae81ff } /* Literal.Number */
+pre.pygments .tok-s { color: #e6db74 } /* Literal.String */
+pre.pygments .tok-na { color: #a6e22e } /* Name.Attribute */
+pre.pygments .tok-nb { color: #f8f8f2 } /* Name.Builtin */
+pre.pygments .tok-nc { color: #a6e22e } /* Name.Class */
+pre.pygments .tok-no { color: #66d9ef } /* Name.Constant */
+pre.pygments .tok-nd { color: #a6e22e } /* Name.Decorator */
+pre.pygments .tok-ni { color: #f8f8f2 } /* Name.Entity */
+pre.pygments .tok-ne { color: #a6e22e } /* Name.Exception */
+pre.pygments .tok-nf { color: #a6e22e } /* Name.Function */
+pre.pygments .tok-nl { color: #f8f8f2 } /* Name.Label */
+pre.pygments .tok-nn { color: #f8f8f2 } /* Name.Namespace */
+pre.pygments .tok-nx { color: #a6e22e } /* Name.Other */
+pre.pygments .tok-py { color: #f8f8f2 } /* Name.Property */
+pre.pygments .tok-nt { color: #f92672 } /* Name.Tag */
+pre.pygments .tok-nv { color: #f8f8f2 } /* Name.Variable */
+pre.pygments .tok-ow { color: #f92672 } /* Operator.Word */
+pre.pygments .tok-w { color: #f8f8f2 } /* Text.Whitespace */
+pre.pygments .tok-mb { color: #ae81ff } /* Literal.Number.Bin */
+pre.pygments .tok-mf { color: #ae81ff } /* Literal.Number.Float */
+pre.pygments .tok-mh { color: #ae81ff } /* Literal.Number.Hex */
+pre.pygments .tok-mi { color: #ae81ff } /* Literal.Number.Integer */
+pre.pygments .tok-mo { color: #ae81ff } /* Literal.Number.Oct */
+pre.pygments .tok-sa { color: #e6db74 } /* Literal.String.Affix */
+pre.pygments .tok-sb { color: #e6db74 } /* Literal.String.Backtick */
+pre.pygments .tok-sc { color: #e6db74 } /* Literal.String.Char */
+pre.pygments .tok-dl { color: #e6db74 } /* Literal.String.Delimiter */
+pre.pygments .tok-sd { color: #e6db74 } /* Literal.String.Doc */
+pre.pygments .tok-s2 { color: #e6db74 } /* Literal.String.Double */
+pre.pygments .tok-se { color: #ae81ff } /* Literal.String.Escape */
+pre.pygments .tok-sh { color: #e6db74 } /* Literal.String.Heredoc */
+pre.pygments .tok-si { color: #e6db74 } /* Literal.String.Interpol */
+pre.pygments .tok-sx { color: #e6db74 } /* Literal.String.Other */
+pre.pygments .tok-sr { color: #e6db74 } /* Literal.String.Regex */
+pre.pygments .tok-s1 { color: #e6db74 } /* Literal.String.Single */
+pre.pygments .tok-ss { color: #e6db74 } /* Literal.String.Symbol */
+pre.pygments .tok-bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
+pre.pygments .tok-fm { color: #a6e22e } /* Name.Function.Magic */
+pre.pygments .tok-vc { color: #f8f8f2 } /* Name.Variable.Class */
+pre.pygments .tok-vg { color: #f8f8f2 } /* Name.Variable.Global */
+pre.pygments .tok-vi { color: #f8f8f2 } /* Name.Variable.Instance */
+pre.pygments .tok-vm { color: #f8f8f2 } /* Name.Variable.Magic */
+pre.pygments .tok-il { color: #ae81ff } /* Literal.Number.Integer.Long */
+</style>
+<head>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=DotGothic16">
+<link rel="icon" type="image/png" href="N2DE_favicon.png"/>
+
+<style>
+
+/*--------------------------------------------------------------*/
+/*use '!important' to override default css used by asciidoctor*/
+/*--------------------------------------------------------------*/
+
+:root {
+    --gruvbox-black: #282828;
+    --gruvbox-black2: #1d2021;
+    --gruvbox-black3: #463f39;
+    --gruvbox-red: #fb4934;
+    --gruvbox-yellow: #fabd2f;
+    --gruvbox-white: #ebdbb2;
+    --gruvbox-white2: #fbf1c7;
+    --gruvbox-blue: #83a598;
+    --gruvbox-green: #b8bb26;
+    --gruvbox-bg1: #7c6f64;
+    --gruvbox-bg2: #665c54;
+
+}
+
+.title {
+  color: var(--gruvbox-red) !important;
+}
+
+blockquote {
+    color: var(--gruvbox-white) !important;
+}
+
+.hdlist1 {
+  font-size: 1.3em;
+}
+
+cite {
+    color: var(--gruvbox-green) !important;
+}
+
+.tableblock {
+    background-color: inherit;
+    color: var(--gruvbox-white);
+    max-width: 95%;
+}
+
+.tableblock th {
+    background-color: var(--gruvbox-black3);
+    color: var(--gruvbox-white);
+    max-width: 97%;
+}
+
+code:not([data-lang]) {
+    background-color: var(--gruvbox-bg2) !important;
+    color: var(--gruvbox-white);
+    text-shadow: none;
+}
+
+.checklist {
+    text-align: left;
+    font-size: .8em;
+}
+
+.checklist li ul { margin-left: 3%;
+}
+
+#content, h1, pre {
+    border-radius: 8px !important;
+}
+
+#header, #content, #footnotes, #footer {
+  padding-left: 0 !important;
+  padding-right: 0 !important;
+}
+
+.api-type a:hover {
+    text-decoration: underline;
+}
+
+.api-type, .api-type a {
+    color: var(--gruvbox-green);
+    text-decoration: none;
+}
+
+pre {
+    border-style: solid !important;
+    border-color: white !important;
+    border-width: 2px !important;
+}
+
+h1 {
+    font-family: "DotGothic16", sans-serif !important;
+    background-color: var(--gruvbox-bg2) !important;
+    color: var(--gruvbox-white) !important;
+    opacity: .6;
+}
+
+.admonitionblock > table td.content {
+    color: var(--gruvbox-white) !important;
+}
+
+/*
+html {
+    margin: 0;
+    height: 100%;
+    width: 100%;
+}
+
+*/
+/*html {*/
+body {
+    /*background: black url("background-image-space.jpeg") no-repeat fixed center;*/
+    /*background-color: black;*/
+    background-color: var(--gruvbox-black);
+    background-attachment: fixed;
+    background-size: cover;
+    overflow-y: scroll;
+    /*
+    margin: 0;
+    height: 100%;
+    width: 100%;
+    overflow: hidden;
+    */
+}
+
+
+/*
+body {
+    overflow-y: scroll;
+    background: rgba(0,0,0,0);
+    height: 100%;
+    margin: 2%;
+}
+*/
+
+#toc {
+    background-color: var(--gruvbox-black2) !important;
+    /*opacity: .9;*/
+}
+
+#toctitle {
+    color: var(--gruvbox-red);
+}
+
+a {
+    color: var(--gruvbox-blue);
+}
+
+#content {
+    color: #ebdbb2;
+    background: var(--gruvbox-black);
+    /*opacity: .9;*/
+}
+
+#header > h1:nth-last-child(2) {
+    border-bottom: none !important;
+    background-color: rgba(0, 0, 0, .1);
+    padding-left: 2%;
+}
+
+.sect1 + .sect1 {
+  border-top: none !important;
+}
+
+.sect1 h2 {
+    background-size: cover;
+    background-attachment: fixed;
+    border-bottom: 1px solid var(--gruvbox-white);
+    border-top: 1px solid var(--gruvbox-white);
+    text-align: center;
+    color: var(--gruvbox-white) !important;
+    /*
+    text-shadow: 1px 1px 1px var(--gruvbox-black);
+    text-shadow: 3px 3px 3px var(--gruvbox-black);
+    text-shadow: 5px 5px 5px var(--gruvbox-blue);
+    */
+}
+
+h3, h4, h5 {
+    /*
+    text-shadow: 1px 1px 1px var(--gruvbox-white);
+    */
+}
+
+h3 {
+  color: var(--gruvbox-red) !important;
+}
+
+h4 {
+  color: var(--gruvbox-yellow) !important;
+}
+
+h5 {
+  color: #83a598 !important;
+}
+
+h2 ~ *:not(h1) {
+  margin-left: .5em;
+}
+
+.pygments {
+    max-width: 97% !important;
+    white-space: pre;
+    overflow-x: scroll !important;
+}
+
+::before {
+    /*makes sure that the programming language that show up on hover is within
+      pre tag*/
+    padding-right: 3%;
+}
+
+@media screen and (max-width: 800px) {
+    .checklist li ul {
+        margin-left: 6% !important;
+    }
+    #toc {
+        padding-left: 10px;
+    }
+
+    footer {
+        margin-bottom: 10px !important;
+    }
+    html {
+        margin-bottom: 10px !important;
+    }
+}
+@media screen and (max-width: 535px) {
+    h3 ~ *:not(h2):not(h3) {
+      margin-left: 0 !important;
+    }
+
+    h4 ~ *:not(h2):not(h3):not(.h3):not(h4) {
+      margin-left: 0 !important;
+    }
+    h5 ~ *:not(h2):not(h3):not(.h3):not(h4):not(.h4):not(h5) {
+      margin-left: 0 !important;
+    }
+
+    footer {
+        margin-bottom: 10px !important;
+    }
+    html {
+        margin-bottom: 10px !important;
+    }
+}
+h3 ~ *:not(h2):not(h3) {
+  margin-left: 1.5em;
+}
+
+h4 ~ *:not(h2):not(h3):not(.h3):not(h4) {
+  margin-left: 2em;
+}
+h5 ~ *:not(h2):not(h3):not(.h3):not(h4):not(.h4):not(h5) {
+  margin-left: 2.5em;
+}
+
+
+.sect1 h2 {
+    background: linear-gradient(
+        to bottom,
+        rgba(251, 189, 47, 0.2), /* yellow */
+        rgba(0, 0, 0, 0.4)       /* black */
+    );
+    /*opacity: .9;*/
+  }
+
+#preamble p{
+  padding-left: 10px;
+  color: var(--gruvbox-white) !important;
+}
+
+#footer {
+    max-width: 62.5em !important;
+    padding-left: 10px !important;
+    text-align: center;
+}
+
+.logo img {
+    display: block !important;
+    margin-left: auto !important;
+    margin-right: auto !important;
+}
+
+#header > h1:first-child {
+  margin-top: .3em !important;
+  padding-top: .2em !important;
+  padding-bottom: .3em !important;
+}
+
+footer {
+    max-width: 62.5em;
+    margin-left: auto;
+    margin-right: auto;
+    display: block;
+
+}
+
+details[open] > summary::before {
+   /* display: none;*/
+    border-top: none;
+    content: "▼";
+    margin-top: -12px;
+}
+
+</style>
+
+</head>
+
+<script src="docinfo.js"></script>
+
+
+</head>
+<body class="article toc2 toc-left">
+<div id="header">
+<h1>Low Level Learning</h1>
+<div id="toc" class="toc2">
+<div id="toctitle">Table of Contents</div>
+<ul class="sectlevel1">
+<li><a href="#_related_links">Related Links</a></li>
+<li><a href="#_looking_at_the_opcode_tables">Looking at the OpCode tables</a>
+<ul class="sectlevel2">
+<li><a href="#_instructions">Instructions</a></li>
+<li><a href="#_opcodes">Opcodes</a></li>
+</ul>
+</li>
+<li><a href="#_data_types">Data types</a></li>
+<li><a href="#_registers">Registers</a>
+<ul class="sectlevel2">
+<li><a href="#_r_x_vs_e_x_vs_x_vs_h_vs_l">R_X vs E_X vs _X vs _H vs _L</a></li>
+<li><a href="#_general_purpose_registers">General Purpose Registers</a></li>
+<li><a href="#_flag_registers">Flag Registers</a></li>
+<li><a href="#_instruction_pointer_register_rip">Instruction Pointer Register (rip)</a></li>
+<li><a href="#_xmm_and_ymm_registers">xmm and ymm Registers</a></li>
+</ul>
+</li>
+<li><a href="#_main">Main</a></li>
+<li><a href="#_labels">Labels</a></li>
+<li><a href="#_jumping_looping">Jumping / looping</a>
+<ul class="sectlevel2">
+<li><a href="#_different_types_of_jumps">Different Types of Jumps</a></li>
+</ul>
+</li>
+<li><a href="#_function_calls">Function Calls</a>
+<ul class="sectlevel2">
+<li><a href="#_requirements">Requirements</a></li>
+<li><a href="#_pattern_of_calling_a_function">Pattern of Calling a Function</a></li>
+<li><a href="#_function_related_instructions">Function Related Instructions</a></li>
+<li><a href="#_locality">Locality</a></li>
+<li><a href="#_function_types">Function types</a></li>
+<li><a href="#_alignment">Alignment</a></li>
+</ul>
+</li>
+<li><a href="#_syscalls">Syscalls</a></li>
+<li><a href="#_different_addressing_types">Different Addressing types</a>
+<ul class="sectlevel2">
+<li><a href="#_immediate">Immediate</a></li>
+<li><a href="#_register">Register</a></li>
+<li><a href="#_direct_memory">Direct Memory</a></li>
+<li><a href="#_base_indexed_with_scale_and_discplacement">Base-indexed with scale and discplacement</a></li>
+</ul>
+</li>
+<li><a href="#_endianness">Endianness</a>
+<ul class="sectlevel2">
+<li><a href="#_least_significant_vs_most_significant">Least significant vs Most significant</a></li>
+<li><a href="#_text">Text</a></li>
+<li><a href="#_change_a_number_from_little_endian_to_big_endian_in_c">Change a number from little endian to big endian in C</a></li>
+</ul>
+</li>
+<li><a href="#_pointers_and_differnt_addressing_types">Pointers and Differnt Addressing Types</a></li>
+<li><a href="#_instructions_2">Instructions</a>
+<ul class="sectlevel2">
+<li><a href="#_neg">NEG</a></li>
+<li><a href="#_imul">IMUL</a></li>
+<li><a href="#_mul">MUL</a></li>
+<li><a href="#_sub">SUB</a></li>
+<li><a href="#_idiv">IDIV</a></li>
+<li><a href="#_lea">LEA</a></li>
+<li><a href="#_div">DIV</a></li>
+<li><a href="#_test">TEST</a></li>
+<li><a href="#_nop">NOP</a></li>
+<li><a href="#_movsd">MOVSD</a></li>
+<li><a href="#_movss">MOVSS</a></li>
+<li><a href="#_what_is_the_differnce_between_sar_and_shr">What is the differnce between SAR and SHR?</a></li>
+<li><a href="#_whats_the_difference_between_the_cf_flag_and_of_flag">What&#8217;s the difference between the CF flag and OF flag.</a></li>
+</ul>
+</li>
+<li><a href="#_nasm_and_gdb">NASM and GDB</a>
+<ul class="sectlevel2">
+<li><a href="#_get_memory_allocated_on_the_heap">Get Memory Allocated On The Heap</a></li>
+<li><a href="#_get_type_of">Get type of</a></li>
+<li><a href="#_breaking_at_local_labels">Breaking at local labels</a></li>
+<li><a href="#_looking_at_flags">Looking at flags</a></li>
+<li><a href="#_next_instruction">Next instruction</a></li>
+<li><a href="#_steping_into_a_function">Steping into a function</a></li>
+<li><a href="#_make_printing_look_nice">Make Printing Look Nice</a></li>
+<li><a href="#_get_current_line">Get current line</a></li>
+<li><a href="#_break_at_specific_instruction_number">Break at specific instruction number</a></li>
+<li><a href="#_flavor">Flavor</a></li>
+<li><a href="#_dissassembly_a_function">Dissassembly a function</a></li>
+<li><a href="#_finding_immediate_registers_label_values">Finding Immediate / registers / label values</a></li>
+<li><a href="#_tui">TUI</a></li>
+<li><a href="#_registers_2">Registers</a></li>
+<li><a href="#_source_code">Source code</a></li>
+<li><a href="#_steping_through_instructions">Steping through Instructions</a></li>
+<li><a href="#_step_out_of_function">Step out of function</a></li>
+</ul>
+</li>
+<li><a href="#_segment_registers">Segment Registers</a>
+<ul class="sectlevel2">
+<li><a href="#_shdr">SHDR</a></li>
+<li><a href="#_data_segment">Data segment</a></li>
+</ul>
+</li>
+<li><a href="#_compiling_and_linking">Compiling and Linking</a>
+<ul class="sectlevel2">
+<li><a href="#_makefile">Makefile</a></li>
+</ul>
+</li>
+<li><a href="#_modes">Modes</a></li>
+<li><a href="#_memory">Memory</a>
+<ul class="sectlevel2">
+<li><a href="#_layout">Layout</a></li>
+<li><a href="#_stack">Stack</a></li>
+<li><a href="#_virtual_memory">Virtual Memory</a></li>
+<li><a href="#_what_is_that_d_flag">What is that D Flag</a></li>
+</ul>
+</li>
+<li><a href="#_strings_and_symbol_tables">Strings and Symbol Tables</a></li>
+<li><a href="#_elf_file_header">Elf File Header</a></li>
+<li><a href="#_numerical">Numerical</a>
+<ul class="sectlevel2">
+<li><a href="#_what_does_the_most_significant_bit_mean_in_numbers">What does the most significant bit mean in numbers?</a></li>
+<li><a href="#_single_vs_double_precision">Single vs. Double Precision</a></li>
+<li><a href="#_twos_complement">Two&#8217;s complement</a></li>
+<li><a href="#_checking_if_signed_number_is_negative">Checking if Signed Number is negative</a></li>
+</ul>
+</li>
+<li><a href="#_syntax">Syntax</a>
+<ul class="sectlevel2">
+<li><a href="#_att_vs_intel_syntax">ATT vs. Intel Syntax</a></li>
+<li><a href="#_strings">Strings</a></li>
+<li><a href="#_constant_precomputation">Constant Precomputation</a></li>
+</ul>
+</li>
+<li><a href="#_books">Books</a></li>
+<li><a href="#_links">Links</a></li>
+<li><a href="#_asciidoctor">Asciidoctor</a></li>
+</ul>
+</div>
+</div>
+<div id="content">
+<div class="sect1">
+<h2 id="_related_links">Related Links</h2>
+<div class="sectionbody">
+<div class="ulist">
+<ul>
+<li>
+<p><a href="https://html-preview.github.io/?url=https://github.com/A-Larsen/beginning_low_level_learning/blob/main/docs/c-disassembling.html">c-disassemebling</a></p>
+</li>
+<li>
+<p><a href="https://html-preview.github.io/?url=https://github.com/A-Larsen/beginning_low_level_learning/blob/main/docs/Q-and-A.html">Q and A</a></p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_looking_at_the_opcode_tables">Looking at the OpCode tables</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Ex.</p>
+</div>
+<table class="tableblock frame-all grid-all stretch">
+<caption class="title">Table 1. SAL/SHL</caption>
+<colgroup>
+<col style="width: 16.6666%;">
+<col style="width: 16.6666%;">
+<col style="width: 16.6666%;">
+<col style="width: 16.6666%;">
+<col style="width: 16.6666%;">
+<col style="width: 16.667%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-top">Opcode</th>
+<th class="tableblock halign-left valign-top">Instruction</th>
+<th class="tableblock halign-left valign-top">Op/En</th>
+<th class="tableblock halign-left valign-top">64-bit Mode</th>
+<th class="tableblock halign-left valign-top">Compat/Leg Mode</th>
+<th class="tableblock halign-left valign-top">Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">D0/4</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">SAL r/m8, 1</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">M1</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Valid</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">valid</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Multiply r/m8 by 2, once</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">C1 /4 ib</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">SHL r/m16,imm8</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">M1</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Valid</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">valid</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Multiply r/m32 by 2, once</p></td>
+</tr>
+</tbody>
+</table>
+<div class="paragraph">
+<p>This is an example of an instruction table that you might see, In this case I
+took this from the
+<a href="https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html">Intel 64 and IA-32 Architectures software Developer&#8217;s Manual</a>.</p>
+</div>
+<div class="sect2">
+<h3 id="_instructions">Instructions</h3>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">r</dt>
+<dd>
+<p>"r" stands for a general purpose register, "r/m8" mean a 8 bit register,
+"r/m16" means a 16 bit register.</p>
+</dd>
+<dt class="hdlist1">m</dt>
+<dd>
+<p>A 16-, 32- or 64-bit operand in memory</p>
+</dd>
+<dt class="hdlist1">imm</dt>
+<dd>
+<p>stands for immediate value (e.g., integer constant like 42 or 1335).</p>
+</dd>
+<dt class="hdlist1">rel8</dt>
+<dd>
+<p>A relative address in the range from 128 bytes before the end of the
+instruction to 127 bytes after the end of the instruction.</p>
+</dd>
+<dt class="hdlist1">rel16, rel32</dt>
+<dd>
+<p>A relative address within the same code segment as the instruction
+assembled. The rel16 symbol applies to instructions with an operand-size
+attribute of 16 bits; the rel32 symbol applies to instructions with an
+operand-size attribute of 32 bits</p>
+</dd>
+</dl>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_opcodes">Opcodes</h3>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">REX.W</dt>
+<dd>
+<p>Indicates the use of a REX prefix that affects operand size or instruction
+semantics. The ordering of the REX prefix and other optional/mandatory
+instruction perfixes are discussed in Chapter 2. Note that REX prefixes
+promote legacy instructions to 64-bit behavor are not listed explicitly in
+the opcode column</p>
+</dd>
+<dt class="hdlist1">/Digit</dt>
+<dd>
+<p>A digit between 0 and 7 indicates that the ModR/M byte of the instruction
+uses only the r/m (register or memory) operand. The reg field contains the
+digit that provides an extension to the instruction&#8217;s opcode.</p>
+</dd>
+<dt class="hdlist1">/r</dt>
+<dd>
+<p>Indicates that the ModR/M byte of the instruction contains a register
+operand and an r/m operand.</p>
+</dd>
+<dt class="hdlist1">cb, cw, cd, cp, co, ct</dt>
+<dd>
+<p>A 1-byte (cb), 2-byte (cw), 4-byte (cd), 6-byte (cp), 8-byte (co) or
+10-byte (ct) value following the opcode. This value is used to specify a
+code offset and possibly a new value for the code segment register.</p>
+</dd>
+<dt class="hdlist1">ib, iw, id, io</dt>
+<dd>
+<p>A 1-byte (ib), 2-byte (iw), 4-byte (id) or 8-byte (io) immediate operand to
+the instruction that follows the opcode, ModR/M bytes or scale-indexing
+bytes. The opcode determines if the operand is a signed value. All words,
+doublewords and quadwords are given with the low-order byte first.</p>
+</dd>
+<dt class="hdlist1">+rb, +rw, +rd, +ro</dt>
+<dd>
+<p>Indicates the lower 3 bits of the opcode byte is used to encode the register
+operand without a modR/M byte. The instruction lists the corresponding
+hexadecimal value of the opcode byte with low 3 bits as 000b. In non-64-bit
+mode, a register code, from 0 through 7, is added to the hexadecimal value
+of the opcode byte. In 64-bit mode, indicates the four bit field of REX.b
+and opcode[2:0] field encodes the register operand of the instruction. “+ro”
+is applicable only in 64-bit mode. See Table 3-1 for the codes.</p>
+</dd>
+<dt class="hdlist1">+i</dt>
+<dd>
+<p>A number used in floating-point instructions when one of the operands is
+ST(i) from the FPU register stack. The number i (which can range from 0 to
+7) is added to the hexadecimal byte given at the left of the plus sign to
+form a single opcode byte.</p>
+</dd>
+</dl>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<i class="fa icon-note" title="Note"></i>
+</td>
+<td class="content">
+Look at Intel 64 and IA-32 Architectures Software Developer&#8217;s Manual page
+      2839
+</td>
+</tr>
+</table>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_data_types">Data types</h2>
+<div class="sectionbody">
+<table class="tableblock frame-all grid-all stretch">
+<caption class="title">Table 2. datatypes</caption>
+<colgroup>
+<col style="width: 33.3333%;">
+<col style="width: 33.3333%;">
+<col style="width: 33.3334%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-top">Type</th>
+<th class="tableblock halign-left valign-top">Length</th>
+<th class="tableblock halign-left valign-top">Name</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">db</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">8 bits</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Byte</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">dw</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">16 bits</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Word</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">dd</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">32 bits</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Double Word</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">dq</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">64 bits</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Quadword</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_registers">Registers</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_r_x_vs_e_x_vs_x_vs_h_vs_l">R_X vs E_X vs _X vs _H vs _L</h3>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">R_X</dt>
+<dd>
+<p>all 64 bits</p>
+</dd>
+<dt class="hdlist1">E_X</dt>
+<dd>
+<p>lower 32 bits</p>
+</dd>
+<dt class="hdlist1">_X</dt>
+<dd>
+<p>lower 16 bits</p>
+</dd>
+<dt class="hdlist1">_H</dt>
+<dd>
+<p>top 4 bits of last byte</p>
+</dd>
+<dt class="hdlist1">_L</dt>
+<dd>
+<p>bottom 4 bits of last byte</p>
+</dd>
+</dl>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_general_purpose_registers">General Purpose Registers</h3>
+<table class="tableblock frame-all grid-all stretch">
+<colgroup>
+<col style="width: 16.6666%;">
+<col style="width: 16.6666%;">
+<col style="width: 16.6666%;">
+<col style="width: 16.6666%;">
+<col style="width: 16.6666%;">
+<col style="width: 16.667%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-top">64-bit</th>
+<th class="tableblock halign-left valign-top">32-bit</th>
+<th class="tableblock halign-left valign-top">16-bit</th>
+<th class="tableblock halign-left valign-top">low 8-bit</th>
+<th class="tableblock halign-left valign-top">high 8-bit</th>
+<th class="tableblock halign-left valign-top">comment</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">rax</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">eax</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">ax</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">al</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">ah</p></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">rbx</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">ebx</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">bx</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">bl</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">bh</p></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">rcx</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">ecx</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">cx</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">cl</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">ch</p></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">rdx</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">edx</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">dx</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">dl</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">dh</p></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">rsi</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">esi</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">si</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">sil</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">rdi</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">edi</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">di</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">dil</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">rbp</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">ebp</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">bp</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">bpl</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Base Pointer</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">rsp</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">esp</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">sp</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">spl</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Stack Pointer</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r8</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r8d</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r8w</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r8b</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r9</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r9d</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r9w</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r9b</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r10</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r10d</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r10w</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r10b</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r11</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r11d</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r11w</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r11b</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r12</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r12d</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r12w</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r12b</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r13</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r13d</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r13w</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r13b</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r14</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r14d</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r14w</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r14b</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r15</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r15d</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r15w</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">r15b</p></td>
+<td class="tableblock halign-left valign-top"></td>
+<td class="tableblock halign-left valign-top"></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect2">
+<h3 id="_flag_registers">Flag Registers</h3>
+<table class="tableblock frame-all grid-all stretch">
+<colgroup>
+<col style="width: 25%;">
+<col style="width: 25%;">
+<col style="width: 25%;">
+<col style="width: 25%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-top">Name</th>
+<th class="tableblock halign-left valign-top">Symbol</th>
+<th class="tableblock halign-left valign-top">Bit</th>
+<th class="tableblock halign-left valign-top">Content</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Carry</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">CF</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">0</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Previous instruction had a carry</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">parity</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">PF</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">2</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Last byte has even number of 1s</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Adjust</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">AF</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">4</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">BCD operations</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Zero</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">ZF</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">6</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Pervious instruction resulted in zero</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Sign</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">SF</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">8</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Previous instruction resulted in most significant
+                            bit equal to 1</p></td>
+</tr>
+<tr>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Overflow</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">OF</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">11</p></td>
+<td class="tableblock halign-left valign-top"><p class="tableblock">Previous instruction resulted in overflow</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect2">
+<h3 id="_instruction_pointer_register_rip">Instruction Pointer Register (rip)</h3>
+<div class="paragraph">
+<p>The processor keeps trakc of the next instruction to be executed by storing the
+address of the next instruction in rip.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_xmm_and_ymm_registers">xmm and ymm Registers</h3>
+<div class="paragraph">
+<p>These registers are used for floating-point calculations and SIMD.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_main">Main</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>One file in your assembly program needs "main" defined. This seems to be defined
+in the <code>.text</code> section.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-k">section </span><span class="tok-nv">.text</span>
+<span class="tok-k">global </span><span class="tok-nv">main</span>
+<span class="tok-nl">main:</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_labels">Labels</h2>
+<div class="sectionbody">
+<div class="ulist">
+<ul>
+<li>
+<p>Labels look like this <code>&lt;description&gt;:</code></p>
+</li>
+<li>
+<p>Local lablels Look like this <code>.&lt;description&gt;:</code></p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>If there is a local label within a global label then the full label name
+could loop like this <code>main.loop</code>. Like in this example:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-k">section </span><span class="tok-nv">.text</span>
+<span class="tok-k">global </span><span class="tok-nv">main</span>
+<span class="tok-nl">main:</span>
+    <span class="tok-nf">.loop</span>
+    <span class="tok-c1">; do somethings</span>
+    <span class="tok-nf">jnz</span> <span class="tok-nv">.loop</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_jumping_looping">Jumping / looping</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p><code>cmp</code> sets the approriate flags. <code>jl</code> jumps if rax &lt; 42. <code>jmp</code> jumps straight to
+the <code>ex</code> label.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span>    <span class="tok-nf">cmp</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-mi">42</span>
+    <span class="tok-nf">jl</span> <span class="tok-nv">yes</span>
+    <span class="tok-nf">mov</span> <span class="tok-nb">rbx</span><span class="tok-p">,</span> <span class="tok-mi">0</span>
+    <span class="tok-nf">jmp</span> <span class="tok-nv">ex</span>
+<span class="tok-nl">yes:</span>
+    <span class="tok-nf">mov</span> <span class="tok-nb">rbx</span><span class="tok-p">,</span> <span class="tok-mi">1</span>
+<span class="tok-nl">ex:</span></code></pre>
+</div>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1"><code>ja</code></dt>
+<dd>
+<p>(jump if above)/ <code>jb</code> (jump if below) for a jump after a comparison
+of <em>unsigned numbers with cmp</em>.</p>
+</dd>
+<dt class="hdlist1"><code>jg</code></dt>
+<dd>
+<p>(Jump if greater) / <code>jl</code> (jump if less) for <em>signed</em>.</p>
+</dd>
+<dt class="hdlist1"><code>jae</code></dt>
+<dd>
+<p>(jump if above or equal), jle (jump if less or equal) and similar</p>
+</dd>
+<dt class="hdlist1"><a href="https://www.felixcloutier.com/x86/loop:loopcc">loop</a></dt>
+<dd>
+<p>checks RCX/ECX/CX register as a counter. Each time the LOOP instruction is
+executed, the count register is decremented, the check for 0. If the count
+is 0, the loop is terminated. If the count is not zero, a near jump is
+performed.</p>
+</dd>
+</dl>
+</div>
+<div class="sect2">
+<h3 id="_different_types_of_jumps"><a href="https://www.felixcloutier.com/x86/jmp">Different Types of Jumps</a></h3>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Near Jump</dt>
+<dd>
+<p>A jump to an instruction within the current code segment (the segment
+currently pointed to by the CS register), sometimes referred to as an
+intrasegment jump</p>
+</dd>
+<dt class="hdlist1">Short Jump</dt>
+<dd>
+<p>A near jump where the jump range is limited to –128 to +127 from the current
+EIP value</p>
+</dd>
+<dt class="hdlist1">Far Jump</dt>
+<dd>
+<p>A jump to an instruction located in a different segment than the current
+code segment but at the same privilege level, sometimes referred to as an
+intersegment jump</p>
+</dd>
+<dt class="hdlist1">Task Switch</dt>
+<dd>
+<p>A jump to an instruction located in a different task</p>
+</dd>
+</dl>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_function_calls">Function Calls</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_requirements">Requirements</h3>
+<div class="paragraph">
+<p>Must start wih a function prologue and end with a function epilogue followed by
+a <code>pop rip</code>.</p>
+</div>
+<div class="listingblock">
+<div class="title">function prologue</div>
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">push</span> <span class="tok-nb">rbp</span>
+<span class="tok-nf">mov</span> <span class="tok-nb">rbp</span><span class="tok-p">,</span><span class="tok-nb">rsp</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="title">function epilogue</div>
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">mov</span> <span class="tok-nb">rsp</span><span class="tok-p">,</span> <span class="tok-nb">rbp</span>
+<span class="tok-nf">pop</span> <span class="tok-nb">rbp</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Must move to the the function label with a jmp, like so:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">push</span> <span class="tok-nv">rip</span>
+<span class="tok-nf">jmp</span> <span class="tok-o">&lt;</span><span class="tok-nv">address</span><span class="tok-o">&gt;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The address now stored in the stack (for rip contents) is called <strong>return</strong>
+<strong>address</strong>.</p>
+</div>
+<div class="paragraph">
+<p>The first six arguments must be rdi, rsi, rdx, rcx, r8, and r9, respectively.</p>
+</div>
+<div class="paragraph">
+<p>One should not invoke <code>ret</code> (<code>pop rip</code>) unless the stack is in exactly the same
+state as when the function started.</p>
+</div>
+<div class="paragraph">
+<p>Must restore all other register that where not arguments.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Callee-saved registers</dt>
+<dd>
+<p>must be restored by the procedure being called.
+rbx, rbp, rsp, r12-r15</p>
+</dd>
+<dt class="hdlist1">Caller-saved registers</dt>
+<dd>
+<p>Should be saved before invoking a function and restored after. All other
+registers are caller-saved.</p>
+</dd>
+</dl>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_pattern_of_calling_a_function">Pattern of Calling a Function</h3>
+<div class="ulist">
+<ul>
+<li>
+<p>Save all caller-saved registers you want to survive function call (you can use
+push for that)</p>
+</li>
+<li>
+<p>Store arguments in the relevent register (rdi, rsi, etc).</p>
+</li>
+<li>
+<p>If you return a value from a function, you use xmm0 for floating point values
+and use rax for other values, such as integers or addresses.</p>
+</li>
+<li>
+<p>Restore caller-saved registers stored before the function call.</p>
+</li>
+</ul>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<i class="fa icon-note" title="Note"></i>
+</td>
+<td class="content">
+some system calls also return values - be careful to read the docs!
+</td>
+</tr>
+</table>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_function_related_instructions">Function Related Instructions</h3>
+<div class="dlist">
+<dl>
+<dt class="hdlist1"><code>ret</code></dt>
+<dd>
+<p>Denotes the function end. same as <code>pop rip</code>.</p>
+</dd>
+<dt class="hdlist1"><code>leave</code></dt>
+<dd>
+<p>Is the the same as <code>mov rsp, rbp</code> and <code>pop rbp</code> (the epilogue).</p>
+</dd>
+<dt class="hdlist1"><code>call &lt;address&gt;</code></dt>
+<dd>
+<p>Is the same as <code>push rip</code> and <code>jmp &lt;address&gt;</code></p>
+</dd>
+<dt class="hdlist1"><code>enter 0, 0</code></dt>
+<dd>
+<p>Is the same as <code>push rbp</code> and <code>mov rbp, rsp</code> (the prologue). It
+is said to have poor performance.</p>
+</dd>
+</dl>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_locality">Locality</h3>
+<div class="paragraph">
+<p>Functions can have their own sections, such as <code>.data</code>, <code>.bss</code>, and <code>.text</code>. A
+period before a variable means that variable is local to that function.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_function_types">Function types</h3>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Branch Functions</dt>
+<dd>
+<p>Contain calls to other functions</p>
+</dd>
+<dt class="hdlist1">Leaf Functions</dt>
+<dd>
+<p>Execute some commands and then return to the parent function.</p>
+</dd>
+</dl>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_alignment">Alignment</h3>
+<div class="paragraph">
+<p>The stack has to have 16-byte alignment when you call a function. Inside a leaf
+function, you can in general ignore stack from and stack alignment; it is not
+necessary as long as you don&#8217;t mess with the stack. Similarly, if your function
+does not use SIMD instructions, you do not need to care about alignment.
+Compilers have optimizing functionality, and sometimes when you look at code
+generated by compilers, you will find that there was no stack from used. That
+happens when the compilers noticed during optimization that a stack form is no
+needed. It <strong>IS</strong> a good habit to always include a stack from and check the
+stack alignment; it can save you a lot of trouble later. A good reaason to
+include a stack frome is the fact that GDB and GDB-based debugges (such as DDD
+and SASM) expect to find a stack frame. If there is no stacfk form in your code,
+the debugger will behave unpredictably, such as ignoring breakpoints or jumping
+over instructions.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_syscalls">Syscalls</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>syscall instructions implicitly uses rcx. System calls cannot accept more than
+six arguments.</p>
+</div>
+<div class="paragraph">
+<p>All the syscalls are listed in <em>/usr/include/nasm/unistd.h</em> (or something
+similar), together with their numbers (the value to put in EAX before you call
+int 80h). In ubuntu I found the file in
+<em>/usr/include/x86_64-linux-gnu/asm/unistd_64.h</em>.</p>
+</div>
+<div class="paragraph">
+<p>You can checkout <a href="https://www.man7.org/linux/man-pages/man2/syscalls.2.html">man syscalls</a> on links to lookup a syscall.</p>
+</div>
+<div class="paragraph">
+<p>checkout this <a href="https://hackeradam.com/x86-64-linux-syscalls/">syscall table</a> for
+linux</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_different_addressing_types">Different Addressing types</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_immediate">Immediate</h3>
+<div class="paragraph">
+<p>use the specified value</p>
+</div>
+<div class="paragraph">
+<p>ex.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">mov</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-mi">10</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_register">Register</h3>
+<div class="paragraph">
+<p>Use the value in teh specified register</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">mov</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-nb">rbx</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">mov</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-p">[</span><span class="tok-mi">10</span><span class="tok-p">]</span><span class="tok-c1">; transfers 8 bytes starting at the tenth address into rax</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">mov</span> <span class="tok-nb">r9</span><span class="tok-p">,</span> <span class="tok-mi">10</span>
+<span class="tok-nf">mov</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-p">[</span><span class="tok-nb">r9</span><span class="tok-p">]</span> <span class="tok-c1">; take the address from the register</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_direct_memory">Direct Memory</h3>
+<div class="paragraph">
+<p>Use the value at the specified memory address</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">mov</span> <span class="tok-nb">rdi</span><span class="tok-p">,</span> <span class="tok-mh">0x172</span> <span class="tok-c1">; not 100% sure about this</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_base_indexed_with_scale_and_discplacement">Base-indexed with scale and discplacement</h3>
+<div class="paragraph">
+<p>Most addressing modes are generalized by this mode. The address here is
+calculated based on the following components:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>Address = base + index * scale + displacement</pre>
+</div>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Base is either immediate or a register</p>
+</li>
+<li>
+<p>Scale can only be immediate equal to 1, 2, 4, or 8</p>
+</li>
+<li>
+<p>Index is immediate or a register</p>
+</li>
+<li>
+<p>Displacement is always immediate</p>
+</li>
+</ul>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">mov</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-p">[</span><span class="tok-nb">rbx</span> <span class="tok-o">+</span> <span class="tok-mi">4</span> <span class="tok-o">*</span> <span class="tok-nb">rcx</span> <span class="tok-o">+</span> <span class="tok-mi">9</span><span class="tok-p">]</span>
+<span class="tok-nf">mov</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-p">[</span><span class="tok-mi">4</span> <span class="tok-o">*</span> <span class="tok-nb">r9</span><span class="tok-p">]</span>
+<span class="tok-nf">mov</span> <span class="tok-nb">rdx</span><span class="tok-p">,</span> <span class="tok-p">[</span><span class="tok-nb">rax</span> <span class="tok-o">+</span> <span class="tok-nb">rbx</span><span class="tok-p">]</span>
+<span class="tok-nf">lea</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-p">[</span><span class="tok-nb">rbx</span> <span class="tok-o">+</span> <span class="tok-nb">rbx</span> <span class="tok-o">*</span> <span class="tok-mi">4</span><span class="tok-p">]</span> <span class="tok-c1">; rax = rbx * 5</span>
+<span class="tok-nf">add</span> <span class="tok-nb">r8</span><span class="tok-p">,</span> <span class="tok-p">[</span><span class="tok-mi">9</span> <span class="tok-o">+</span> <span class="tok-nb">rbx</span> <span class="tok-o">*</span> <span class="tok-mi">8</span> <span class="tok-o">+</span> <span class="tok-mi">7</span><span class="tok-p">]</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_endianness">Endianness</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_least_significant_vs_most_significant">Least significant vs Most significant</h3>
+<div class="paragraph">
+<p>This is dependent on the endianness of the system. Most systems are little
+endian meaning that the less significant bits are further the the right. More
+signifacant bits are further to the right.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_text">Text</h3>
+<div class="paragraph">
+<p>This instruction</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>mov rax, [text1]</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>stores <code>text1</code> into rax in little endian mode</p>
+</div>
+<div class="listingblock">
+<div class="title">gdb rax register</div>
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) i r
+rax            0x5452455000636261  6075995057182433889</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>0x61 is a, 0x62 is b, and 0x63 is c.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_change_a_number_from_little_endian_to_big_endian_in_c">Change a number from little endian to big endian in C</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c"><span></span><span class="tok-cp">#include</span><span class="tok-w"> </span><span class="tok-cpf">&lt;stdio.h&gt;</span><span class="tok-cp"></span>
+<span class="tok-cp">#include</span><span class="tok-w"> </span><span class="tok-cpf">&lt;stdlib.h&gt;</span><span class="tok-cp"></span>
+<span class="tok-cp">#include</span><span class="tok-w"> </span><span class="tok-cpf">&lt;arpa/inet.h&gt;</span><span class="tok-cp"></span>
+
+<span class="tok-kt">int</span><span class="tok-w"></span>
+<span class="tok-nf">main</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-p">){</span><span class="tok-w"></span>
+<span class="tok-w">    </span><span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">num</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-mh">0x12345678</span><span class="tok-p">;</span><span class="tok-w"></span>
+<span class="tok-w">    </span><span class="tok-n">printf</span><span class="tok-p">(</span><span class="tok-s">&quot;%x</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">htonl</span><span class="tok-p">(</span><span class="tok-n">num</span><span class="tok-p">));</span><span class="tok-w"></span>
+<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_pointers_and_differnt_addressing_types">Pointers and Differnt Addressing Types</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Pointers are 8 bytes.</p>
+</div>
+<div class="paragraph">
+<p>you need to specify operation size, when trying to write shomewhere a value
+whose size is not specified.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-k">section </span><span class="tok-nv">.data</span>
+    <span class="tok-nl">test:</span> <span class="tok-kd">dq</span> <span class="tok-o">-</span><span class="tok-mi">1</span>
+<span class="tok-k">section </span><span class="tok-nv">.bss</span>
+<span class="tok-k">section </span><span class="tok-nv">.text</span>
+       <span class="tok-k">global </span><span class="tok-nv">main</span>
+<span class="tok-nl">main:</span>
+   <span class="tok-nf">mov</span> <span class="tok-kt">byte</span><span class="tok-p">[</span><span class="tok-nv">test</span><span class="tok-p">],</span> <span class="tok-mi">1</span>
+    <span class="tok-c1">;mov [test], 1 ; gives an error</span>
+   <span class="tok-nf">mov</span> <span class="tok-kt">word</span><span class="tok-p">[</span><span class="tok-nv">test</span><span class="tok-p">],</span> <span class="tok-mi">1</span>
+   <span class="tok-nf">mov</span> <span class="tok-kt">dword</span><span class="tok-p">[</span><span class="tok-nv">test</span><span class="tok-p">],</span> <span class="tok-mi">1</span>
+   <span class="tok-nf">mov</span> <span class="tok-kt">qword</span><span class="tok-p">[</span><span class="tok-nv">test</span><span class="tok-p">],</span> <span class="tok-mi">1</span>
+
+       <span class="tok-nf">mov</span>  <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-mi">60</span>
+       <span class="tok-nf">mov</span> <span class="tok-nb">rdi</span><span class="tok-p">,</span> <span class="tok-mi">0</span>
+       <span class="tok-nf">syscall</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_instructions_2">Instructions</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_neg"><a href="https://www.felixcloutier.com/x86/neg">NEG</a></h3>
+<div class="paragraph">
+<p>The <a href="https://www.felixcloutier.com/x86/neg">NEG</a> instruction applys two complement. It sets the CF falgs to zero if the
+source operand is 0; otherwise it is set to 1.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_imul"><a href="https://www.felixcloutier.com/x86/imul">IMUL</a></h3>
+<div class="paragraph">
+<p>signed multiplication</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">One-operand form</dt>
+<dd>
+<p>secound operand is in AL, AX, EAX, or RAX, depending on the
+size</p>
+</dd>
+<dt class="hdlist1">Two-operand form</dt>
+<dd>
+<p>With this form the destination operand (the first operand) is multiplied by
+the source operand</p>
+</dd>
+<dt class="hdlist1">Three-operand form</dt>
+<dd>
+<p>with <code>mul a, b, c</code>, the multiplication of <code>b</code> and <code>c</code> is
+stored in <code>a</code></p>
+</dd>
+</dl>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_mul"><a href="https://www.felixcloutier.com/x86/mul">MUL</a></h3>
+<div class="paragraph">
+<p>unsigned multiply</p>
+</div>
+<div class="paragraph">
+<p>the source operand is located in either AL, AX, or EAX, dending on the size of
+the operand.</p>
+</div>
+<div class="paragraph">
+<p>The result is stored in RDX:RAX meaning that the lower 64 bits are stored in RAX
+and the upper 64 bits are stored in RDX. This is because the result of two
+numbers can be larger bit size they originaly had.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_sub"><a href="https://www.felixcloutier.com/x86/sub">SUB</a></h3>
+<div class="paragraph">
+<p>subtract source operand from the destination operand and stores the result in
+the destination operand.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>integer subraction; signed and unsigned</p>
+</li>
+<li>
+<p>sets OF flags to indicate an overflow in the signed or unsigned result,
+respectively.</p>
+</li>
+<li>
+<p>The SF flag indicates the sign of the signed result</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>In 64-bit mode the instruction&#8217;s default operation size is 32 bits</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_idiv"><a href="https://www.felixcloutier.com/x86/idiv">IDIV</a></h3>
+<div class="paragraph">
+<p>signed divide. Divides the value in AX, DX:AX, or EDX:EAX (dividend) by the
+source operand (divisor) and stores the result in AX (AH:AL), DX:AX, or EDX:EAX
+registers.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Overflow is indicated withthe #DE (divide error) exception rather than with
+the CF flag</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>The <strong>modulo</strong> can be found in rdx.</p>
+</div>
+<div class="admonitionblock warning">
+<table>
+<tr>
+<td class="icon">
+<i class="fa icon-warning" title="Warning"></i>
+</td>
+<td class="content">
+Remember to set rdx to zero every time before you use idiv or the
+         resulting quotient may be wrong.
+</td>
+</tr>
+</table>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_lea"><a href="https://www.felixcloutier.com/x86/lea">LEA</a></h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">lea</span> <span class="tok-nb">rsi</span><span class="tok-p">,</span> <span class="tok-p">[</span><span class="tok-nv">variable</span><span class="tok-p">]</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>square brackets represent <strong>indirect addressing</strong>.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_div"><a href="https://www.felixcloutier.com/x86/div">DIV</a></h3>
+<div class="paragraph">
+<p>Divids unsigned the value in the AX, DX:AX, EDX:EAX, or RDX:RAX registers
+(dividend) by the source operand (divisor) and stores the result in AX (AH:AL),
+DX:AX, EDX:EAX, or RDX:RAX register</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_test"><a href="https://www.felixcloutier.com/x86/test">TEST</a></h3>
+<div class="paragraph">
+<p>Computes the bit-wise logical AND of first operand (source 1 operand) and the
+second operand (source 2 operand) and sets the SF, ZF, and PF status flags
+according to the result. The result is then discarded.</p>
+</div>
+<div class="paragraph">
+<p>If the result of AND is zero then the ZF flag is set.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_nop"><a href="https://www.felixcloutier.com/x86/nop">NOP</a></h3>
+<div class="paragraph">
+<p>The x86-64 ISA includes several no-op (no operation) instructions, including
+<code>nop</code>, <code>nop A,</code> (no-op with an argument), and <code>data16</code>. No-ops do pretty much
+nothing, but do set the rflags. The main reason for no-ops is to optimize
+instruction memory (e.g., code size, alignment).</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_movsd">MOVSD</h3>
+<div class="paragraph">
+<p>move a double precision floating point value</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_movss">MOVSS</h3>
+<div class="paragraph">
+<p>move a single precision floating point value</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_what_is_the_differnce_between_sar_and_shr">What is the differnce between SAR and SHR?</h3>
+<div class="paragraph">
+<p>SAR sets or clears the most significant bit depending on the sign, While SHR
+just clears the most significant bit.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_whats_the_difference_between_the_cf_flag_and_of_flag">What&#8217;s the difference between the CF flag and OF flag.</h3>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Carry Flag</dt>
+<dd>
+<p>bits that are carried over in <strong>UNSIGNED</strong> integer arithmetic</p>
+</dd>
+<dt class="hdlist1">Overflow Flag</dt>
+<dd>
+<p>bits that are carried over in <strong>SIGNED</strong> integer arithmetic</p>
+</dd>
+</dl>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_nasm_and_gdb">NASM and GDB</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_get_memory_allocated_on_the_heap">Get Memory Allocated On The Heap</h3>
+<div class="paragraph">
+<p>List memory regions mapped by the specified process
+- <a href="https://www.baeldung.com/linux/find-heap-memory-running-process">find-heap-memory-running-process</a></p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) info proc mappings</code></pre>
+</div>
+</div>
+<details>
+<summary class="title">output</summary>
+<div class="content">
+<div class="literalblock">
+<div class="content">
+<pre>(gdb) info proc mappings
+process 56173
+Mapped address spaces:
+          Start Addr           End Addr       Size     Offset  Perms  objfile
+      0x555555554000     0x555555555000     0x1000        0x0  r--p   /usr/local/share/tst/c/tst
+      0x555555555000     0x555555556000     0x1000     0x1000  r-xp   /usr/local/share/tst/c/tst
+      0x555555556000     0x555555557000     0x1000     0x2000  r--p   /usr/local/share/tst/c/tst
+      0x555555557000     0x555555558000     0x1000     0x2000  r--p   /usr/local/share/tst/c/tst
+      0x555555558000     0x555555559000     0x1000     0x3000  rw-p   /usr/local/share/tst/c/tst
+      0x555555559000     0x55555557a000    0x21000        0x0  rw-p   [heap]
+      0x7fffb7d74000     0x7ffff7d78000 0x40004000        0x0  rw-p
+      0x7ffff7d78000     0x7ffff7da0000    0x28000        0x0  r--p   /usr/lib/x86_64-linux-gnu/libc.so.6
+      0x7ffff7da0000     0x7ffff7f35000   0x195000    0x28000  r-xp   /usr/lib/x86_64-linux-gnu/libc.so.6
+      0x7ffff7f35000     0x7ffff7f8d000    0x58000   0x1bd000  r--p   /usr/lib/x86_64-linux-gnu/libc.so.6
+      0x7ffff7f8d000     0x7ffff7f8e000     0x1000   0x215000  ---p   /usr/lib/x86_64-linux-gnu/libc.so.6
+      0x7ffff7f8e000     0x7ffff7f92000     0x4000   0x215000  r--p   /usr/lib/x86_64-linux-gnu/libc.so.6
+      0x7ffff7f92000     0x7ffff7f94000     0x2000   0x219000  rw-p   /usr/lib/x86_64-linux-gnu/libc.so.6
+      0x7ffff7f94000     0x7ffff7fa1000     0xd000        0x0  rw-p
+      0x7ffff7fbb000     0x7ffff7fbd000     0x2000        0x0  rw-p
+      0x7ffff7fbd000     0x7ffff7fc1000     0x4000        0x0  r--p   [vvar]
+      0x7ffff7fc1000     0x7ffff7fc3000     0x2000        0x0  r-xp   [vdso]
+      0x7ffff7fc3000     0x7ffff7fc5000     0x2000        0x0  r--p   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+o.2
+      0x7ffff7fc5000     0x7ffff7fef000    0x2a000     0x2000  r-xp   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+--Type &lt;RET&gt; for more, q to quit, c to continue without paging--
+o.2
+      0x7ffff7fef000     0x7ffff7ffa000     0xb000    0x2c000  r--p   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+o.2
+      0x7ffff7ffb000     0x7ffff7ffd000     0x2000    0x37000  r--p   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+o.2
+      0x7ffff7ffd000     0x7ffff7fff000     0x2000    0x39000  rw-p   /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.s
+o.2
+      0x7ffffffdd000     0x7ffffffff000    0x22000        0x0  rw-p   [stack]
+  0xffffffffff600000 0xffffffffff601000     0x1000        0x0  --xp   [vsyscall]</pre>
+</div>
+</div>
+</div>
+</details>
+<div class="paragraph">
+<p>From the heap memory addresses we can use <code>find</code> to find a string within the heap</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>find 0x555555559000, 0x55555557a000, &#39;h&#39;, &#39;e&#39;, &#39;l&#39;, &#39;l&#39;, &#39;o&#39;, &#39;1&#39;</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_get_type_of">Get type of</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) ptype  0x404034
+type = int</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_breaking_at_local_labels">Breaking at local labels</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>b main.string_size</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_looking_at_flags">Looking at flags</h3>
+<div class="paragraph">
+<p>To get flag values:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>info registers eflags</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>An output like this:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>eflags  0x41  [ CF ZF ]</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>means that the carry and zero flag are set</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_next_instruction">Next instruction</h3>
+<div class="paragraph">
+<p>assembly:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) ni</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>C:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) n</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_steping_into_a_function">Steping into a function</h3>
+<div class="paragraph">
+<p>To step into an assembly function</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) stepi</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>To step into an C function</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) step</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_make_printing_look_nice">Make Printing Look Nice</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) set print pretty</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_get_current_line">Get current line</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) frame</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_break_at_specific_instruction_number">Break at specific instruction number</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span> (gdb) b * 0x0000000000401110</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_flavor">Flavor</h3>
+<div class="paragraph">
+<p>to set dissasembly flavor to intel instead of AT&amp;T:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) set disassembly-flavor intel</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_dissassembly_a_function">Dissassembly a function</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>disassemble &lt;function name&gt;</code></pre>
+</div>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><strong>function name</strong> - can be the name of any function (i.e main)</p>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_finding_immediate_registers_label_values">Finding Immediate / registers / label values</h3>
+<div class="paragraph">
+<p>If you have</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">msg</span> <span class="tok-nv">db</span> <span class="tok-s">&quot;hello, world&quot;</span><span class="tok-p">,</span> <span class="tok-mi">10</span><span class="tok-p">,</span> <span class="tok-mi">0</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In the <code>.data</code> section and use it later with</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">mov</span> <span class="tok-nb">rsi</span><span class="tok-p">,</span> <span class="tok-nv">msg</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The output of <code>(gdb) dissassembly &lt;function name&gt;</code> might look something like
+this</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-err">0</span><span class="tok-nf">x000000000040111a</span> <span class="tok-o">&lt;+</span><span class="tok-mi">10</span><span class="tok-o">&gt;</span><span class="tok-p">:</span>    <span class="tok-nv">movabs</span> <span class="tok-nb">rsi</span><span class="tok-p">,</span><span class="tok-mh">0x404028</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>You can see what is inside the memory address <code>0x404028</code> with</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) x/s 0x404028
+0x404028 &lt;msg&gt;: &quot;hello, world\n&quot;</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>As you can see that is the address is where <code>msg</code> is located</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><strong>get register value</strong> &#8594; <code>(gdb) x/s $rax</code></p>
+</li>
+<li>
+<p><strong>get register value</strong> &#8594; <code>(gdb) p $rax</code></p>
+</li>
+<li>
+<p><strong>get label value</strong> &#8594; <code>(gdb) x/s &amp;codes</code></p>
+</li>
+<li>
+<p><strong>get label value</strong> &#8594; <code>(gdb) p &amp;codes</code></p>
+</li>
+<li>
+<p><strong>x/s</strong> &#8594; output string</p>
+</li>
+<li>
+<p><strong>x/c</strong> &#8594; output character</p>
+</li>
+<li>
+<p><strong>x/13c</strong> &#8594; output 13 characters</p>
+</li>
+<li>
+<p><strong>x/13d</strong> &#8594; output 13 characters in decimal representation</p>
+</li>
+</ul>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<i class="fa icon-note" title="Note"></i>
+</td>
+<td class="content">
+checkout <code>(gdb) help x</code>
+</td>
+</tr>
+</table>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_tui">TUI</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) tui &lt;enable/disable&gt;</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_registers_2">Registers</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) info registers</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_source_code">Source code</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) list &lt;nothing or line number&gt;</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_steping_through_instructions">Steping through Instructions</h3>
+<div class="listingblock">
+<div class="title">next_asm.gdb</div>
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>set language asm
+set disassembly-flavor intel
+define asm_next
+nexti
+disassemble
+end</code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="sh"><span></span>$ gdb -x next_asm.gdb &lt;executable&gt;</code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_step_out_of_function">Step out of function</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) finish</code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_segment_registers">Segment Registers</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Logical addresses can be explicitly specified in *x86 assembly language</p>
+</div>
+<div class="paragraph">
+<p>all segments have a base of zero</p>
+</div>
+<div class="paragraph">
+<p>In protected mode, code may always modify all segment registers except CS (the
+code segment selector). This is because the current privilege level (CPL) of the
+processor is stored in the lower 2 bits of the CS register</p>
+</div>
+<div class="paragraph">
+<p>The only ways to raise the processor privilege level (and reload CS) are through
+the lcall (far call) and int (interrupt) instructions. Similarly, the only ways
+to lower the privilege level (and reload CS) are through lret (far return) and
+iret (interrupt return) instructions. In real mode, code may also modify the CS
+register by making a far jump (or using an undocumented POP CS instruction on
+the 8086 or 8088).[4] Of course, in real mode, there are no privilege levels;
+all programs have absolute unchecked access to all of memory and all CPU
+instructions</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="asm"><span></span><span class="tok-nf">movl</span> <span class="tok-no">$42</span><span class="tok-p">,</span> <span class="tok-nv">%fs</span><span class="tok-p">:(</span><span class="tok-nv">%eax</span><span class="tok-p">)</span>  <span class="tok-c1">; Equivalent to M[fs:eax]&lt;-42) in RTL</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>or in intel syntax</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nf">mov</span> <span class="tok-kt">dword</span> <span class="tok-p">[</span><span class="tok-nb">fs</span><span class="tok-p">:</span><span class="tok-nb">eax</span><span class="tok-p">],</span> <span class="tok-mi">42</span></code></pre>
+</div>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>What data is in each segment</p>
+<div class="ulist">
+<ul>
+<li>
+<p>All CPU instructions are implicitly fetched from the code segment
+specified by the segment selector held in the CS register.</p>
+</li>
+<li>
+<p>Most memory references come from the data segment specified by the segment
+selector held in the DS register. These may also come from the extra
+segment specified by the segment selector held in the ES register, if a
+segment-override prefix precedes the instruction that makes the memory
+reference. Most, but not all, instructions that use DS by default will
+accept an ES override prefix.</p>
+</li>
+<li>
+<p>Processor stack references, either implicitly (e.g. push and pop
+instructions) or explicitly (memory accesses using the (E)SP or (E)BP
+registers) use the stack segment specified by the segment selector held in
+the SS register.</p>
+</li>
+<li>
+<p>String instructions (e.g. stos, movs), along with data segment, also use
+the extra segment specified by the segment selector held in the ES
+register.</p>
+</li>
+<li>
+<p>mov is used to manipulate data, so the address is relative to the data
+segment</p>
+</li>
+</ul>
+</div>
+</li>
+</ul>
+</div>
+<div class="sect2">
+<h3 id="_shdr">SHDR</h3>
+<div class="paragraph">
+<p>From <a href="https://linux.die.net/man/5/elf">man elf</a> we can see that the <code>Elf32_Shdr</code> or <code>Elf32_Shdr</code> structs, can
+contain info about <code>.bss</code>, <code>.data</code>, etc.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_data_segment">Data segment</h3>
+<div class="sect3">
+<h4 id="_example_1">Example 1</h4>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-k">global </span><span class="tok-nv">main</span>
+<span class="tok-k">section </span><span class="tok-nv">.data</span>
+    <span class="tok-nf">bNum</span> <span class="tok-nv">db</span> <span class="tok-mi">123</span>
+<span class="tok-k">section </span><span class="tok-nv">.text</span>
+<span class="tok-nl">main:</span>
+<span class="tok-nf">lea</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-p">[</span><span class="tok-nv">bNum</span><span class="tok-p">]</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="title">gdb disassembly</div>
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span> lea    rax,ds:0x404028</code></pre>
+</div>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">ds</dt>
+<dd>
+<p>data segment</p>
+</dd>
+<dt class="hdlist1">0x404028</dt>
+<dd>
+<p>address of bNum</p>
+</dd>
+</dl>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_compiling_and_linking">Compiling and Linking</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_makefile">Makefile</h3>
+<div class="paragraph">
+<p>The <code>-f</code> is follow by the output format, in our case elf64, which means
+Executable and Linkable Format for 64-bit. The <code>-g</code> mains that we include debug
+information in a debug format specified adter the <code>-F</code> option. We use dwarf
+debug format. The <code>-l</code> tells NASM to generate a <em>.lst</em> file. Nasm will create an
+object file with a <em>.o</em> extension. That object file is used by the linker.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">DWARF</dt>
+<dd>
+<p><strong>D</strong>ebug With <strong>A</strong>rbitrary <strong>R</strong>ecord <strong>F</strong>ormat</p>
+</dd>
+<dt class="hdlist1">STABS</dt>
+<dd>
+<p>Debug with <strong>S</strong>ymbol <strong>Tab</strong>le <strong>S</strong>trings.</p>
+</dd>
+<dt class="hdlist1">elf64</dt>
+<dd>
+<p><strong>E</strong>xecutable and <strong>l</strong>inkable <strong>F</strong>ormat for <strong>64</strong>-bit</p>
+</dd>
+<dt class="hdlist1">PIE</dt>
+<dd>
+<p><strong>P</strong>osition-<strong>I</strong>ndependant <strong>E</strong>xecutables</p>
+</dd>
+</dl>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_modes">Modes</h2>
+<div class="sectionbody">
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Real mode</dt>
+<dd>
+<div class="ulist">
+<ul>
+<li>
+<p>the most ancient, 16-bit</p>
+</li>
+<li>
+<p>Computer is booted into this mode</p>
+</li>
+<li>
+<p>Can access pretty much any memory location</p>
+</li>
+<li>
+<p>No virtual memory</p>
+</li>
+</ul>
+</div>
+</dd>
+<dt class="hdlist1">Protected</dt>
+<dd>
+<div class="ulist">
+<ul>
+<li>
+<p>commonly referred as 32-bit one</p>
+</li>
+<li>
+<p>Virtual memory</p>
+</li>
+<li>
+<p>Protection rings</p>
+</li>
+<li>
+<p>Improved segmentation</p>
+</li>
+</ul>
+</div>
+</dd>
+<dt class="hdlist1">Virtual</dt>
+<dd>
+<div class="ulist">
+<ul>
+<li>
+<p>emulate real mode inside protected</p>
+</li>
+</ul>
+</div>
+</dd>
+<dt class="hdlist1">System management mode</dt>
+<dd>
+<div class="ulist">
+<ul>
+<li>
+<p>for sleep mode, power management, etc</p>
+</li>
+</ul>
+</div>
+</dd>
+<dt class="hdlist1">Long Mode</dt>
+<dd>
+<div class="ulist">
+<ul>
+<li>
+<p>Virtual memory</p>
+</li>
+</ul>
+</div>
+</dd>
+</dl>
+</div>
+<div class="quoteblock">
+<blockquote>
+A 386 CPU can be put back into real mode by clearing a bit in the CR0 control
+register, however this is a privileged operation in order to enforce security
+and robustness
+</blockquote>
+<div class="attribution">
+&#8212; X86_memory_segmentation<br>
+<cite>Wikipedia</cite>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_memory">Memory</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The memory size has a theoretical limit of 2^64 address.</p>
+</div>
+<div class="paragraph">
+<p>If you look at this <em>.lst</em> file you can see the each memory address (second
+column) has 8 hexadecimal digits meaning that there are 64 bits per instruction.
+This is because we are using 64 bit assembler.</p>
+</div>
+<div class="listingblock">
+<div class="title">\.lst file</div>
+<div class="content">
+<pre>    11 00000000 B801000000                  mov rax, 1
+    12 00000005 BF01000000                  mov rdi, 1</pre>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_layout">Layout</h3>
+<div class="paragraph">
+<p>The stack in high memory can grow; it grows in the downward directection toward
+<code>section .bss</code>. The available free memory between the stack and the other
+sections is called the heap.</p>
+</div>
+<div class="paragraph">
+<p>The memory in <code>section .bss</code> is asigned at runtime.</p>
+</div>
+<div class="imageblock">
+<div class="content">
+<img src="diag-ditaa-md5-748c8d76a4b154138a91a12caf43c78a.png" alt="Diagram" width="640" height="364">
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>readelf --symbols ./memory | tail +10 | sort -k 2 -r</code></pre>
+</div>
+</div>
+<details>
+<summary class="title">output</summary>
+<div class="content">
+<div class="literalblock">
+<div class="content">
+<pre>38: 0000000000404090     0 NOTYPE  GLOBAL DEFAULT   23 _end
+23: 0000000000404071     8 OBJECT  LOCAL  DEFAULT   23 qvar
+22: 000000000040405d     2 OBJECT  LOCAL  DEFAULT   23 wvar
+21: 0000000000404059     4 OBJECT  LOCAL  DEFAULT   23 dvar
+20: 0000000000404058     1 OBJECT  LOCAL  DEFAULT   23 bvar
+43: 0000000000404058     0 OBJECT  GLOBAL HIDDEN    22 __TMC_END__
+ 7: 0000000000404054     1 OBJECT  LOCAL  DEFAULT   23 completed.0
+41: 0000000000404051     0 NOTYPE  GLOBAL DEFAULT   23 __bss_start
+32: 0000000000404051     0 NOTYPE  GLOBAL DEFAULT   22 _edata
+19: 000000000040404d     1 OBJECT  LOCAL  DEFAULT   22 text2
+18: 0000000000404045     8 OBJECT  LOCAL  DEFAULT   22 qNum2
+17: 0000000000404041     1 OBJECT  LOCAL  DEFAULT   22 text1
+16: 0000000000404039     8 OBJECT  LOCAL  DEFAULT   22 qNum1
+15: 0000000000404035     4 OBJECT  LOCAL  DEFAULT   22 dNum
+14: 000000000040402b     2 OBJECT  LOCAL  DEFAULT   22 warray
+13: 0000000000404029     2 OBJECT  LOCAL  DEFAULT   22 wNum
+12: 0000000000404028     1 OBJECT  LOCAL  DEFAULT   22 bNum
+36: 0000000000404020     0 OBJECT  GLOBAL HIDDEN    22 __dso_handle
+31: 0000000000404018     0 NOTYPE  WEAK   DEFAULT   22 data_start
+34: 0000000000404018     0 NOTYPE  GLOBAL DEFAULT   22 __data_start
+29: 0000000000404000     0 OBJECT  LOCAL  DEFAULT   21 _GLOBAL_OFFSET_TABLE_
+27: 0000000000403e60     0 OBJECT  LOCAL  DEFAULT   19 _DYNAMIC
+ 8: 0000000000403e58     0 OBJECT  LOCAL  DEFAULT   18 __do_global_dtor[...]
+10: 0000000000403e50     0 OBJECT  LOCAL  DEFAULT   17 __frame_dummy_in[...]
+25: 0000000000402060     0 OBJECT  LOCAL  DEFAULT   16 __FRAME_END__
+28: 0000000000402004     0 NOTYPE  LOCAL  DEFAULT   15 __GNU_EH_FRAME_HDR
+37: 0000000000402000     4 OBJECT  GLOBAL DEFAULT   14 _IO_stdin_used
+33: 0000000000401190     0 FUNC    GLOBAL HIDDEN    13 _fini
+42: 0000000000401110     0 NOTYPE  GLOBAL DEFAULT   12 main
+ 9: 0000000000401100     0 FUNC    LOCAL  DEFAULT   12 frame_dummy
+ 6: 00000000004010d0     0 FUNC    LOCAL  DEFAULT   12 __do_global_dtors_aux
+ 5: 0000000000401090     0 FUNC    LOCAL  DEFAULT   12 register_tm_clones
+ 4: 0000000000401060     0 FUNC    LOCAL  DEFAULT   12 deregister_tm_clones
+39: 0000000000401050     5 FUNC    GLOBAL HIDDEN    12 _dl_relocate_sta[...]
+40: 0000000000401020    38 FUNC    GLOBAL DEFAULT   12 _start
+44: 0000000000401000     0 FUNC    GLOBAL HIDDEN    11 _init
+ 2: 000000000040037c    32 OBJECT  LOCAL  DEFAULT    4 __abi_tag
+35: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
+ 0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
+30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_mai[...]
+11: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS memory.nasm
+24: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
+ 3: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
+ 1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crt1.o
+26: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS</pre>
+</div>
+</div>
+</div>
+</details>
+<div class="ulist">
+<ul>
+<li>
+<p><strong>main</strong>  &#8594; 0x0000000000401110.</p>
+</li>
+<li>
+<p><strong>.bss</strong>  &#8594; 0x0000000000404051</p>
+</li>
+<li>
+<p><strong>.data</strong> &#8594; 0x0000000000404018</p>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_stack">Stack</h3>
+<div class="paragraph">
+<p>The stack segment starts in high memory, and when it grows, it grows in the
+downward direction. Items are placed on the stack with the
+<a href="https://www.felixcloutier.com/x86/push">push</a> instruction and removed from the
+stack with the <a href="https://www.felixcloutier.com/x86/pop">pop</a> instruction. Every
+time you push, the stack grows, every time you pop, the stack shrinks.</p>
+</div>
+<div class="paragraph">
+<p>The stack can be used as temporary storage to save values in registers and call
+them back later or, more importantly, to transfer values to functions.</p>
+</div>
+<div class="paragraph">
+<p>The stack has to have a 16-byte alignment when you call a function. The reason
+for this is that there are SIMD instructions that perform parallel operations on
+larger blocks of data, and these SIMD instructions may require that these data
+are located in memory on addresses that are multiples of 16 bytes.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-k">section </span><span class="tok-nv">.data</span>
+    <span class="tok-nf">string</span> <span class="tok-nv">db</span> <span class="tok-s">&quot;ABCDE&quot;</span><span class="tok-p">,</span> <span class="tok-mi">0</span>
+    <span class="tok-no">stringLen</span><span class="tok-kd"> equ</span> <span class="tok-kc">$</span> <span class="tok-o">-</span> <span class="tok-nv">string</span> <span class="tok-o">-</span> <span class="tok-mi">1</span>
+
+<span class="tok-nl">main:</span>
+    <span class="tok-nf">xor</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-nb">rax</span>
+    <span class="tok-nf">mov</span> <span class="tok-nb">rbx</span><span class="tok-p">,</span> <span class="tok-nv">string</span>
+    <span class="tok-nf">mov</span> <span class="tok-nb">rcx</span><span class="tok-p">,</span> <span class="tok-nv">stringLen</span>
+    <span class="tok-nf">mov</span> <span class="tok-nb">r12</span><span class="tok-p">,</span> <span class="tok-mi">0</span>
+    <span class="tok-nl">pushLoop:</span>
+        <span class="tok-nf">mov</span> <span class="tok-nb">al</span><span class="tok-p">,</span> <span class="tok-kt">byte</span> <span class="tok-p">[</span><span class="tok-nb">rbx</span> <span class="tok-o">+</span> <span class="tok-nb">r12</span><span class="tok-p">]</span>
+        <span class="tok-nf">push</span> <span class="tok-nb">rax</span>
+        <span class="tok-nf">inc</span> <span class="tok-nb">r12</span>
+        <span class="tok-nf">loop</span> <span class="tok-nv">pushLoop</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) i s</code></pre>
+</div>
+</div>
+<details>
+<summary class="title">output</summary>
+<div class="content">
+<div class="literalblock">
+<div class="content">
+<pre>#0  0x000000000040116a in pushLoop ()
+#1  0x0000000000000044 in ?? ()
+#2  0x0000000000000043 in ?? ()
+#3  0x0000000000000042 in ?? ()
+#4  0x0000000000000041 in ?? ()
+#5  0x0000000000000001 in ?? ()
+#6  0x00007ffff7da1d90 in __libc_start_call_main (main=main@entry=0x401130 &lt;main&gt;,
+    argc=1, argc@entry=-10544, argv=0x7fffffffd7e8, argv@entry=0x4)
+    at ../sysdeps/nptl/libc_start_call_main.h:58
+#7  0x00007ffff7da1e40 in __libc_start_main_impl (main=0x401130 &lt;main&gt;, argc=-10544,
+    argv=0x4, init=&lt;optimized out&gt;, fini=&lt;optimized out&gt;, rtld_fini=&lt;optimized out&gt;,
+    stack_end=0x7fffffffd7d8) at ../csu/libc-start.c:392
+#8  0x0000000000401065 in _start ()</pre>
+</div>
+</div>
+</div>
+</details>
+<div class="paragraph">
+<p>Here you can see the stack, and can see 0x0000000000000041 (A),
+0x0000000000000042 (B), 0x0000000000000042 (C), 0x0000000000000043 (D)
+0x0000000000000044 (E), being pushed onto the stack.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_virtual_memory">Virtual Memory</h3>
+<div class="paragraph">
+<p>From <a href="https://linux.die.net/man/5/elf">man elf</a> or <code>info elf</code> we can see that
+<code>e_entry</code> from the <code>ElfN_Ehdr</code> struct gives the virtual address to which the
+system first transfers control.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_what_is_that_d_flag">What is that D Flag</h3>
+<div class="paragraph">
+<p>The "D" flag determines the size of each element in the stack. It can be
+changed, but changing it can result in an unaligned stack if you are not
+careful.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_strings_and_symbol_tables">Strings and Symbol Tables</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>From <a href="https://linux.die.net/man/5/elf">man elf</a> we see that <code>Elf32_Sym</code> or <code>Elf64_Sym</code> can hold these tables.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_elf_file_header">Elf File Header</h2>
+<div class="sectionbody">
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="sh"><span></span>$ readelf --file-header ./memory</code></pre>
+</div>
+</div>
+<details>
+<summary class="title">output</summary>
+<div class="content">
+<div class="literalblock">
+<div class="content">
+<pre>Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
+Class:                             ELF64
+Data:                              2's complement, little endian
+Version:                           1 (current)
+OS/ABI:                            UNIX - System V
+ABI Version:                       0
+Type:                              EXEC (Executable file)
+Machine:                           Advanced Micro Devices X86-64
+Version:                           0x1
+Entry point address:               0x401020
+Start of program headers:          64 (bytes into file)
+Start of section headers:          14520 (bytes into file)
+Flags:                             0x0
+Size of this header:               64 (bytes)
+Size of program headers:           56 (bytes)
+Number of program headers:         13</pre>
+</div>
+</div>
+</div>
+</details>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="gdb"><span></span>(gdb) disass</code></pre>
+</div>
+</div>
+<details>
+<summary class="title">output</summary>
+<div class="content">
+<div class="literalblock">
+<div class="content">
+<pre>Dump of assembler code for function main:
+   0x0000000000401110 &lt;+0&gt;:     push   %rbp
+   0x0000000000401111 &lt;+1&gt;:     mov    %rsp,%rbp
+=&gt; 0x0000000000401114 &lt;+4&gt;:     lea    0x404028,%rax
+   0x000000000040111c &lt;+12&gt;:    movabs $0x404028,%rax
+   0x0000000000401126 &lt;+22&gt;:    mov    0x404028,%rax
+   0x000000000040112e &lt;+30&gt;:    mov    %rax,0x404058
+   0x0000000000401136 &lt;+38&gt;:    lea    0x404058,%rax
+   0x000000000040113e &lt;+46&gt;:    lea    0x404029,%rax
+   0x0000000000401146 &lt;+54&gt;:    mov    0x404029,%rax
+   0x000000000040114e &lt;+62&gt;:    lea    0x404041,%rax
+   0x0000000000401156 &lt;+70&gt;:    movabs $0x404041,%rax
+   0x0000000000401160 &lt;+80&gt;:    movabs $0x404042,%rax
+   0x000000000040116a &lt;+90&gt;:    lea    0x404042,%rax
+   0x0000000000401172 &lt;+98&gt;:    mov    0x404041,%rax
+   0x000000000040117a &lt;+106&gt;:   mov    0x404042,%rax
+   0x0000000000401182 &lt;+114&gt;:   mov    %rbp,%rsp
+   0x0000000000401185 &lt;+117&gt;:   pop    %rbp
+   0x0000000000401186 &lt;+118&gt;:   mov    $0x3c,%eax
+   0x000000000040118b &lt;+123&gt;:   xor    %rdi,%rdi
+   0x000000000040118e &lt;+126&gt;:   syscall</pre>
+</div>
+</div>
+</div>
+</details>
+<div class="paragraph">
+<p>The entry point from <code>readelf</code> is smaller then the entry point from <code>disass</code>.
+This is because their is a header for elf executables.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_numerical">Numerical</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_what_does_the_most_significant_bit_mean_in_numbers">What does the most significant bit mean in numbers?</h3>
+<div class="paragraph">
+<p>It can either be a part of the bit of the number or thing it is trying to
+represent if it is a unsigned number. Or it can represent whether a number is
+"signed" or "unsigned" if it is a signed number.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_single_vs_double_precision">Single vs. Double Precision</h3>
+<div class="paragraph">
+<p>I decimal number has three parts:</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">SIGN</dt>
+<dd>
+<p>Specifies a negitive or positive number, 0 being positive and 1 being
+negative.</p>
+</dd>
+<dt class="hdlist1">EXPONENT</dt>
+<dd>
+<p>Takes the non-decimal version of the number and counts the first bit to the
+right of most signicant on bit all the way to the least significant bit and
+then adds 127 if it is single percision or 1023 if it is double percision.</p>
+</dd>
+<dt class="hdlist1">FRACTION</dt>
+<dd>
+<p>Takes the non-decimal version number and stores the first bit to the right
+of most signicant on bit all the way to the least significant bit.</p>
+</dd>
+</dl>
+</div>
+<div class="paragraph">
+<p>If the exponent part of a single percision number is above 127 it is a positive
+exponent, otherwise it is a negative exponent.</p>
+</div>
+<div class="paragraph">
+<p>If the exponent part of a double percision number is above 1023 it is a positive
+exponent, otherwise it is a negative exponent.</p>
+</div>
+<div class="paragraph">
+<p>A single-precision number is stored in 32 bits: 1 sign bit, 8 exponent bits,
+and 23 fraction bits</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>S   EEEEEEEE   FFFFFFFFFFFFFFFFFFFFFFF
+0   1      8   9                     31</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>A double-percision number is stored in 64-bits: 1 sign bit, 11 exponent bits,
+and 52 fractin bits.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>S  EEEEEEEEEEE   FFFFFFFFFFFFFF...FFFFFFFFFFFFFFF
+0  1         11  12                             63</pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_twos_complement">Two&#8217;s complement</h3>
+<div class="paragraph">
+<p>Two&#8217;s complement is used to represent negative numbers.This is the steps to get
+the negative version of a number.</p>
+</div>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Do a logical not to all the bits</p>
+</li>
+<li>
+<p>add 1</p>
+</li>
+</ol>
+</div>
+<div class="paragraph">
+<p>Binary 4294967296 is zero, anything above this number is positive, anything
+below this is negative.</p>
+</div>
+<div class="paragraph">
+<p>For example, I can convert the number 500 into the negative version of the
+number in c.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c"><span></span><span class="tok-cp">#include</span><span class="tok-w"> </span><span class="tok-cpf">&lt;stdio.h&gt;</span><span class="tok-cp"></span>
+
+<span class="tok-cp">#define NUM 500</span>
+
+<span class="tok-kt">int</span><span class="tok-w"></span>
+<span class="tok-nf">main</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-p">){</span><span class="tok-w"></span>
+<span class="tok-kt">unsigned</span><span class="tok-w"> </span><span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-n">a</span><span class="tok-w"> </span><span class="tok-o">=</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-o">~</span><span class="tok-n">NUM</span><span class="tok-p">)</span><span class="tok-w"> </span><span class="tok-o">+</span><span class="tok-w"> </span><span class="tok-mi">1</span><span class="tok-p">;</span><span class="tok-w"></span>
+<span class="tok-n">printf</span><span class="tok-p">(</span><span class="tok-s">&quot;%d</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">,</span><span class="tok-w"> </span><span class="tok-n">a</span><span class="tok-p">);</span><span class="tok-w"></span>
+<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_checking_if_signed_number_is_negative">Checking if Signed Number is negative</h3>
+<div class="sect3">
+<h4 id="_binary">binary</h4>
+<div class="paragraph">
+<p>check if the most significant bit is 1</p>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_hexidecimal">hexidecimal</h4>
+<div class="paragraph">
+<p>check if lefmost byte is 8, 9, A, B, C D, E, or F. Break number into multiple
+bytes or this will not work. For example 0xd12 would appear to be negative if
+you didn&#8217;t break it up into byte chunks, doing so you get:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>0x0d, 0x12</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>or</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>0x0d &lt;&lt; 8 | 0x12</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Notice how the leftmost byte actually starts with a zero. Also notice how each
+byte is two digits long.</p>
+</div>
+<div class="paragraph">
+<p>you can or bytes together to get the original answer by doing</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>byte4 &lt;&lt; 24 | byte3 &lt;&lt; 16 | byte2 &lt;&lt; 8 | byte1</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In this case I or&#8217;ed together 4 bytes to get a 24 bit number. bitshift right 8,
+16, 24 are offsets; shifting by one byte, two bytes, and then three.</p>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_syntax">Syntax</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="_att_vs_intel_syntax">ATT vs. Intel Syntax</h3>
+<div class="paragraph">
+<p>gdb uses ATT syntax by default, but you can change it to intel (nasm&#8217;s syntax)
+with the command <code>set disassembly-flavor intel</code></p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_strings">Strings</h3>
+<div class="paragraph">
+<p>To explicitly state the length of a string:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-kd">db</span> <span class="tok-mi">27</span><span class="tok-p">,</span> <span class="tok-s">&#39;Selling England by the Pound&#39;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_constant_precomputation">Constant Precomputation</h3>
+<div class="paragraph">
+<p>The math in the code belows is calculated at compile time and turned into a
+constant</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="nasm"><span></span><span class="tok-nl">lab:</span> <span class="tok-kd">db</span> <span class="tok-mi">0</span>
+
+<span class="tok-nf">mov</span> <span class="tok-nb">rax</span><span class="tok-p">,</span> <span class="tok-nv">lab</span> <span class="tok-o">+</span> <span class="tok-mi">1</span> <span class="tok-o">+</span> <span class="tok-mi">2</span> <span class="tok-o">*</span><span class="tok-mi">3</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_books">Books</h2>
+<div class="sectionbody">
+<div class="ulist">
+<ul>
+<li>
+<p>"Learn to Program with Assembly by Jonathan Bartlett"</p>
+<div class="ulist">
+<ul>
+<li>
+<p>learning AT&amp;T syntax with GNU assembler</p>
+</li>
+</ul>
+</div>
+</li>
+<li>
+<p>"Low-Level Programming by Igor Zhirkov"</p>
+<div class="ulist">
+<ul>
+<li>
+<p>intel syntax</p>
+</li>
+</ul>
+</div>
+</li>
+<li>
+<p>"Linkers and Loaders, John R. Levine, 1999, The Morgan Kaufmann Series in
+Sofware Engineering and Programming"</p>
+</li>
+<li>
+<p>"Assembly Language for x86 Processors 6th Edition by Kip R. Irvine"</p>
+</li>
+<li>
+<p>"Beginning x64 Assembly Programming from Novice to AVX Professional by Jo Van
+Hoey"</p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_links">Links</h2>
+<div class="sectionbody">
+<div class="ulist">
+<ul>
+<li>
+<p><a href="https://www.felixcloutier.com/x86/">x86 and amd64 instruction reference</a></p>
+</li>
+<li>
+<p><a href="https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html">intel 64 IA-32 architectures Software Developer&#8217;s Manual</a></p>
+</li>
+<li>
+<p><a href="https://redirect.cs.umbc.edu/portal/help/nasm/nasm.shtml">nasm and gdb</a></p>
+</li>
+<li>
+<p><a href="https://refspecs.linuxfoundation.org/elf/x86_64-abi-0.99.pdf">System V Application Binary Interface AMD64</a></p>
+</li>
+<li>
+<p><a href="https://electronicsreference.com/assembly-language/linux_syscalls/">linux syscalls</a></p>
+</li>
+<li>
+<p><a href="https://blog.packagecloud.io/the-definitive-guide-to-linux-system-calls/">more on linux syscalls</a></p>
+</li>
+<li>
+<p><a href="https://github.com/torvalds/linux/blob/v3.13/arch/x86/syscalls/syscall_32.tbl">linux source code syscall table</a></p>
+</li>
+<li>
+<p><a href="https://stackoverflow.com/questions/15017659/how-to-read-the-intel-opcode-notation">op code notation</a></p>
+</li>
+<li>
+<p><a href="https://stackoverflow.com/questions/10684468/missing-debugging-information-with-gdb-and-nasm">debugging asm_next script nasm and gdb</a></p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_asciidoctor">Asciidoctor</h2>
+<div class="sectionbody">
+<div class="ulist">
+<ul>
+<li>
+<p><a href="https://docs.asciidoctor.org/diagram-extension/latest/diagram_types/bytefield/">bytefield extension</a></p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+</div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2024-04-01 20:31:14 -0400
+</div>
+</div>
+<script type="text/x-mathjax-config">
+MathJax.Hub.Config({
+  messageStyle: "none",
+  tex2jax: {
+    inlineMath: [["\\(", "\\)"]],
+    displayMath: [["\\[", "\\]"]],
+    ignoreClass: "nostem|nolatexmath"
+  },
+  asciimath2jax: {
+    delimiters: [["\\$", "\\$"]],
+    ignoreClass: "nostem|noasciimath"
+  },
+  TeX: { equationNumbers: { autoNumber: "none" } }
+})
+MathJax.Hub.Register.StartupHook("AsciiMath Jax Ready", function () {
+  MathJax.InputJax.AsciiMath.postfilterHooks.Add(function (data, node) {
+    if ((node = data.script.parentNode) && (node = node.parentNode) && node.classList.contains("stemblock")) {
+      data.math.root.display = "block"
+    }
+    return data
+  })
+})
+</script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>
+</body>
+</html>
\ No newline at end of file
diff --git a/endianess.nasm b/endianess.nasm
new file mode 100644 (file)
index 0000000..a7c7b91
--- /dev/null
@@ -0,0 +1,59 @@
+section .data
+    newline_char: db 10
+    codes: db '012345678abcdef'
+    demo1: dq 0x1122334455667788
+    demo2: db 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88
+
+section .text
+
+global main
+
+print_newline:
+    mov rax, 1 ; 'write' syscall identifier
+    mov rdi, 1 ; 'stdout' file descriptor
+    mov rsi, newline_char ; where do we take data from
+    mov rdx, 1 ; the amount of bytes to write
+    syscall
+    ret
+
+print_hex: ; "function"
+    ; there are no Calle-saved registers in this function
+    mov rax, rdi
+    mov rdi, 1
+    mov rdx, 1
+    mov rcx, 64 ; how far are we shifting rax?
+
+iterate: ; this is still part of print_hex function
+    push rax
+    sub rcx, 4
+    sar rax, cl
+
+    and rax, 0xf
+    lea rsi, [codes + rax]
+
+    mov rax, 1
+
+    push rcx
+    syscall
+
+    pop rcx
+    pop rax
+    test rcx, rcx
+    jnz iterate
+
+    ret
+
+main:
+    ; rdi is our one argument
+
+    mov rdi, [demo1]
+    call print_hex
+    call print_newline
+
+    mov rdi, [demo2]
+    call print_hex
+    call print_newline
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/example2-3.nasm b/example2-3.nasm
new file mode 100644 (file)
index 0000000..631adb2
--- /dev/null
@@ -0,0 +1,37 @@
+section .data
+    codes: db '012345678ABCDEF' ; +7 to go to next byte
+
+section .text
+global main
+main:
+    mov rax, 0x1122334455667788
+
+    mov rdi, 1 ; stdout for print instruction
+    mov rdx, 1 ; length of one byte
+    mov rcx, 64
+
+.loop:
+    push rax ; decrements stack and places rax on top of stack
+    ; 4 bits can fit 16 values for our hex number
+    sub rcx, 4
+    sar rax, cl ; cl = 60, 56, 52, 48, 44, etc
+    ;get four most significant bits, shift four, reapeat
+
+    and rax, 0xf ; performs and places result in rax
+                ; rax = 7, 7, 8
+
+    lea rsi, [codes + rax] ; source for stdout
+    mov rax, 1
+
+    push rcx
+    syscall
+    pop rcx ; puts value at top of stack in rcx and increments stack
+            ; puts the old value of rcx before syscall back into rcx
+
+    pop rax ; puts the old value of rax when initialized back into rax
+    test rcx, rcx ;; set flags from anding these
+    jnz .loop
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/false.nasm b/false.nasm
new file mode 100644 (file)
index 0000000..b94f61c
--- /dev/null
@@ -0,0 +1,30 @@
+global main
+section .data
+
+test_string: db "abcdef", 0
+
+section .text
+
+strlen:
+    xor rax, rax
+
+.loop:
+    cmp byte [rdi + rax], 0
+
+    je .end
+
+    inc rax
+
+    jmp .loop
+
+.end:
+    ret
+
+main:
+    mov rdi, test_string ; first arguemnt for strlen function
+    call strlen ; the "return" value for strlen in in rax
+    mov rdi, rax
+
+    mov rax, 60
+    syscall
+
diff --git a/fcalc.nasm b/fcalc.nasm
new file mode 100644 (file)
index 0000000..1cc1e9e
--- /dev/null
@@ -0,0 +1,74 @@
+global main
+extern printf
+
+section .data
+    number1 dq 9.0
+    number2 dq 73.0
+    fmt db "The numbers are %f and %f", 10, 0
+
+    fmtfloat db "%s %f", 10, 0
+    f_sum db "The float sum of %f and %f", 10, 0
+    f_dif db "The float difference of %f and %f is %f", 10, 0
+    f_mul db "The float profuct of %f and %f is %f", 10, 0
+    f_div db "The float division of %f by %f is %f", 10, 0
+    f_sqrt db "The float squareroot of %f is %f", 10, 0
+
+section .text
+
+main:
+    push rbp
+    mov rbp, rsp
+
+    ; print the numbers
+
+    movsd xmm0, [number1]
+    movsd xmm1, [number2]
+    mov rdi, fmt
+    mov rax, 2 ; two floats
+    call printf
+
+    ; sum
+    movsd xmm2, [number1] ; double percision float into xmm
+    addsd xmm2, [number2] ; add double percision to xmm
+
+    ; print the result
+    movsd xmm0, [number1]
+    movsd xmm1, [number2]
+    mov rdi, f_sum
+    mov rax, 3 ;three floats
+    call printf
+
+    ; difference
+    movsd xmm2, [number1] ; double percision float into xmm
+    subsd xmm2, [number2] ; subtract from xmm
+    ; print the result
+    movsd xmm0, [number1]
+    movsd xmm1, [number2]
+    mov rdi, f_dif
+    mov rax, 3
+    call printf
+
+    ;division
+    movsd xmm2, [number1] ; double precision float into xmm
+    divsd xmm2, [number2] ; divide xmm0
+    ; print the result
+    mov rdi, f_div
+    movsd xmm0, [number1]
+    movsd xmm1, [number2]
+    mov rax, 1 ; one float
+    call printf
+
+    ; squareroot
+    sqrtsd xmm1, [number1]
+    ; print the result
+    mov rdi, f_sqrt
+    movsd xmm0, [number1]
+    mov rax, 2 ; two floats
+    call printf
+
+    mov rsp, rbp
+    pop rbp
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/function4.nasm b/function4.nasm
new file mode 100644 (file)
index 0000000..e8be249
--- /dev/null
@@ -0,0 +1,76 @@
+extern printf
+extern c_area
+extern c_circum
+extern r_area
+extern r_circum
+
+global pi
+global main
+
+section .data
+    pi dq 3.141592654
+    radius dq 10.0
+    side1 dq 4
+    side2 dq 5
+    fmtf db "%s %f", 10, 0
+    fmti db "%s %d", 10, 0
+    ca db "The circle area is ", 0
+    cc db "The circle circumference is ", 0
+    ra db "The rectangle area is ", 0
+    rc db "The rectangle circumference is ", 0
+
+section .bss
+
+section .text
+main:
+    push rbp
+    mov rbp, rsp
+    ; circle area
+    movsd xmm0, qword [radius] ; radius xmm0 argument
+    call c_area ; area returned in xmm0
+    ; print the circle area
+    mov rdi, fmtf
+    mov rsi, ca
+    mov rax, 1
+    call printf
+
+    ;circle circumference
+    movsd xmm0, qword [radius] ; radius xmm0 argument
+    call c_circum ; circumference in xmm0
+    ; print the circle circumference
+    mov rdi, fmtf
+    mov rsi, cc
+    mov rax, 1
+    call printf
+
+    ; rectangle area
+    mov rdi, [side1]
+    mov rsi, [side2]
+    call r_area
+
+    ; print the rectangle area
+    mov rdi, fmti
+    mov rsi, ra
+    mov rdx, rax
+    mov rax, 0
+    call printf
+
+    ; rectangle circumference
+    mov rdi, [side1]
+    mov rsi, [side2]
+    call r_circum
+
+    ; print the rectangle circumference
+
+    mov rdi, fmti
+    mov rsi, rc
+    mov rdx, rax
+    mov rax, 0
+    call printf
+
+    mov rsp, rbp
+    pop rbp
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/function_test1.nasm b/function_test1.nasm
new file mode 100644 (file)
index 0000000..0a05cfa
--- /dev/null
@@ -0,0 +1,58 @@
+global main
+extern printf
+
+section .data
+    radius dq 10.0
+
+section .bss
+
+section .text
+
+area:
+section .data
+    .pi dq 3.141592654 ; local to area
+section .text
+    push rbp
+    mov rbp, rsp
+    movsd xmm0, [radius]
+    mulsd xmm0, [radius]
+    mulsd xmm0, [.pi]
+    leave
+    ret
+
+circum:
+section .data
+    .pi dq 3.14 ; local to circum
+section .text
+    push rbp
+    mov rbp, rsp
+    movsd xmm0, [radius]
+    addsd xmm0, [radius]
+    mulsd xmm0, [.pi]
+    leave
+    ret
+
+circle:
+section .data
+    .fmt_area db "The area is %f",10, 0
+    .fmt_circum db "The circumference if %f",10, 0
+section .text
+    push rbp
+    mov rbp, rsp
+    call area
+    mov rdi, .fmt_area
+    mov rax, 1 ; area in xmm0
+    call printf
+    call circum
+    mov rdi, .fmt_circum
+    mov rax, 1 ; circumference in xmm0
+    call printf
+    leave
+    ret
+
+main:
+    push rbp
+    mov rbp, rsp
+    call circle
+    leave
+    ret
diff --git a/hello_world.nasm b/hello_world.nasm
new file mode 100644 (file)
index 0000000..11d7048
--- /dev/null
@@ -0,0 +1,14 @@
+section .data
+       msg db "hello, world", 10, 0
+section .bss
+section .text
+       global main
+main:
+       mov rax, 1
+       mov rdi, 1
+       mov rsi, msg 
+       mov rdx, 13
+       syscall
+       mov  rax, 60
+       mov rdi, 0 
+       syscall
diff --git a/icalc.nasm b/icalc.nasm
new file mode 100644 (file)
index 0000000..4b55dc0
--- /dev/null
@@ -0,0 +1,56 @@
+global main
+extern printf
+
+section .data
+
+    number1 dq 128
+    number2 dq 19
+    neg_num dq -12
+    fmt db "The numbers are %ld and %ld", 10, 0
+    fmtint db "%s %ld", 10, 0
+    sumi db "The sum is", 0
+    difi db "The difference is", 0
+    inci db "Number 1 Incremented:", 0
+    deci db "Number 1 Decremented:", 0
+    sali db "Number 1 Shift left 2 (x4):", 0
+    sari db "Number 1 Shift right 2 (/4):", 0
+    sariex db "Number 1 Shift right 2 (/4) with"
+           db "sign extension:", 0
+    multi db "The product is", 0
+    divi db "The integer quotient is", 0
+    remi db "The modulo is", 0
+
+section .bss
+    resulti resq 1
+    modulo resq 2
+
+section .text
+
+main:
+    push rbp ; function prologe
+    mov rbp, rsp ; function prologe
+
+; displaying the numbers
+    mov rdi, fmt
+    mov rsi, [number1]
+    mov rdx, [number2]
+    mov rax, 0
+    call printf
+
+; adding -------------------------------
+
+    mov rax, [number1]
+    add rax, [number2]
+
+    mov rdi, fmtint
+    mov rsi, sumi 
+    mov rdx, [resulti] 
+    mov rax, 0
+    call printf
+
+    mov rsp, rbp ; function epiloge
+    pop rbp ; function epiloge
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/inline_assembly.c b/inline_assembly.c
new file mode 100644 (file)
index 0000000..e6fccfe
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(void){
+    unsigned int syscall_nr = 1;
+    int exit_status = 42;
+
+  asm (
+    "movl %0, %%eax\n"
+    "movl %1, %%ebx\n"
+    "int $0x80"
+    : /* output parameters, we aren't outputting anything, no none */
+      /* (none) */
+    : /* input parameters mapped to %0 and %1, repsectively */
+    "m" (syscall_nr), "m" (exit_status)
+    : /* registers that we are "clobbering", unneeded since we are calling exit */
+      "eax", "ebx"
+    );
+
+}
diff --git a/loop.nasm b/loop.nasm
new file mode 100644 (file)
index 0000000..22c5f83
--- /dev/null
+++ b/loop.nasm
@@ -0,0 +1,36 @@
+extern printf 
+
+section .data
+       fmt: db "number: %d", 10, 0
+section .bss
+    var resq 1
+
+section .text
+       global main
+main:
+       push rbp    ; push function prologe
+       mov rbp, rsp ; push function prologe
+
+    xor rcx, rcx
+    mov [var], rcx
+
+loop:
+    mov rdi, fmt
+    mov rsi, [var]
+    mov rax, 0
+       call printf
+
+    mov rcx, [var]
+    inc rcx
+    mov [var], rcx
+
+    cmp rcx, 12
+
+    jl loop
+
+       mov rsp, rbp ; pop function prologe
+       pop rbp      ; pop function prologe
+
+       mov  rax, 60
+       mov rdi, 0 
+       syscall
diff --git a/memory.nasm b/memory.nasm
new file mode 100644 (file)
index 0000000..2f98317
--- /dev/null
@@ -0,0 +1,45 @@
+global main
+
+section .data
+   bNum db 123
+   wNum dw 12345
+   warray times 5 dw 0
+
+   dNum dd 12345
+   qNum1 dq 12345
+   text1 db "abc", 0
+   qNum2 dq 3.141592654
+   text2 db "cde", 0
+
+section .bss
+    bvar resb 1
+    dvar resd 1
+    wvar resw 10
+    qvar resq 3
+
+section .text
+
+main:
+    push rbp
+    mov rbp, rsp
+
+    lea rax, [bNum]
+    mov rax, bNum ;; effectively the same as above
+    mov rax, [bNum]
+    mov [bvar], rax ; because rax is bigger than bvar, this can cause issues
+    lea rax, [bvar]
+    lea rax, [wNum]
+    mov rax, [wNum]
+    lea rax, [text1]
+    mov rax, text1
+    mov rax, text1 + 1
+    lea rax, [text1 + 1]
+    mov rax, [text1]
+    mov rax, [text1 + 1]
+
+    mov rsp, rbp
+    pop rbp
+    
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/print_call.nasm b/print_call.nasm
new file mode 100644 (file)
index 0000000..01ef23b
--- /dev/null
@@ -0,0 +1,51 @@
+section .data
+    newline_char: db 10
+    codes: db '012345678abcdef' ; what 9?
+
+section .text
+
+global main
+
+print_newline:
+    mov rax, 1 ; 'write' syscall identifier
+    mov rdi, 1 ; 'stdout' file descriptor
+    mov rsi, newline_char ; where do we take data from
+    mov rdx, 1 ; the amount of bytes to write
+    syscall
+    ret
+
+print_hex: ; "function"
+    ; there are no Calle-saved registers in this function
+    mov rax, rdi
+    mov rdi, 1
+    mov rdx, 1
+    mov rcx, 64 ; how far are we shifting rax?
+
+iterate: ; this is still part of print_hex function
+    push rax
+    sub rcx, 4
+    sar rax, cl
+
+    and rax, 0xf
+    lea rsi, [codes + rax]
+
+    mov rax, 1
+
+    push rcx
+    syscall
+
+    pop rcx
+    pop rax
+    test rcx, rcx
+    jnz iterate
+
+    ret
+
+main:
+    mov rdi, 0x1122334455667788
+    call print_hex
+    call print_newline
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/printf.nasm b/printf.nasm
new file mode 100644 (file)
index 0000000..1a187d7
--- /dev/null
@@ -0,0 +1,23 @@
+extern printf 
+
+section .data
+       fmt: db "number: %d", 10, 0
+
+section .text
+    global main
+
+main:
+       push rbp    ; push function prologe
+       mov rbp,rsp ; push function prologe
+
+    mov rdi, fmt
+    mov rsi, 12
+    mov rax, 0
+       call printf
+
+       mov rsp, rbp ; pop function prologe
+       pop rbp      ; pop function prologe
+
+       mov  rax, 60     ; 60 = exit
+       mov rdi, 0       ; 0 = success exit code
+       syscall          ; quit
diff --git a/question_print_int.nasm b/question_print_int.nasm
new file mode 100644 (file)
index 0000000..8f8d91b
--- /dev/null
@@ -0,0 +1,74 @@
+; QUESTIONS:
+; - what is EDX:EAX ? I though the colon just represented offset
+; - why does syscall change rcx ?
+
+section .data
+    codes: db '0123456789'
+    temp: times 10 db 0
+
+section .text
+
+global main
+
+; one argument of rdi
+print_int: ; function
+    push rbx
+    xor rcx, rcx
+.loop:
+    ; modulo
+    xor rdx, rdx
+    mov rax, rdi ; dividend (top)
+    mov rbx, 10 ; divisor (bottom)
+    div rbx
+    mul rbx ; rax * rbx, result i n edx:rax
+    mov rbx, rdi
+    sub rbx, rax ; answer in rbx
+
+    ; store value 1 btyte of `codes` somewhere in temp
+    mov rax, [codes + rbx]
+    mov qword [temp + rcx], rax
+    inc rcx
+
+    ; keep dividing by 10
+    xor rdx, rdx
+    mov rax, rdi ; dividend (top)
+    mov rdi, 10 ; divisor (bottom)
+    div rdi 
+    mov rdi, rax ; result in rdi
+
+    test rdi, rdi
+    jnz .loop
+
+.reverse:
+    dec rcx
+
+    push rcx
+    lea rax, [temp + rcx]
+    mov rsi, rax
+    
+    mov rax, 1 ; 'write' syscall
+    mov rdi, 1 ; stdout file description
+
+    mov rdx, 1
+    syscall ; syscall must change rcx in some way
+
+    pop rcx
+    test rcx, rcx
+    jnz .reverse
+
+    mov rax, 1 ; 'write' syscall
+    mov rdi, 1 ; stdout file description
+    mov rsi, 10
+    mov rdx, 1
+    syscall
+
+    pop rbx
+    ret
+
+main:
+    mov rdi, 5495
+    call print_int
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/question_print_int_new.nasm b/question_print_int_new.nasm
new file mode 100644 (file)
index 0000000..436da7b
--- /dev/null
@@ -0,0 +1,76 @@
+; QUESTIONS:
+; - why does syscall change rcx ?
+
+section .data
+    codes: db '0123456789'
+    temp: times 10 db 0
+
+section .text
+
+global main
+
+; one argument of rdi
+print_int: ; function
+    push rbx
+    xor rcx, rcx
+.loop:
+    ; modulo
+    xor rdx, rdx ; clear rdx to clear junk data
+    mov rax, rdi ; dividend (top)
+    mov rbx, 10 ; divisor (bottom)
+    div rbx ; result in RDX:RAX, modulo of division in rdx
+
+    ; store value 1 btyte of `codes` somewhere in temp
+    mov rax, [codes + rdx]
+    mov qword [temp + rcx], rax
+    inc rcx
+
+    ; keep dividing by 10
+    xor rdx, rdx
+    mov rax, rdi ; dividend (top)
+    mov rdi, 10 ; divisor (bottom)
+    div rdi 
+    mov rdi, rax ; result in rdi
+
+    test rdi, rdi
+    jnz .loop
+
+
+.reverse:
+    lea rax, [temp + rcx - 1]
+    mov rsi, rax
+    
+    mov rax, 1 ; 'write' syscall
+    mov rdi, 1 ; stdout file description
+    mov rdx, 1 ; 1 byte long
+
+    push rcx
+    syscall ; syscall must change rcx in some way
+    pop rcx
+
+    loop .reverse
+
+    xor rcx, rcx
+
+    mov rax, 1 ; 'write' syscall
+    mov rdi, 1 ; stdout file description
+    mov rsi, 10
+    mov rdx, 1
+    syscall
+
+    pop rbx
+    ret
+
+main:
+    push rbp
+    mov rbp, rsp
+
+    mov rdi, 5495
+    call print_int
+
+    mov rsp, rbp
+    pop rbp
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/rect.nasm b/rect.nasm
new file mode 100644 (file)
index 0000000..c53b998
--- /dev/null
+++ b/rect.nasm
@@ -0,0 +1,31 @@
+global r_circum
+global r_area
+
+section .data
+section .bss
+section .text
+
+r_area:
+    section .text
+    push rbp
+    mov rbp, rsp
+
+    mov rax, rsi
+    imul rax, rdi
+    mov rsp, rbp
+
+    pop rbp
+    ret
+
+r_circum:
+    section .text
+    push rbp
+    mov rbp, rsp
+
+    mov rax, rsi
+    add rax, rdi
+    add rax, rax
+
+    mov rsp, rbp
+    pop rbp
+    ret
diff --git a/stack.nasm b/stack.nasm
new file mode 100644 (file)
index 0000000..9f9888f
--- /dev/null
@@ -0,0 +1,61 @@
+global main
+extern printf
+
+section .data
+    string db "ABCDE", 0
+    stringLen equ $ - string - 1
+    fmt1 db "The original string: %s", 10, 0
+    fmt2 db "The reversed string: %s", 10, 0
+
+section .bss
+
+section .text
+main:
+    push rbp
+    mov rbp, rsp
+
+    ; print the original string
+    mov rdi, fmt1
+    mov rsi, string
+    mov rax, 0
+    call printf
+
+    ; push the stirng char per char on the stack
+    xor rax, rax
+    mov rbx, string
+    mov rcx, stringLen
+    mov r12, 0
+
+    pushLoop:
+        mov al, byte [rbx + r12]
+        push rax
+        inc r12
+        loop pushLoop
+
+    ; pop the string char per char from the stack
+    ; this will reverse the original string
+
+    mov rbx, string
+    mov rcx, stringLen
+    mov r12, 0
+
+    popLoop:
+        pop rax
+        mov byte [rbx + r12], al
+        inc r12
+        loop popLoop
+
+    mov byte [rbx + r12], 0 ; terminate string with 0
+
+    ; Print the reversed string
+    mov rdi, fmt2
+    mov rsi, string
+    mov rax, 0
+    call printf
+
+    mov rsp, rbp
+    pop rbp
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/strlen.nasm b/strlen.nasm
new file mode 100644 (file)
index 0000000..5e0e922
--- /dev/null
@@ -0,0 +1,29 @@
+global main
+
+section .data
+test_string: db "abcdef", 0
+
+section .text
+
+strlen:
+    xor rax, rax
+.loop:
+    cmp byte [rdi + rax], 0
+
+    je .end
+
+    inc rax
+
+    jmp .loop
+
+.end:
+    ret
+
+main:
+    mov rdi, test_string ; first arguemnt for strlen function
+    call strlen ; the "return" value for strlen in in rax
+    mov rdi, rax
+
+    mov rax, 60
+    syscall
+
diff --git a/tst.nasm b/tst.nasm
new file mode 100644 (file)
index 0000000..e992177
--- /dev/null
+++ b/tst.nasm
@@ -0,0 +1,32 @@
+section .data
+    codes: db '012345678ABCDEF'
+
+section .text
+global main
+main:
+    mov rax, 0x01122334455667788
+
+    mov rdi, 1
+    mov rdx, 1
+    mov rcx, 64
+
+.loop:
+    push rax
+    sub rcx, 4
+    sar rax, cl
+    and rax, 0xf
+
+    lea rsi, [codes + rax]
+    mov rax, 1
+
+    push rcx
+    syscall
+    pop rcx
+
+    pop rax
+    test rcx, rcx
+    jnz .loop
+
+    mov rax, 60
+    xor rdi, rdi
+    syscall
diff --git a/write_number.nasm b/write_number.nasm
new file mode 100644 (file)
index 0000000..7378867
--- /dev/null
@@ -0,0 +1,23 @@
+extern printf 
+
+section .data
+       fmt: db "number %d", 10, 0
+    thing: dq 88
+section .bss
+section .text
+       global main
+main:
+       push rbp    ; push function prologe
+       mov rbp,rsp ; push function prologe
+
+    mov rdi, fmt
+    mov rsi, [thing]
+    mov rax, 0
+       call printf
+
+       mov rsp, rbp ; pop function prologe
+       pop rbp      ; pop function prologe
+
+       mov  rax, 60
+       mov rdi, 0 
+       syscall