diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-06-12 07:57:27 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-06-12 07:57:38 -0700 |
commit | 86351aafe218a7386f6578be3c4da3edcdcb0c98 (patch) | |
tree | 209e27b8ad7ed2a8f733c699b278d19d0f59bf43 /html/apps/ex11.subx.html | |
parent | 07dba48f13be2aaa531b3d75a7d48d36e6ab4cb1 (diff) | |
download | mu-86351aafe218a7386f6578be3c4da3edcdcb0c98.tar.gz |
6513
Diffstat (limited to 'html/apps/ex11.subx.html')
-rw-r--r-- | html/apps/ex11.subx.html | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/html/apps/ex11.subx.html b/html/apps/ex11.subx.html index 275a594b..c06d6fe0 100644 --- a/html/apps/ex11.subx.html +++ b/html/apps/ex11.subx.html @@ -15,15 +15,15 @@ body { font-size:12pt; font-family: monospace; color: #000000; background-color: a { color:inherit; } * { font-size:12pt; font-size: 1em; } .subxComment { color: #005faf; } +.subxS2Comment { color: #8a8a8a; } +.subxTest { color: #5f8700; } .subxFunction { color: #af5f00; text-decoration: underline; } .LineNr { } .subxS1Comment { color: #0000af; } -.subxTest { color: #5f8700; } .SpecialChar { color: #d70000; } .Normal { color: #000000; background-color: #c6c6c6; padding-bottom: 1px; } .subxMinorFunction { color: #875f5f; } .Constant { color: #008787; } -.subxS2Comment { color: #8a8a8a; } .subxH1Comment { color: #005faf; text-decoration: underline; } --> </style> @@ -60,12 +60,12 @@ if ('onhashchange' in window) { <body onload='JumpToLine();'> <a href='https://github.com/akkartik/mu/blob/master/apps/ex11.subx'>https://github.com/akkartik/mu/blob/master/apps/ex11.subx</a> <pre id='vimCodeElement'> -<span id="L1" class="LineNr"> 1 </span><span class="subxComment"># Null-terminated vs length-prefixed ascii strings.</span> +<span id="L1" class="LineNr"> 1 </span><span class="subxComment"># Null-terminated vs size-prefixed ascii strings.</span> <span id="L2" class="LineNr"> 2 </span><span class="subxComment">#</span> -<span id="L3" class="LineNr"> 3 </span><span class="subxComment"># By default we create strings with a 4-byte length prefix rather than a null suffix.</span> +<span id="L3" class="LineNr"> 3 </span><span class="subxComment"># By default we create strings with a 4-byte size prefix rather than a null suffix.</span> <span id="L4" class="LineNr"> 4 </span><span class="subxComment"># However we still need null-prefixed strings when interacting with the Linux</span> <span id="L5" class="LineNr"> 5 </span><span class="subxComment"># kernel in a few places. This layer implements a function for comparing</span> -<span id="L6" class="LineNr"> 6 </span><span class="subxComment"># a null-terminated 'kernel string' with a length-prefixed 'SubX string'.</span> +<span id="L6" class="LineNr"> 6 </span><span class="subxComment"># a null-terminated 'kernel string' with a size-prefixed 'SubX string'.</span> <span id="L7" class="LineNr"> 7 </span><span class="subxComment">#</span> <span id="L8" class="LineNr"> 8 </span><span class="subxComment"># To run:</span> <span id="L9" class="LineNr"> 9 </span><span class="subxComment"># $ ./bootstrap translate init.linux apps/ex11.subx -o apps/ex11</span> @@ -87,11 +87,11 @@ if ('onhashchange' in window) { <span id="L25" class="LineNr"> 25 </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> <span id="L26" class="LineNr"> 26 </span> e8/call syscall_exit/disp32 <span id="L27" class="LineNr"> 27 </span> -<span id="L28" class="LineNr"> 28 </span><span class="subxComment"># compare a null-terminated ascii string with a more idiomatic length-prefixed byte array</span> +<span id="L28" class="LineNr"> 28 </span><span class="subxComment"># compare a null-terminated ascii string with a more idiomatic size-prefixed byte array</span> <span id="L29" class="LineNr"> 29 </span><span class="subxComment"># reason for the name: the only place we should have null-terminated ascii strings is from commandline args</span> -<span id="L30" class="LineNr"> 30 </span><span class="subxFunction">kernel-string-equal?</span>: <span class="subxComment"># s: null-terminated ascii string, benchmark: length-prefixed ascii string -> eax: boolean</span> +<span id="L30" class="LineNr"> 30 </span><span class="subxFunction">kernel-string-equal?</span>: <span class="subxComment"># s: null-terminated ascii string, benchmark: size-prefixed ascii string -> eax: boolean</span> <span id="L31" class="LineNr"> 31 </span> <span class="subxComment"># pseudocode:</span> -<span id="L32" class="LineNr"> 32 </span> <span class="subxComment"># n = benchmark->length</span> +<span id="L32" class="LineNr"> 32 </span> <span class="subxComment"># n = benchmark->size</span> <span id="L33" class="LineNr"> 33 </span> <span class="subxComment"># s1 = s</span> <span id="L34" class="LineNr"> 34 </span> <span class="subxComment"># s2 = benchmark->data</span> <span id="L35" class="LineNr"> 35 </span> <span class="subxComment"># i = 0</span> @@ -122,7 +122,7 @@ if ('onhashchange' in window) { <span id="L60" class="LineNr"> 60 </span> 57/push-edi <span id="L61" class="LineNr"> 61 </span> <span class="subxComment"># s1/edi = s</span> <span id="L62" class="LineNr"> 62 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 7/r32/edi 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+8) to edi</span> -<span id="L63" class="LineNr"> 63 </span> <span class="subxComment"># n/edx = benchmark->length</span> +<span id="L63" class="LineNr"> 63 </span> <span class="subxComment"># n/edx = benchmark->size</span> <span id="L64" class="LineNr"> 64 </span> 8b/copy 1/mod/*+disp8 5/rm32/ebp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ebp+12) to edx</span> <span id="L65" class="LineNr"> 65 </span> 8b/copy 0/mod/indirect 2/rm32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/edx <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *edx to edx</span> <span id="L66" class="LineNr"> 66 </span> <span class="subxComment"># s2/esi = benchmark->data</span> |