fix other mandelbrot variants
[mu.git] / html / linux / ex12.subx.html
blob36401e8d3c1315b45fe979036eaccadb8715cb60
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5 <title>Mu - linux/ex12.subx</title>
6 <meta name="Generator" content="Vim/8.1">
7 <meta name="plugin-version" content="vim8.1_v1">
8 <meta name="syntax" content="none">
9 <meta name="settings" content="number_lines,use_css,no_foldcolumn,expand_tabs,line_ids,prevent_copy=">
10 <meta name="colorscheme" content="minimal-light">
11 <style type="text/css">
12 <!--
13 pre { font-family: monospace; color: #000000; background-color: #ffffd7; }
14 body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; }
15 a { color:inherit; }
16 * { font-size:12pt; font-size: 1em; }
17 .subxComment { color: #005faf; }
18 .subxS2Comment { color: #8a8a8a; }
19 .LineNr { }
20 .subxS1Comment { color: #0000af; }
21 .SpecialChar { color: #d70000; }
22 .Normal { color: #000000; background-color: #ffffd7; padding-bottom: 1px; }
23 -->
24 </style>
26 <script type='text/javascript'>
27 <!--
29 /* function to open any folds containing a jumped-to line before jumping to it */
30 function JumpToLine()
32 var lineNum;
33 lineNum = window.location.hash;
34 lineNum = lineNum.substr(1); /* strip off '#' */
36 if (lineNum.indexOf('L') == -1) {
37 lineNum = 'L'+lineNum;
39 var lineElem = document.getElementById(lineNum);
40 /* Always jump to new location even if the line was hidden inside a fold, or
41 * we corrected the raw number to a line ID.
43 if (lineElem) {
44 lineElem.scrollIntoView(true);
46 return true;
48 if ('onhashchange' in window) {
49 window.onhashchange = JumpToLine;
52 -->
53 </script>
54 </head>
55 <body onload='JumpToLine();'>
56 <a href='https://github.com/akkartik/mu/blob/main/linux/ex12.subx'>https://github.com/akkartik/mu/blob/main/linux/ex12.subx</a>
57 <pre id='vimCodeElement'>
58 <span id="L1" class="LineNr"> 1 </span><span class="subxComment"># Example showing mmap syscall.</span>
59 <span id="L2" class="LineNr"> 2 </span><span class="subxComment"># Create a new segment using mmap, save the address, write to it.</span>
60 <span id="L3" class="LineNr"> 3 </span><span class="subxComment">#</span>
61 <span id="L4" class="LineNr"> 4 </span><span class="subxComment"># To run:</span>
62 <span id="L5" class="LineNr"> 5 </span><span class="subxComment"># $ bootstrap/bootstrap translate ex12.subx -o ex12</span>
63 <span id="L6" class="LineNr"> 6 </span><span class="subxComment"># $ bootstrap/bootstrap run ex12</span>
64 <span id="L7" class="LineNr"> 7 </span><span class="subxComment"># You shouldn't get a segmentation fault.</span>
65 <span id="L8" class="LineNr"> 8 </span>
66 <span id="L9" class="LineNr"> 9 </span>== code
67 <span id="L10" class="LineNr">10 </span><span class="subxComment"># instruction effective address register displacement immediate</span>
68 <span id="L11" class="LineNr">11 </span><span class="subxS1Comment"># . op subop mod rm32 base index scale r32</span>
69 <span id="L12" class="LineNr">12 </span><span class="subxS1Comment"># . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes</span>
70 <span id="L13" class="LineNr">13 </span>
71 <span id="L14" class="LineNr">14 </span><span class="SpecialChar">Entry</span>:
72 <span id="L15" class="LineNr">15 </span> <span class="subxComment"># mmap(Mmap-new-segment-&gt;len)</span>
73 <span id="L16" class="LineNr">16 </span> bb/copy-to-ebx <span class="SpecialChar"><a href='ex12.subx.html#L29'>Mmap-new-segment</a></span>/imm32
74 <span id="L17" class="LineNr">17 </span> e8/call <a href='000init.subx.html#L71'>syscall_mmap</a>/disp32
75 <span id="L18" class="LineNr">18 </span>
76 <span id="L19" class="LineNr">19 </span> <span class="subxComment"># write to *eax to check that we have access to the newly-allocated segment</span>
77 <span id="L20" class="LineNr">20 </span> c7 0/subop/copy 0/mod/direct 0/rm32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0x34/imm32 <span class="subxComment"># copy to *eax</span>
78 <span id="L21" class="LineNr">21 </span>
79 <span id="L22" class="LineNr">22 </span> <span class="subxComment"># exit(eax)</span>
80 <span id="L23" class="LineNr">23 </span> 89/copy 3/mod/direct 3/rm32/ebx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/eax <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy eax to ebx</span>
81 <span id="L24" class="LineNr">24 </span> e8/call <a href='000init.subx.html#L18'>syscall_exit</a>/disp32
82 <span id="L25" class="LineNr">25 </span>
83 <span id="L26" class="LineNr">26 </span>== data
84 <span id="L27" class="LineNr">27 </span>
85 <span id="L28" class="LineNr">28 </span><span class="subxComment"># various constants used here were found in the Linux sources (search for file mman-common.h)</span>
86 <span id="L29" class="LineNr">29 </span><span class="SpecialChar">Mmap-new-segment</span>: <span class="subxComment"># type mmap_arg_struct</span>
87 <span id="L30" class="LineNr">30 </span> <span class="subxComment"># addr</span>
88 <span id="L31" class="LineNr">31 </span> 0/imm32
89 <span id="L32" class="LineNr">32 </span> <span class="subxComment"># len</span>
90 <span id="L33" class="LineNr">33 </span> 0x100/imm32
91 <span id="L34" class="LineNr">34 </span> <span class="subxComment"># protection flags</span>
92 <span id="L35" class="LineNr">35 </span> 3/imm32 <span class="subxComment"># PROT_READ | PROT_WRITE</span>
93 <span id="L36" class="LineNr">36 </span> <span class="subxComment"># sharing flags</span>
94 <span id="L37" class="LineNr">37 </span> 0x22/imm32 <span class="subxComment"># MAP_PRIVATE | MAP_ANONYMOUS</span>
95 <span id="L38" class="LineNr">38 </span> <span class="subxComment"># fd</span>
96 <span id="L39" class="LineNr">39 </span> -1/imm32 <span class="subxComment"># since MAP_ANONYMOUS is specified</span>
97 <span id="L40" class="LineNr">40 </span> <span class="subxComment"># offset</span>
98 <span id="L41" class="LineNr">41 </span> 0/imm32 <span class="subxComment"># since MAP_ANONYMOUS is specified</span>
99 <span id="L42" class="LineNr">42 </span>
100 <span id="L43" class="LineNr">43 </span><span class="subxS2Comment"># . . vim&#0058;nowrap:textwidth=0</span>
101 </pre>
102 </body>
103 </html>
104 <!-- vim: set foldmethod=manual : -->