diff options
-rw-r--r-- | html/subx/050_write.subx.html | 3 | ||||
-rw-r--r-- | html/subx/050write_stderr.subx.html | 97 | ||||
-rw-r--r-- | html/subx/051test.subx.html | 7 | ||||
-rw-r--r-- | html/subx/052kernel_string_equal.subx.html | 28 | ||||
-rw-r--r-- | html/subx/053new_segment.subx.html | 5 | ||||
-rw-r--r-- | html/subx/054string_equal.subx.html | 22 | ||||
-rw-r--r-- | html/subx/055trace.subx.html | 31 | ||||
-rw-r--r-- | html/subx/056write.subx.html | 21 | ||||
-rw-r--r-- | html/subx/057stop.subx.html | 15 | ||||
-rw-r--r-- | html/subx/058read.subx.html | 19 | ||||
-rw-r--r-- | html/subx/059read-byte.subx.html | 17 | ||||
-rw-r--r-- | html/subx/060write-stream.subx.html | 17 | ||||
-rw-r--r-- | html/subx/apps/crenshaw2-1.subx.html | 31 | ||||
-rw-r--r-- | html/subx/apps/crenshaw2-1b.subx.html | 37 | ||||
-rw-r--r-- | html/subx/apps/factorial.subx.html | 12 | ||||
-rw-r--r-- | html/subx/examples/ex10.subx.html | 12 | ||||
-rw-r--r-- | html/subx/examples/ex11.subx.html | 36 | ||||
-rw-r--r-- | html/subx/examples/ex3.subx.html | 5 | ||||
-rw-r--r-- | html/subx/examples/ex8.subx.html | 8 | ||||
-rw-r--r-- | html/subx/examples/ex9.subx.html | 3 | ||||
-rw-r--r-- | subx/subx.vim | 11 |
21 files changed, 196 insertions, 241 deletions
diff --git a/html/subx/050_write.subx.html b/html/subx/050_write.subx.html index 0dfa8594..eadec7a1 100644 --- a/html/subx/050_write.subx.html +++ b/html/subx/050_write.subx.html @@ -23,6 +23,7 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxMinorFunction { color: #875f5f; } --> </style> @@ -71,7 +72,7 @@ if ('onhashchange' in window) { <span id="L11" class="LineNr">11 </span> b8/copy-to-EAX 1/imm32 <span id="L12" class="LineNr">12 </span> cd/syscall 0x80/imm8 <span id="L13" class="LineNr">13 </span> -<span id="L14" class="LineNr">14 </span>_write: <span class="subxComment"># fd : int, s : (address array byte) -> <void></span> +<span id="L14" class="LineNr">14 </span><span class="subxMinorFunction">_write</span>: <span class="subxComment"># fd : int, s : (address array byte) -> <void></span> <span id="L15" class="LineNr">15 </span> <span class="subxS1Comment"># . prolog</span> <span id="L16" class="LineNr">16 </span> 55/push-EBP <span id="L17" class="LineNr">17 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> diff --git a/html/subx/050write_stderr.subx.html b/html/subx/050write_stderr.subx.html deleted file mode 100644 index 63fb619c..00000000 --- a/html/subx/050write_stderr.subx.html +++ /dev/null @@ -1,97 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html> -<head> -<meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - subx/050write_stderr.subx</title> -<meta name="Generator" content="Vim/8.0"> -<meta name="plugin-version" content="vim7.4_v2"> -<meta name="syntax" content="none"> -<meta name="settings" content="number_lines,use_css,no_foldcolumn,expand_tabs,line_ids,prevent_copy="> -<meta name="colorscheme" content="minimal"> -<style type="text/css"> -<!-- -pre { font-family: monospace; color: #aaaaaa; background-color: #080808; } -body { font-size: 12pt; font-family: monospace; color: #aaaaaa; background-color: #080808; } -a { color:#eeeeee; text-decoration: none; } -a:hover { text-decoration: underline; } -* { font-size: 12pt; font-size: 1em; } -.LineNr { color: #444444; } -.Delimiter { color: #800080; } -.Comment { color: #9090ff; } -.Comment a { color:#0000ee; text-decoration:underline; } ---> -</style> - -<script type='text/javascript'> -<!-- - -/* function to open any folds containing a jumped-to line before jumping to it */ -function JumpToLine() -{ - var lineNum; - lineNum = window.location.hash; - lineNum = lineNum.substr(1); /* strip off '#' */ - - if (lineNum.indexOf('L') == -1) { - lineNum = 'L'+lineNum; - } - lineElem = document.getElementById(lineNum); - /* Always jump to new location even if the line was hidden inside a fold, or - * we corrected the raw number to a line ID. - */ - if (lineElem) { - lineElem.scrollIntoView(true); - } - return true; -} -if ('onhashchange' in window) { - window.onhashchange = JumpToLine; -} - ---> -</script> -</head> -<body onload='JumpToLine();'> -<pre id='vimCodeElement'> -<span id="L1" class="LineNr"> 1 </span>== code -<span id="L2" class="LineNr"> 2 </span> -<span id="L3" class="LineNr"> 3 </span><span class="Comment"># instruction effective address operand displacement immediate</span> -<span id="L4" class="LineNr"> 4 </span><span class="Comment"># op subop mod rm32 base index scale r32</span> -<span id="L5" class="LineNr"> 5 </span><span class="Comment"># 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> -<span id="L6" class="LineNr"> 6 </span> -<span id="L7" class="LineNr"> 7 </span>write_stderr: <span class="Comment"># s : (address array byte) -> <void></span> -<span id="L8" class="LineNr"> 8 </span> <span class="Comment"># prolog</span> -<span id="L9" class="LineNr"> 9 </span> 55/push-EBP -<span id="L10" class="LineNr">10 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> 4/r32/ESP <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Comment"># copy ESP to EBP</span> -<span id="L11" class="LineNr">11 </span> <span class="Comment"># save registers</span> -<span id="L12" class="LineNr">12 </span> 50/push-EAX -<span id="L13" class="LineNr">13 </span> 51/push-ECX -<span id="L14" class="LineNr">14 </span> 52/push-EDX -<span id="L15" class="LineNr">15 </span> 53/push-EBX -<span id="L16" class="LineNr">16 </span> <span class="Comment"># write(2/stderr, (data) s+4, (size) *s)</span> -<span id="L17" class="LineNr">17 </span> <span class="Comment"># fd = 2 (stderr)</span> -<span id="L18" class="LineNr">18 </span> bb/copy <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> 2/imm32 <span class="Comment"># copy to EBX</span> -<span id="L19" class="LineNr">19 </span> <span class="Comment"># x = s+4</span> -<span id="L20" class="LineNr">20 </span> 8b/copy 1/mod/*+disp8 4/rm32/SIB 5/base/EBP 4/index/none <span class="Delimiter"> . </span> 1/r32/ECX 8/disp8 <span class="Delimiter"> . </span> <span class="Comment"># copy *(EBP+8) to ECX</span> -<span id="L21" class="LineNr">21 </span> 81 0/subop/add 3/mod/direct 1/rm32/ECX <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> 4/imm32 <span class="Comment"># add to ECX</span> -<span id="L22" class="LineNr">22 </span> <span class="Comment"># size = *s</span> -<span id="L23" class="LineNr">23 </span> 8b/copy 1/mod/*+disp8 4/rm32/SIB 5/base/EBP 4/index/none <span class="Delimiter"> . </span> 2/r32/EDX 8/disp8 <span class="Delimiter"> . </span> <span class="Comment"># copy *(EBP+8) to EDX</span> -<span id="L24" class="LineNr">24 </span> 8b/copy 0/mod/indirect 2/rm32/EDX <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> 2/r32/EDX <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Comment"># copy *EDX to EDX</span> -<span id="L25" class="LineNr">25 </span> <span class="Comment"># call write()</span> -<span id="L26" class="LineNr">26 </span> b8/copy <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> 4/imm32/write <span class="Comment"># copy to EAX</span> -<span id="L27" class="LineNr">27 </span> cd/syscall 0x80/imm8 -<span id="L28" class="LineNr">28 </span> <span class="Comment"># restore registers</span> -<span id="L29" class="LineNr">29 </span> 5b/pop-to-EBX -<span id="L30" class="LineNr">30 </span> 5a/pop-to-EDX -<span id="L31" class="LineNr">31 </span> 59/pop-to-ECX -<span id="L32" class="LineNr">32 </span> 58/pop-to-EAX -<span id="L33" class="LineNr">33 </span> <span class="Comment"># end</span> -<span id="L34" class="LineNr">34 </span> 89/copy 3/mod/direct 4/rm32/ESP <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> 5/r32/EBP <span class="Delimiter"> . </span> <span class="Delimiter"> . </span> <span class="Comment"># copy EBP to ESP</span> -<span id="L35" class="LineNr">35 </span> 5d/pop-to-EBP -<span id="L36" class="LineNr">36 </span> c3/return -<span id="L37" class="LineNr">37 </span> -<span id="L38" class="LineNr">38 </span><span class="Comment"># vim:ft=subx:nowrap:tw&</span> -</pre> -</body> -</html> -<!-- vim: set foldmethod=manual : --> diff --git a/html/subx/051test.subx.html b/html/subx/051test.subx.html index 89ebfd20..cf70c9bc 100644 --- a/html/subx/051test.subx.html +++ b/html/subx/051test.subx.html @@ -24,6 +24,7 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } .Constant { color:#00a0a0; } +.subxFunction { color: #ff8700; } .SpecialChar { color: #ff0000; } --> </style> @@ -83,7 +84,7 @@ if ('onhashchange' in window) { <span id="L21" class="LineNr">21 </span> cd/syscall 0x80/imm8 <span id="L22" class="LineNr">22 </span> <span id="L23" class="LineNr">23 </span><span class="subxComment"># print msg to stderr if a != b, otherwise print "."</span> -<span id="L24" class="LineNr">24 </span>check-ints-equal: <span class="subxComment"># (a : int, b : int, msg : (address array byte)) -> boolean</span> +<span id="L24" class="LineNr">24 </span><span class="subxFunction">check-ints-equal</span>: <span class="subxComment"># (a : int, b : int, msg : (address array byte)) -> boolean</span> <span id="L25" class="LineNr">25 </span> <span class="subxS1Comment"># . prolog</span> <span id="L26" class="LineNr">26 </span> 55/push-EBP <span id="L27" class="LineNr">27 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -107,7 +108,7 @@ if ('onhashchange' in window) { <span id="L45" class="LineNr">45 </span> <span class="subxS1Comment"># . return</span> <span id="L46" class="LineNr">46 </span> eb/jump $check-ints-equal:end/disp8 <span id="L47" class="LineNr">47 </span> <span class="subxComment"># otherwise print error message</span> -<span id="L48" class="LineNr">48 </span>$check-ints-equal:else: +<span id="L48" class="LineNr">48 </span><span class="Constant">$check-ints-equal:else</span>: <span id="L49" class="LineNr">49 </span> <span class="subxS1Comment"># . _write(2/stderr, msg)</span> <span id="L50" class="LineNr">50 </span> <span class="subxS2Comment"># . . push args</span> <span id="L51" class="LineNr">51 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none <span class="CommentedCode"> . </span> 1/r32/ECX 0x10/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(EBP+16) to ECX</span> @@ -127,7 +128,7 @@ if ('onhashchange' in window) { <span id="L65" class="LineNr">65 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> <span id="L66" class="LineNr">66 </span> <span class="subxComment"># increment Num-test-failures</span> <span id="L67" class="LineNr">67 </span> ff 0/subop/increment 0/mod/indirect 5/rm32/.disp32 <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="SpecialChar">Num-test-failures</span>/disp32 <span class="subxComment"># increment *Num-test-failures</span> -<span id="L68" class="LineNr">68 </span>$check-ints-equal:end: +<span id="L68" class="LineNr">68 </span><span class="Constant">$check-ints-equal:end</span>: <span id="L69" class="LineNr">69 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L70" class="LineNr">70 </span> 5b/pop-to-EBX <span id="L71" class="LineNr">71 </span> 59/pop-to-ECX diff --git a/html/subx/052kernel_string_equal.subx.html b/html/subx/052kernel_string_equal.subx.html index e35b1aa3..5c6911ff 100644 --- a/html/subx/052kernel_string_equal.subx.html +++ b/html/subx/052kernel_string_equal.subx.html @@ -23,6 +23,8 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } .Constant { color:#00a0a0; } .SpecialChar { color: #ff0000; } .subxH1Comment { color:#00ffff; } @@ -91,7 +93,7 @@ if ('onhashchange' in window) { <span id="L28" class="LineNr"> 28 </span> <span id="L29" class="LineNr"> 29 </span><span class="subxComment"># compare a null-terminated ascii string with a more idiomatic length-prefixed byte array</span> <span id="L30" class="LineNr"> 30 </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="L31" class="LineNr"> 31 </span>kernel-string-equal: <span class="subxComment"># s : null-terminated ascii string, benchmark : length-prefixed ascii string -> EAX : boolean</span> +<span id="L31" class="LineNr"> 31 </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="L32" class="LineNr"> 32 </span> <span class="subxS1Comment"># . prolog</span> <span id="L33" class="LineNr"> 33 </span> 55/push-EBP <span id="L34" class="LineNr"> 34 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -127,7 +129,7 @@ if ('onhashchange' in window) { <span id="L64" class="LineNr"> 64 </span> <span class="subxComment"># initialize loop counter i into ECX</span> <span id="L65" class="LineNr"> 65 </span> b9/copy-to-ECX 0/imm32/exit <span id="L66" class="LineNr"> 66 </span> <span class="subxComment"># while (i/ECX < n/EDX)</span> -<span id="L67" class="LineNr"> 67 </span>$kernel-string-equal:loop: +<span id="L67" class="LineNr"> 67 </span><span class="Constant">$kernel-string-equal:loop</span>: <span id="L68" class="LineNr"> 68 </span> 39/compare 3/mod/direct 1/rm32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 2/r32/EDX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># compare ECX with EDX</span> <span id="L69" class="LineNr"> 69 </span> 74/jump-if-equal $kernel-string-equal:break/disp8 <span id="L70" class="LineNr"> 70 </span> <span class="subxComment"># c1/EAX, c2/EBX = *s, *benchmark</span> @@ -147,20 +149,20 @@ if ('onhashchange' in window) { <span id="L84" class="LineNr"> 84 </span> 47/inc-EDI <span id="L85" class="LineNr"> 85 </span> <span class="subxComment"># end while</span> <span id="L86" class="LineNr"> 86 </span> eb/jump $kernel-string-equal:loop/disp8 -<span id="L87" class="LineNr"> 87 </span>$kernel-string-equal:break: +<span id="L87" class="LineNr"> 87 </span><span class="Constant">$kernel-string-equal:break</span>: <span id="L88" class="LineNr"> 88 </span> <span class="subxComment"># if (*s/EDI == 0) return true</span> <span id="L89" class="LineNr"> 89 </span> b8/copy-to-EAX 0/imm32 <span id="L90" class="LineNr"> 90 </span> 8a/copy 0/mod/indirect 7/rm32/EDI <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy byte at *EDI to lower byte of EAX</span> <span id="L91" class="LineNr"> 91 </span> 3d/compare-EAX 0/imm32 <span id="L92" class="LineNr"> 92 </span> 75/jump-if-not-equal $kernel-string-equal:false/disp8 -<span id="L93" class="LineNr"> 93 </span>$kernel-string-equal:true: +<span id="L93" class="LineNr"> 93 </span><span class="Constant">$kernel-string-equal:true</span>: <span id="L94" class="LineNr"> 94 </span> b8/copy-to-EAX 1/imm32 <span id="L95" class="LineNr"> 95 </span> eb/jump $kernel-string-equal:end/disp8 <span id="L96" class="LineNr"> 96 </span> <span class="subxComment"># return false</span> -<span id="L97" class="LineNr"> 97 </span>$kernel-string-equal:false: +<span id="L97" class="LineNr"> 97 </span><span class="Constant">$kernel-string-equal:false</span>: <span id="L98" class="LineNr"> 98 </span> b8/copy-to-EAX 0/imm32 <span id="L99" class="LineNr"> 99 </span> -<span id="L100" class="LineNr">100 </span>$kernel-string-equal:end: +<span id="L100" class="LineNr">100 </span><span class="Constant">$kernel-string-equal:end</span>: <span id="L101" class="LineNr">101 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L102" class="LineNr">102 </span> 5f/pop-to-EDI <span id="L103" class="LineNr">103 </span> 5e/pop-to-ESI @@ -174,7 +176,7 @@ if ('onhashchange' in window) { <span id="L111" class="LineNr">111 </span> <span id="L112" class="LineNr">112 </span><span class="subxH1Comment"># - tests</span> <span id="L113" class="LineNr">113 </span> -<span id="L114" class="LineNr">114 </span>test-compare-null-kernel-string-with-empty-array: +<span id="L114" class="LineNr">114 </span><span class="subxTest">test-compare-null-kernel-string-with-empty-array</span>: <span id="L115" class="LineNr">115 </span> <span class="subxComment"># EAX = kernel-string-equal(Null-kernel-string, "")</span> <span id="L116" class="LineNr">116 </span> <span class="subxS2Comment"># . . push args</span> <span id="L117" class="LineNr">117 </span> 68/push <span class="Constant">""</span>/imm32 @@ -194,7 +196,7 @@ if ('onhashchange' in window) { <span id="L131" class="LineNr">131 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L132" class="LineNr">132 </span> c3/return <span id="L133" class="LineNr">133 </span> -<span id="L134" class="LineNr">134 </span>test-compare-null-kernel-string-with-non-empty-array: +<span id="L134" class="LineNr">134 </span><span class="subxTest">test-compare-null-kernel-string-with-non-empty-array</span>: <span id="L135" class="LineNr">135 </span> <span class="subxComment"># EAX = kernel-string-equal(Null-kernel-string, "Abc")</span> <span id="L136" class="LineNr">136 </span> <span class="subxS2Comment"># . . push args</span> <span id="L137" class="LineNr">137 </span> 68/push <span class="Constant">"Abc"</span>/imm32 @@ -214,7 +216,7 @@ if ('onhashchange' in window) { <span id="L151" class="LineNr">151 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L152" class="LineNr">152 </span> c3/return <span id="L153" class="LineNr">153 </span> -<span id="L154" class="LineNr">154 </span>test-compare-kernel-string-with-equal-array: +<span id="L154" class="LineNr">154 </span><span class="subxTest">test-compare-kernel-string-with-equal-array</span>: <span id="L155" class="LineNr">155 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "Abc")</span> <span id="L156" class="LineNr">156 </span> <span class="subxS2Comment"># . . push args</span> <span id="L157" class="LineNr">157 </span> 68/push <span class="Constant">"Abc"</span>/imm32 @@ -234,7 +236,7 @@ if ('onhashchange' in window) { <span id="L171" class="LineNr">171 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L172" class="LineNr">172 </span> c3/return <span id="L173" class="LineNr">173 </span> -<span id="L174" class="LineNr">174 </span>test-compare-kernel-string-with-inequal-array: +<span id="L174" class="LineNr">174 </span><span class="subxTest">test-compare-kernel-string-with-inequal-array</span>: <span id="L175" class="LineNr">175 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "Adc")</span> <span id="L176" class="LineNr">176 </span> <span class="subxS2Comment"># . . push args</span> <span id="L177" class="LineNr">177 </span> 68/push <span class="Constant">"Adc"</span>/imm32 @@ -254,7 +256,7 @@ if ('onhashchange' in window) { <span id="L191" class="LineNr">191 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L192" class="LineNr">192 </span> c3/return <span id="L193" class="LineNr">193 </span> -<span id="L194" class="LineNr">194 </span>test-compare-kernel-string-with-empty-array: +<span id="L194" class="LineNr">194 </span><span class="subxTest">test-compare-kernel-string-with-empty-array</span>: <span id="L195" class="LineNr">195 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "")</span> <span id="L196" class="LineNr">196 </span> <span class="subxS2Comment"># . . push args</span> <span id="L197" class="LineNr">197 </span> 68/push <span class="Constant">""</span>/imm32 @@ -274,7 +276,7 @@ if ('onhashchange' in window) { <span id="L211" class="LineNr">211 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L212" class="LineNr">212 </span> c3/return <span id="L213" class="LineNr">213 </span> -<span id="L214" class="LineNr">214 </span>test-compare-kernel-string-with-shorter-array: +<span id="L214" class="LineNr">214 </span><span class="subxTest">test-compare-kernel-string-with-shorter-array</span>: <span id="L215" class="LineNr">215 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "Ab")</span> <span id="L216" class="LineNr">216 </span> <span class="subxS2Comment"># . . push args</span> <span id="L217" class="LineNr">217 </span> 68/push <span class="Constant">"Ab"</span>/imm32 @@ -294,7 +296,7 @@ if ('onhashchange' in window) { <span id="L231" class="LineNr">231 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L232" class="LineNr">232 </span> c3/return <span id="L233" class="LineNr">233 </span> -<span id="L234" class="LineNr">234 </span>test-compare-kernel-string-with-longer-array: +<span id="L234" class="LineNr">234 </span><span class="subxTest">test-compare-kernel-string-with-longer-array</span>: <span id="L235" class="LineNr">235 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "Abcd")</span> <span id="L236" class="LineNr">236 </span> <span class="subxS2Comment"># . . push args</span> <span id="L237" class="LineNr">237 </span> 68/push <span class="Constant">"Abcd"</span>/imm32 diff --git a/html/subx/053new_segment.subx.html b/html/subx/053new_segment.subx.html index cc8a1748..8e448bd7 100644 --- a/html/subx/053new_segment.subx.html +++ b/html/subx/053new_segment.subx.html @@ -23,6 +23,7 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } .subxH1Comment { color:#00ffff; } --> </style> @@ -83,7 +84,7 @@ if ('onhashchange' in window) { <span id="L22" class="LineNr">22 </span> b8/copy-to-EAX 1/imm32/exit <span id="L23" class="LineNr">23 </span> cd/syscall 0x80/imm8 <span id="L24" class="LineNr">24 </span> -<span id="L25" class="LineNr">25 </span>new-segment: <span class="subxComment"># len : int -> address</span> +<span id="L25" class="LineNr">25 </span><span class="subxFunction">new-segment</span>: <span class="subxComment"># len : int -> address</span> <span id="L26" class="LineNr">26 </span> <span class="subxS1Comment"># . prolog</span> <span id="L27" class="LineNr">27 </span> 55/push-EBP <span id="L28" class="LineNr">28 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -106,7 +107,7 @@ if ('onhashchange' in window) { <span id="L45" class="LineNr">45 </span>== data <span id="L46" class="LineNr">46 </span> <span id="L47" class="LineNr">47 </span><span class="subxComment"># various constants used here were found in the Linux sources (search for file mman-common.h)</span> -<span id="L48" class="LineNr">48 </span>mmap-new-segment: <span class="subxComment"># type mmap_arg_struct</span> +<span id="L48" class="LineNr">48 </span><span class="subxFunction">mmap-new-segment</span>: <span class="subxComment"># type mmap_arg_struct</span> <span id="L49" class="LineNr">49 </span> <span class="subxComment"># addr</span> <span id="L50" class="LineNr">50 </span> 00 00 00 00 <span class="subxComment"># null</span> <span id="L51" class="LineNr">51 </span> <span class="subxComment"># len</span> diff --git a/html/subx/054string_equal.subx.html b/html/subx/054string_equal.subx.html index 5b6504d2..c99387f5 100644 --- a/html/subx/054string_equal.subx.html +++ b/html/subx/054string_equal.subx.html @@ -23,6 +23,8 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } .Constant { color:#00a0a0; } .SpecialChar { color: #ff0000; } .subxH1Comment { color:#00ffff; } @@ -76,7 +78,7 @@ if ('onhashchange' in window) { <span id="L13" class="LineNr"> 13 </span> b8/copy-to-EAX 1/imm32 <span id="L14" class="LineNr"> 14 </span> cd/syscall 0x80/imm8 <span id="L15" class="LineNr"> 15 </span> -<span id="L16" class="LineNr"> 16 </span>string-equal: <span class="subxComment"># s : string, benchmark : string -> EAX : boolean</span> +<span id="L16" class="LineNr"> 16 </span><span class="subxFunction">string-equal</span>: <span class="subxComment"># s : string, benchmark : string -> EAX : boolean</span> <span id="L17" class="LineNr"> 17 </span> <span class="subxS1Comment"># . prolog</span> <span id="L18" class="LineNr"> 18 </span> 55/push-EBP <span id="L19" class="LineNr"> 19 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -107,14 +109,14 @@ if ('onhashchange' in window) { <span id="L44" class="LineNr"> 44 </span> <span class="subxComment"># compare s.length and b.length</span> <span id="L45" class="LineNr"> 45 </span> 39/compare 0/mod/indirect 3/rm32/EBX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 2/r32/EDX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># compare *EBX with EDX</span> <span id="L46" class="LineNr"> 46 </span> 75/jump-if-not-equal $string-equal:false/disp8 -<span id="L47" class="LineNr"> 47 </span>$string-equal:lengths: +<span id="L47" class="LineNr"> 47 </span><span class="Constant">$string-equal:lengths</span>: <span id="L48" class="LineNr"> 48 </span> <span class="subxComment"># var i/ECX : int = 0</span> <span id="L49" class="LineNr"> 49 </span> b9/copy-to-ECX 0/imm32 <span id="L50" class="LineNr"> 50 </span> <span class="subxComment"># EBX = &b[i]</span> <span id="L51" class="LineNr"> 51 </span> 43/inc-EBX <span id="L52" class="LineNr"> 52 </span> <span class="subxComment"># EAX = &s[i]</span> <span id="L53" class="LineNr"> 53 </span> 40/inc-EAX -<span id="L54" class="LineNr"> 54 </span>$string-equal:loop: +<span id="L54" class="LineNr"> 54 </span><span class="Constant">$string-equal:loop</span>: <span id="L55" class="LineNr"> 55 </span> <span class="subxComment"># if i >= s.length return true</span> <span id="L56" class="LineNr"> 56 </span> 39/compare 3/mod/direct 1/rm32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 2/r32/EDX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># compare ECX with EDX</span> <span id="L57" class="LineNr"> 57 </span> 7d/jump-if-greater-or-equal $string-equal:true/disp8 @@ -130,14 +132,14 @@ if ('onhashchange' in window) { <span id="L67" class="LineNr"> 67 </span> 43/inc-EBX <span id="L68" class="LineNr"> 68 </span> <span class="subxComment"># loop</span> <span id="L69" class="LineNr"> 69 </span> eb/jump $string-equal:loop/disp8 -<span id="L70" class="LineNr"> 70 </span>$string-equal:true: +<span id="L70" class="LineNr"> 70 </span><span class="Constant">$string-equal:true</span>: <span id="L71" class="LineNr"> 71 </span> <span class="subxComment"># return true</span> <span id="L72" class="LineNr"> 72 </span> b8/copy-to-EAX 1/imm32 <span id="L73" class="LineNr"> 73 </span> eb/jump $string-equal:end/disp8 -<span id="L74" class="LineNr"> 74 </span>$string-equal:false: +<span id="L74" class="LineNr"> 74 </span><span class="Constant">$string-equal:false</span>: <span id="L75" class="LineNr"> 75 </span> <span class="subxComment"># return false</span> <span id="L76" class="LineNr"> 76 </span> b8/copy-to-EAX 0/imm32 -<span id="L77" class="LineNr"> 77 </span>$string-equal:end: +<span id="L77" class="LineNr"> 77 </span><span class="Constant">$string-equal:end</span>: <span id="L78" class="LineNr"> 78 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L79" class="LineNr"> 79 </span> 5e/pop-to-ESI <span id="L80" class="LineNr"> 80 </span> 5b/pop-to-EBX @@ -150,7 +152,7 @@ if ('onhashchange' in window) { <span id="L87" class="LineNr"> 87 </span> <span id="L88" class="LineNr"> 88 </span><span class="subxH1Comment"># - tests</span> <span id="L89" class="LineNr"> 89 </span> -<span id="L90" class="LineNr"> 90 </span>test-compare-empty-with-empty-string: +<span id="L90" class="LineNr"> 90 </span><span class="subxTest">test-compare-empty-with-empty-string</span>: <span id="L91" class="LineNr"> 91 </span> <span class="subxComment"># EAX = string-equal("", "")</span> <span id="L92" class="LineNr"> 92 </span> <span class="subxS2Comment"># . . push args</span> <span id="L93" class="LineNr"> 93 </span> 68/push <span class="Constant">""</span>/imm32 @@ -170,7 +172,7 @@ if ('onhashchange' in window) { <span id="L107" class="LineNr">107 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L108" class="LineNr">108 </span> c3/return <span id="L109" class="LineNr">109 </span> -<span id="L110" class="LineNr">110 </span>test-compare-empty-with-non-empty-string: <span class="subxComment"># also checks length-mismatch code path</span> +<span id="L110" class="LineNr">110 </span><span class="subxTest">test-compare-empty-with-non-empty-string</span>: <span class="subxComment"># also checks length-mismatch code path</span> <span id="L111" class="LineNr">111 </span> <span class="subxComment"># EAX = string-equal("", "Abc")</span> <span id="L112" class="LineNr">112 </span> <span class="subxS2Comment"># . . push args</span> <span id="L113" class="LineNr">113 </span> 68/push <span class="Constant">"Abc"</span>/imm32 @@ -190,7 +192,7 @@ if ('onhashchange' in window) { <span id="L127" class="LineNr">127 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L128" class="LineNr">128 </span> c3/return <span id="L129" class="LineNr">129 </span> -<span id="L130" class="LineNr">130 </span>test-compare-equal-strings: +<span id="L130" class="LineNr">130 </span><span class="subxTest">test-compare-equal-strings</span>: <span id="L131" class="LineNr">131 </span> <span class="subxComment"># EAX = string-equal("Abc", "Abc")</span> <span id="L132" class="LineNr">132 </span> <span class="subxS2Comment"># . . push args</span> <span id="L133" class="LineNr">133 </span> 68/push <span class="Constant">"Abc"</span>/imm32 @@ -210,7 +212,7 @@ if ('onhashchange' in window) { <span id="L147" class="LineNr">147 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L148" class="LineNr">148 </span> c3/return <span id="L149" class="LineNr">149 </span> -<span id="L150" class="LineNr">150 </span>test-compare-inequal-strings-equal-lengths: +<span id="L150" class="LineNr">150 </span><span class="subxTest">test-compare-inequal-strings-equal-lengths</span>: <span id="L151" class="LineNr">151 </span> <span class="subxComment"># EAX = string-equal("Abc", "Adc")</span> <span id="L152" class="LineNr">152 </span> <span class="subxS2Comment"># . . push args</span> <span id="L153" class="LineNr">153 </span> 68/push <span class="Constant">"Adc"</span>/imm32 diff --git a/html/subx/055trace.subx.html b/html/subx/055trace.subx.html index bd3ec9c0..4e92ea63 100644 --- a/html/subx/055trace.subx.html +++ b/html/subx/055trace.subx.html @@ -23,6 +23,9 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .SpecialChar { color: #ff0000; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } +.subxMinorFunction { color: #875f5f; } .Constant { color:#00a0a0; } .CommentedCode { color: #6c6c6c; } .subxH1Comment { color:#00ffff; } @@ -90,7 +93,7 @@ if ('onhashchange' in window) { <span id="L27" class="LineNr"> 27 </span> <span id="L28" class="LineNr"> 28 </span><span class="subxComment"># Fake trace-stream for tests.</span> <span id="L29" class="LineNr"> 29 </span><span class="subxComment"># Also illustrates the layout of the real trace-stream (segment).</span> -<span id="L30" class="LineNr"> 30 </span>_test-trace-stream: +<span id="L30" class="LineNr"> 30 </span><span class="subxMinorFunction">_test-trace-stream</span>: <span id="L31" class="LineNr"> 31 </span> <span class="subxComment"># current write index</span> <span id="L32" class="LineNr"> 32 </span> 00 00 00 00 <span id="L33" class="LineNr"> 33 </span> <span class="subxComment"># current read index</span> @@ -115,7 +118,7 @@ if ('onhashchange' in window) { <span id="L52" class="LineNr"> 52 </span> <span id="L53" class="LineNr"> 53 </span><span class="subxComment"># Allocate a new segment for the trace stream, initialize its length, and save its address to Trace-stream.</span> <span id="L54" class="LineNr"> 54 </span><span class="subxComment"># The Trace-stream segment will consist of variable-length lines separated by newlines (0x0a)</span> -<span id="L55" class="LineNr"> 55 </span>initialize-trace-stream: +<span id="L55" class="LineNr"> 55 </span><span class="subxFunction">initialize-trace-stream</span>: <span id="L56" class="LineNr"> 56 </span> <span class="subxComment"># EAX = new-segment(0x1000)</span> <span id="L57" class="LineNr"> 57 </span> <span class="subxS2Comment"># . . push args</span> <span id="L58" class="LineNr"> 58 </span> 68/push 0x1000/imm32/N @@ -131,7 +134,7 @@ if ('onhashchange' in window) { <span id="L68" class="LineNr"> 68 </span> <span id="L69" class="LineNr"> 69 </span><span class="subxComment"># Append a string to the given trace stream.</span> <span id="L70" class="LineNr"> 70 </span><span class="subxComment"># Silently give up if it's already full. Or truncate the string if there isn't enough room.</span> -<span id="L71" class="LineNr"> 71 </span>trace: <span class="subxComment"># t : (address trace-stream), line : string</span> +<span id="L71" class="LineNr"> 71 </span><span class="subxFunction">trace</span>: <span class="subxComment"># t : (address trace-stream), line : string</span> <span id="L72" class="LineNr"> 72 </span> <span class="subxS1Comment"># . prolog</span> <span id="L73" class="LineNr"> 73 </span> 55/push-EBP <span id="L74" class="LineNr"> 74 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -185,7 +188,7 @@ if ('onhashchange' in window) { <span id="L122" class="LineNr">122 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L123" class="LineNr">123 </span> <span class="subxComment"># t->write += EAX</span> <span id="L124" class="LineNr">124 </span> 01/add 0/mod/indirect 7/rm32/EDI <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># add EAX to *EDI</span> -<span id="L125" class="LineNr">125 </span>$trace:end: +<span id="L125" class="LineNr">125 </span><span class="Constant">$trace:end</span>: <span id="L126" class="LineNr">126 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L127" class="LineNr">127 </span> 5f/pop-to-EDI <span id="L128" class="LineNr">128 </span> 5e/pop-to-ESI @@ -198,7 +201,7 @@ if ('onhashchange' in window) { <span id="L135" class="LineNr">135 </span> 5d/pop-to-EBP <span id="L136" class="LineNr">136 </span> c3/return <span id="L137" class="LineNr">137 </span> -<span id="L138" class="LineNr">138 </span>clear-trace-stream: <span class="subxComment"># t : (address trace-stream)</span> +<span id="L138" class="LineNr">138 </span><span class="subxFunction">clear-trace-stream</span>: <span class="subxComment"># t : (address trace-stream)</span> <span id="L139" class="LineNr">139 </span> <span class="subxS1Comment"># . prolog</span> <span id="L140" class="LineNr">140 </span> 55/push-EBP <span id="L141" class="LineNr">141 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -218,7 +221,7 @@ if ('onhashchange' in window) { <span id="L155" class="LineNr">155 </span> <span class="subxComment"># EAX = t->data</span> <span id="L156" class="LineNr">156 </span> 81 0/subop/add 3/mod/direct 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to EAX</span> <span id="L157" class="LineNr">157 </span> <span class="subxComment"># while (true)</span> -<span id="L158" class="LineNr">158 </span>$clear-trace-stream:loop: +<span id="L158" class="LineNr">158 </span><span class="Constant">$clear-trace-stream:loop</span>: <span id="L159" class="LineNr">159 </span> <span class="subxComment"># if EAX >= ECX break</span> <span id="L160" class="LineNr">160 </span> 39/compare 3/mod/direct 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 1/r32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># compare EAX with ECX</span> <span id="L161" class="LineNr">161 </span> 7d/jump-if-greater-or-equal $clear-trace-stream:end/disp8 @@ -227,7 +230,7 @@ if ('onhashchange' in window) { <span id="L164" class="LineNr">164 </span> <span class="subxComment"># EAX += 4</span> <span id="L165" class="LineNr">165 </span> 81 0/subop/add 3/mod/direct 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/imm32 <span class="subxComment"># add to EAX</span> <span id="L166" class="LineNr">166 </span> eb/jump $clear-trace-stream:loop/disp8 -<span id="L167" class="LineNr">167 </span>$clear-trace-stream:end: +<span id="L167" class="LineNr">167 </span><span class="Constant">$clear-trace-stream:end</span>: <span id="L168" class="LineNr">168 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L169" class="LineNr">169 </span> 59/pop-to-ECX <span id="L170" class="LineNr">170 </span> 58/pop-to-EAX @@ -238,7 +241,7 @@ if ('onhashchange' in window) { <span id="L175" class="LineNr">175 </span> <span id="L176" class="LineNr">176 </span><span class="subxH1Comment"># - tests</span> <span id="L177" class="LineNr">177 </span> -<span id="L178" class="LineNr">178 </span>test-trace-single: +<span id="L178" class="LineNr">178 </span><span class="subxTest">test-trace-single</span>: <span id="L179" class="LineNr">179 </span> <span class="subxComment"># clear-trace-stream(_test-trace-stream)</span> <span id="L180" class="LineNr">180 </span> <span class="subxS2Comment"># . . push args</span> <span id="L181" class="LineNr">181 </span> 68/push _test-trace-stream/imm32 @@ -268,7 +271,7 @@ if ('onhashchange' in window) { <span id="L205" class="LineNr">205 </span> <span class="subxComment"># end</span> <span id="L206" class="LineNr">206 </span> c3/return <span id="L207" class="LineNr">207 </span> -<span id="L208" class="LineNr">208 </span>test-trace-appends: +<span id="L208" class="LineNr">208 </span><span class="subxTest">test-trace-appends</span>: <span id="L209" class="LineNr">209 </span> <span class="subxComment"># clear-trace-stream(_test-trace-stream)</span> <span id="L210" class="LineNr">210 </span> <span class="subxS2Comment"># . . push args</span> <span id="L211" class="LineNr">211 </span> 68/push _test-trace-stream/imm32 @@ -306,7 +309,7 @@ if ('onhashchange' in window) { <span id="L243" class="LineNr">243 </span> <span class="subxComment"># end</span> <span id="L244" class="LineNr">244 </span> c3/return <span id="L245" class="LineNr">245 </span> -<span id="L246" class="LineNr">246 </span>test-trace-empty-line: +<span id="L246" class="LineNr">246 </span><span class="subxTest">test-trace-empty-line</span>: <span id="L247" class="LineNr">247 </span> <span class="subxComment"># clear-trace-stream(_test-trace-stream)</span> <span id="L248" class="LineNr">248 </span> <span class="subxS2Comment"># . . push args</span> <span id="L249" class="LineNr">249 </span> 68/push _test-trace-stream/imm32 @@ -339,7 +342,7 @@ if ('onhashchange' in window) { <span id="L276" class="LineNr">276 </span><span class="subxH1Comment"># - helpers</span> <span id="L277" class="LineNr">277 </span> <span id="L278" class="LineNr">278 </span><span class="subxComment"># 3-argument variant of _append</span> -<span id="L279" class="LineNr">279 </span>_append-3: <span class="subxComment"># out : address, outend : address, s : (array byte) -> num_bytes_appended/EAX</span> +<span id="L279" class="LineNr">279 </span><span class="subxMinorFunction">_append-3</span>: <span class="subxComment"># out : address, outend : address, s : (array byte) -> num_bytes_appended/EAX</span> <span id="L280" class="LineNr">280 </span> <span class="subxS1Comment"># . prolog</span> <span id="L281" class="LineNr">281 </span> 55/push-EBP <span id="L282" class="LineNr">282 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -370,7 +373,7 @@ if ('onhashchange' in window) { <span id="L307" class="LineNr">307 </span> c3/return <span id="L308" class="LineNr">308 </span> <span id="L309" class="LineNr">309 </span><span class="subxComment"># 4-argument variant of _append</span> -<span id="L310" class="LineNr">310 </span>_append-4: <span class="subxComment"># out : address, outend : address, in : address, inend : address -> num_bytes_appended/EAX</span> +<span id="L310" class="LineNr">310 </span><span class="subxMinorFunction">_append-4</span>: <span class="subxComment"># out : address, outend : address, in : address, inend : address -> num_bytes_appended/EAX</span> <span id="L311" class="LineNr">311 </span> <span class="subxS1Comment"># . prolog</span> <span id="L312" class="LineNr">312 </span> 55/push-EBP <span id="L313" class="LineNr">313 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -390,7 +393,7 @@ if ('onhashchange' in window) { <span id="L327" class="LineNr">327 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none <span class="CommentedCode"> . </span> 6/r32/ESI 0x10/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(EBP+16) to ESI</span> <span id="L328" class="LineNr">328 </span> <span class="subxComment"># ECX = inend</span> <span id="L329" class="LineNr">329 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none <span class="CommentedCode"> . </span> 1/r32/ECX 0x14/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(EBP+20) to ECX</span> -<span id="L330" class="LineNr">330 </span>$_append-4:loop: +<span id="L330" class="LineNr">330 </span><span class="Constant">$_append-4:loop</span>: <span id="L331" class="LineNr">331 </span> <span class="subxComment"># if ESI/src >= ECX/srcend break</span> <span id="L332" class="LineNr">332 </span> 39/compare 3/mod/direct 6/rm32/ESI <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 1/r32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># compare ESI with ECX</span> <span id="L333" class="LineNr">333 </span> 7d/jump-if-greater-or-equal $_append-4:end/disp8 @@ -405,7 +408,7 @@ if ('onhashchange' in window) { <span id="L342" class="LineNr">342 </span> 46/increment-ESI <span id="L343" class="LineNr">343 </span> 47/increment-EDI <span id="L344" class="LineNr">344 </span> eb/jump $_append-4:loop/disp8 -<span id="L345" class="LineNr">345 </span>$_append-4:end: +<span id="L345" class="LineNr">345 </span><span class="Constant">$_append-4:end</span>: <span id="L346" class="LineNr">346 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L347" class="LineNr">347 </span> 5f/pop-to-EDI <span id="L348" class="LineNr">348 </span> 5e/pop-to-ESI diff --git a/html/subx/056write.subx.html b/html/subx/056write.subx.html index d21a4bfb..7d08441f 100644 --- a/html/subx/056write.subx.html +++ b/html/subx/056write.subx.html @@ -23,6 +23,9 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } +.subxMinorFunction { color: #875f5f; } .Constant { color:#00a0a0; } .SpecialChar { color: #ff0000; } --> @@ -89,7 +92,7 @@ if ('onhashchange' in window) { <span id="L27" class="LineNr"> 27 </span> b8/copy-to-EAX 1/imm32 <span id="L28" class="LineNr"> 28 </span> cd/syscall 0x80/imm8 <span id="L29" class="LineNr"> 29 </span> -<span id="L30" class="LineNr"> 30 </span>write: <span class="subxComment"># f : fd or (address stream), s : (address array byte) -> bytes_written/EAX</span> +<span id="L30" class="LineNr"> 30 </span><span class="subxFunction">write</span>: <span class="subxComment"># f : fd or (address stream), s : (address array byte) -> bytes_written/EAX</span> <span id="L31" class="LineNr"> 31 </span> <span class="subxComment"># (If we ever leave the Linux kernel behind, it may be better to return</span> <span id="L32" class="LineNr"> 32 </span> <span class="subxComment"># the number of bytes *not* written. Success would then be signaled by</span> <span id="L33" class="LineNr"> 33 </span> <span class="subxComment"># returning 0.)</span> @@ -107,7 +110,7 @@ if ('onhashchange' in window) { <span id="L45" class="LineNr"> 45 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L46" class="LineNr"> 46 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> <span id="L47" class="LineNr"> 47 </span> eb/jump $write:end/disp8 -<span id="L48" class="LineNr"> 48 </span>$write:fake: +<span id="L48" class="LineNr"> 48 </span><span class="Constant">$write:fake</span>: <span id="L49" class="LineNr"> 49 </span> <span class="subxComment"># otherwise, treat 'f' as a stream to append to</span> <span id="L50" class="LineNr"> 50 </span> <span class="subxS1Comment"># . save registers</span> <span id="L51" class="LineNr"> 51 </span> 51/push-ECX @@ -138,13 +141,13 @@ if ('onhashchange' in window) { <span id="L76" class="LineNr"> 76 </span> 5b/pop-to-EBX <span id="L77" class="LineNr"> 77 </span> 5a/pop-to-EDX <span id="L78" class="LineNr"> 78 </span> 59/pop-to-ECX -<span id="L79" class="LineNr"> 79 </span>$write:end: +<span id="L79" class="LineNr"> 79 </span><span class="Constant">$write:end</span>: <span id="L80" class="LineNr"> 80 </span> <span class="subxS1Comment"># . epilog</span> <span id="L81" class="LineNr"> 81 </span> 89/copy 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 5/r32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy EBP to ESP</span> <span id="L82" class="LineNr"> 82 </span> 5d/pop-to-EBP <span id="L83" class="LineNr"> 83 </span> c3/return <span id="L84" class="LineNr"> 84 </span> -<span id="L85" class="LineNr"> 85 </span>clear-stream: <span class="subxComment"># f : (address stream) -> <void></span> +<span id="L85" class="LineNr"> 85 </span><span class="subxFunction">clear-stream</span>: <span class="subxComment"># f : (address stream) -> <void></span> <span id="L86" class="LineNr"> 86 </span> <span class="subxS1Comment"># . prolog</span> <span id="L87" class="LineNr"> 87 </span> 55/push-EBP <span id="L88" class="LineNr"> 88 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -164,7 +167,7 @@ if ('onhashchange' in window) { <span id="L102" class="LineNr">102 </span> <span class="subxComment"># EAX = f->data</span> <span id="L103" class="LineNr">103 </span> 81 0/subop/add 3/mod/direct 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to EAX</span> <span id="L104" class="LineNr">104 </span> <span class="subxComment"># while (true)</span> -<span id="L105" class="LineNr">105 </span>$clear-stream:loop: +<span id="L105" class="LineNr">105 </span><span class="Constant">$clear-stream:loop</span>: <span id="L106" class="LineNr">106 </span> <span class="subxComment"># if EAX >= ECX break</span> <span id="L107" class="LineNr">107 </span> 39/compare 3/mod/direct 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 1/r32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># compare EAX with ECX</span> <span id="L108" class="LineNr">108 </span> 7d/jump-if-greater-or-equal $clear-stream:end/disp8 @@ -173,7 +176,7 @@ if ('onhashchange' in window) { <span id="L111" class="LineNr">111 </span> <span class="subxComment"># EAX += 4</span> <span id="L112" class="LineNr">112 </span> 81 0/subop/add 3/mod/direct 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/imm32 <span class="subxComment"># add to EAX</span> <span id="L113" class="LineNr">113 </span> eb/jump $clear-stream:loop/disp8 -<span id="L114" class="LineNr">114 </span>$clear-stream:end: +<span id="L114" class="LineNr">114 </span><span class="Constant">$clear-stream:end</span>: <span id="L115" class="LineNr">115 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L116" class="LineNr">116 </span> 59/pop-to-ECX <span id="L117" class="LineNr">117 </span> 58/pop-to-EAX @@ -182,7 +185,7 @@ if ('onhashchange' in window) { <span id="L120" class="LineNr">120 </span> 5d/pop-to-EBP <span id="L121" class="LineNr">121 </span> c3/return <span id="L122" class="LineNr">122 </span> -<span id="L123" class="LineNr">123 </span>test-write-single: +<span id="L123" class="LineNr">123 </span><span class="subxTest">test-write-single</span>: <span id="L124" class="LineNr">124 </span> <span class="subxComment"># clear-stream(_test-stream)</span> <span id="L125" class="LineNr">125 </span> <span class="subxS2Comment"># . . push args</span> <span id="L126" class="LineNr">126 </span> 68/push _test-stream/imm32 @@ -221,7 +224,7 @@ if ('onhashchange' in window) { <span id="L159" class="LineNr">159 </span> <span class="subxComment"># end</span> <span id="L160" class="LineNr">160 </span> c3/return <span id="L161" class="LineNr">161 </span> -<span id="L162" class="LineNr">162 </span>test-write-appends: +<span id="L162" class="LineNr">162 </span><span class="subxTest">test-write-appends</span>: <span id="L163" class="LineNr">163 </span> <span class="subxComment"># clear-stream(_test-stream)</span> <span id="L164" class="LineNr">164 </span> <span class="subxS2Comment"># . . push args</span> <span id="L165" class="LineNr">165 </span> 68/push _test-stream/imm32 @@ -261,7 +264,7 @@ if ('onhashchange' in window) { <span id="L199" class="LineNr">199 </span> <span id="L200" class="LineNr">200 </span>== data <span id="L201" class="LineNr">201 </span> -<span id="L202" class="LineNr">202 </span>_test-stream: +<span id="L202" class="LineNr">202 </span><span class="subxMinorFunction">_test-stream</span>: <span id="L203" class="LineNr">203 </span> <span class="subxComment"># current write index</span> <span id="L204" class="LineNr">204 </span> 00 00 00 00 <span id="L205" class="LineNr">205 </span> <span class="subxComment"># current read index</span> diff --git a/html/subx/057stop.subx.html b/html/subx/057stop.subx.html index bd4dec2c..535dc71b 100644 --- a/html/subx/057stop.subx.html +++ b/html/subx/057stop.subx.html @@ -23,6 +23,9 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } +.subxMinorFunction { color: #875f5f; } .Constant { color:#00a0a0; } .SpecialChar { color: #ff0000; } --> @@ -110,7 +113,7 @@ if ('onhashchange' in window) { <span id="L48" class="LineNr"> 48 </span><span class="subxComment"># Configure an exit-descriptor for a call pushing 'nbytes' bytes of args to</span> <span id="L49" class="LineNr"> 49 </span><span class="subxComment"># the stack.</span> <span id="L50" class="LineNr"> 50 </span><span class="subxComment"># Ugly that we need to know the size of args, but so it goes.</span> -<span id="L51" class="LineNr"> 51 </span>tailor-exit-descriptor: <span class="subxComment"># ed : (address exit-descriptor), nbytes : int -> <void></span> +<span id="L51" class="LineNr"> 51 </span><span class="subxFunction">tailor-exit-descriptor</span>: <span class="subxComment"># ed : (address exit-descriptor), nbytes : int -> <void></span> <span id="L52" class="LineNr"> 52 </span> <span class="subxS1Comment"># . prolog</span> <span id="L53" class="LineNr"> 53 </span> 55/push-EBP <span id="L54" class="LineNr"> 54 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -157,7 +160,7 @@ if ('onhashchange' in window) { <span id="L95" class="LineNr"> 95 </span> 5d/pop-to-EBP <span id="L96" class="LineNr"> 96 </span> c3/return <span id="L97" class="LineNr"> 97 </span> -<span id="L98" class="LineNr"> 98 </span>stop: <span class="subxComment"># ed : (address exit-descriptor), value : int</span> +<span id="L98" class="LineNr"> 98 </span><span class="subxFunction">stop</span>: <span class="subxComment"># ed : (address exit-descriptor), value : int</span> <span id="L99" class="LineNr"> 99 </span> <span class="subxComment"># no prolog; one way or another, we're going to clobber registers</span> <span id="L100" class="LineNr">100 </span> <span class="subxComment"># EAX = ed</span> <span id="L101" class="LineNr">101 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none <span class="CommentedCode"> . </span> 0/r32/EAX 4/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(ESP+4) to EAX</span> @@ -168,7 +171,7 @@ if ('onhashchange' in window) { <span id="L106" class="LineNr">106 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none <span class="CommentedCode"> . </span> 3/r32/EBX 8/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(ESP+8) to EBX</span> <span id="L107" class="LineNr">107 </span> b8/copy-to-EAX 1/imm32 <span id="L108" class="LineNr">108 </span> cd/syscall 0x80/imm8 -<span id="L109" class="LineNr">109 </span>$stop:fake: +<span id="L109" class="LineNr">109 </span><span class="Constant">$stop:fake</span>: <span id="L110" class="LineNr">110 </span> <span class="subxComment"># ed->value = value+1</span> <span id="L111" class="LineNr">111 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none <span class="CommentedCode"> . </span> 1/r32/ECX 8/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(ESP+8) to ECX</span> <span id="L112" class="LineNr">112 </span> 41/inc-ECX @@ -177,7 +180,7 @@ if ('onhashchange' in window) { <span id="L115" class="LineNr">115 </span> 8b/copy 0/mod/indirect 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy *EAX to ESP</span> <span id="L116" class="LineNr">116 </span> c3/return <span class="subxComment"># doesn't return to caller</span> <span id="L117" class="LineNr">117 </span> -<span id="L118" class="LineNr">118 </span>test-stop-skips-returns-on-exit: +<span id="L118" class="LineNr">118 </span><span class="subxTest">test-stop-skips-returns-on-exit</span>: <span id="L119" class="LineNr">119 </span> <span class="subxComment"># This looks like the standard prolog, but is here for different reasons.</span> <span id="L120" class="LineNr">120 </span> <span class="subxComment"># A function calling 'stop' can't rely on EBP persisting past the call.</span> <span id="L121" class="LineNr">121 </span> <span class="subxComment">#</span> @@ -226,7 +229,7 @@ if ('onhashchange' in window) { <span id="L164" class="LineNr">164 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> <span id="L165" class="LineNr">165 </span> c3/return <span id="L166" class="LineNr">166 </span> -<span id="L167" class="LineNr">167 </span>_test-stop-1: <span class="subxComment"># ed : (address exit-descriptor)</span> +<span id="L167" class="LineNr">167 </span><span class="subxMinorFunction">_test-stop-1</span>: <span class="subxComment"># ed : (address exit-descriptor)</span> <span id="L168" class="LineNr">168 </span> <span class="subxS1Comment"># . prolog</span> <span id="L169" class="LineNr">169 </span> 55/push-EBP <span id="L170" class="LineNr">170 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -252,7 +255,7 @@ if ('onhashchange' in window) { <span id="L190" class="LineNr">190 </span> 5d/pop-to-EBP <span id="L191" class="LineNr">191 </span> c3/return <span id="L192" class="LineNr">192 </span> -<span id="L193" class="LineNr">193 </span>_test-stop-2: <span class="subxComment"># ed : (address exit-descriptor)</span> +<span id="L193" class="LineNr">193 </span><span class="subxMinorFunction">_test-stop-2</span>: <span class="subxComment"># ed : (address exit-descriptor)</span> <span id="L194" class="LineNr">194 </span> <span class="subxS1Comment"># . prolog</span> <span id="L195" class="LineNr">195 </span> 55/push-EBP <span id="L196" class="LineNr">196 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> diff --git a/html/subx/058read.subx.html b/html/subx/058read.subx.html index 9f17a3ed..ebb51fa0 100644 --- a/html/subx/058read.subx.html +++ b/html/subx/058read.subx.html @@ -23,6 +23,9 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } +.subxMinorFunction { color: #875f5f; } .Constant { color:#00a0a0; } .SpecialChar { color: #ff0000; } .subxH1Comment { color:#00ffff; } @@ -115,7 +118,7 @@ if ('onhashchange' in window) { <span id="L52" class="LineNr"> 52 </span> b8/copy-to-EAX 1/imm32 <span id="L53" class="LineNr"> 53 </span> cd/syscall 0x80/imm8 <span id="L54" class="LineNr"> 54 </span> -<span id="L55" class="LineNr"> 55 </span>read: <span class="subxComment"># f : fd or (address stream), s : (address stream) -> num-bytes-read/EAX</span> +<span id="L55" class="LineNr"> 55 </span><span class="subxFunction">read</span>: <span class="subxComment"># f : fd or (address stream), s : (address stream) -> num-bytes-read/EAX</span> <span id="L56" class="LineNr"> 56 </span> <span class="subxS1Comment"># . prolog</span> <span id="L57" class="LineNr"> 57 </span> 55/push-EBP <span id="L58" class="LineNr"> 58 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -131,7 +134,7 @@ if ('onhashchange' in window) { <span id="L68" class="LineNr"> 68 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> <span id="L69" class="LineNr"> 69 </span> <span class="subxComment"># return</span> <span id="L70" class="LineNr"> 70 </span> eb/jump $read:end/disp8 -<span id="L71" class="LineNr"> 71 </span>$read:fake: +<span id="L71" class="LineNr"> 71 </span><span class="Constant">$read:fake</span>: <span id="L72" class="LineNr"> 72 </span> <span class="subxComment"># otherwise, treat 'f' as a stream to scan from</span> <span id="L73" class="LineNr"> 73 </span> <span class="subxS1Comment"># . save registers</span> <span id="L74" class="LineNr"> 74 </span> 56/push-ESI @@ -169,7 +172,7 @@ if ('onhashchange' in window) { <span id="L106" class="LineNr">106 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L107" class="LineNr">107 </span> 5f/pop-to-EDI <span id="L108" class="LineNr">108 </span> 5e/pop-to-ESI -<span id="L109" class="LineNr">109 </span>$read:end: +<span id="L109" class="LineNr">109 </span><span class="Constant">$read:end</span>: <span id="L110" class="LineNr">110 </span> <span class="subxS1Comment"># . epilog</span> <span id="L111" class="LineNr">111 </span> 89/copy 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 5/r32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy EBP to ESP</span> <span id="L112" class="LineNr">112 </span> 5d/pop-to-EBP @@ -181,7 +184,7 @@ if ('onhashchange' in window) { <span id="L118" class="LineNr">118 </span><span class="subxComment"># Unclear how I'd use it, though. Callers seem to need the check anyway.</span> <span id="L119" class="LineNr">119 </span><span class="subxComment"># Maybe a better helper would be 'empty-stream?'</span> <span id="L120" class="LineNr">120 </span> -<span id="L121" class="LineNr">121 </span>_read: <span class="subxComment"># fd : int, s : (address stream) -> num-bytes-read/EAX</span> +<span id="L121" class="LineNr">121 </span><span class="subxMinorFunction">_read</span>: <span class="subxComment"># fd : int, s : (address stream) -> num-bytes-read/EAX</span> <span id="L122" class="LineNr">122 </span> <span class="subxS1Comment"># . prolog</span> <span id="L123" class="LineNr">123 </span> 55/push-EBP <span id="L124" class="LineNr">124 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -241,7 +244,7 @@ if ('onhashchange' in window) { <span id="L178" class="LineNr">178 </span> <span id="L179" class="LineNr">179 </span><span class="subxH1Comment"># - tests</span> <span id="L180" class="LineNr">180 </span> -<span id="L181" class="LineNr">181 </span>test-read-single: +<span id="L181" class="LineNr">181 </span><span class="subxTest">test-read-single</span>: <span id="L182" class="LineNr">182 </span> <span class="subxH1Comment"># - write a single character into _test-stream, then read from its buffered-file</span> <span id="L183" class="LineNr">183 </span> <span class="subxComment"># clear-stream(_test-stream)</span> <span id="L184" class="LineNr">184 </span> <span class="subxS2Comment"># . . push args</span> @@ -296,7 +299,7 @@ if ('onhashchange' in window) { <span id="L233" class="LineNr">233 </span> <span class="subxComment"># end</span> <span id="L234" class="LineNr">234 </span> c3/return <span id="L235" class="LineNr">235 </span> -<span id="L236" class="LineNr">236 </span>test-read-is-stateful: +<span id="L236" class="LineNr">236 </span><span class="subxTest">test-read-is-stateful</span>: <span id="L237" class="LineNr">237 </span> <span class="subxH1Comment"># - make two consecutive reads, check that their results are appended</span> <span id="L238" class="LineNr">238 </span> <span class="subxComment"># clear-stream(_test-stream)</span> <span id="L239" class="LineNr">239 </span> <span class="subxS2Comment"># . . push args</span> @@ -358,7 +361,7 @@ if ('onhashchange' in window) { <span id="L295" class="LineNr">295 </span> <span class="subxComment"># end</span> <span id="L296" class="LineNr">296 </span> c3/return <span id="L297" class="LineNr">297 </span> -<span id="L298" class="LineNr">298 </span>test-read-returns-0-on-end-of-file: +<span id="L298" class="LineNr">298 </span><span class="subxTest">test-read-returns-0-on-end-of-file</span>: <span id="L299" class="LineNr">299 </span> <span class="subxH1Comment"># - read after hitting end-of-file, check that result is 0</span> <span id="L300" class="LineNr">300 </span> <span class="subxComment"># setup</span> <span id="L301" class="LineNr">301 </span> <span class="subxS1Comment"># . clear-stream(_test-stream)</span> @@ -415,7 +418,7 @@ if ('onhashchange' in window) { <span id="L352" class="LineNr">352 </span> <span id="L353" class="LineNr">353 </span>== data <span id="L354" class="LineNr">354 </span> -<span id="L355" class="LineNr">355 </span>_test-stream-buffer: +<span id="L355" class="LineNr">355 </span><span class="subxMinorFunction">_test-stream-buffer</span>: <span id="L356" class="LineNr">356 </span> <span class="subxComment"># current write index</span> <span id="L357" class="LineNr">357 </span> 00 00 00 00 <span id="L358" class="LineNr">358 </span> <span class="subxComment"># current read index</span> diff --git a/html/subx/059read-byte.subx.html b/html/subx/059read-byte.subx.html index eb760dd4..c81434ac 100644 --- a/html/subx/059read-byte.subx.html +++ b/html/subx/059read-byte.subx.html @@ -23,6 +23,9 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .SpecialChar { color: #ff0000; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } +.subxMinorFunction { color: #875f5f; } .Constant { color:#00a0a0; } .CommentedCode { color: #6c6c6c; } .subxH1Comment { color:#00ffff; } @@ -104,7 +107,7 @@ if ('onhashchange' in window) { <span id="L41" class="LineNr"> 41 </span> <span id="L42" class="LineNr"> 42 </span><span class="subxComment"># return next byte value in EAX, with top 3 bytes cleared.</span> <span id="L43" class="LineNr"> 43 </span><span class="subxComment"># On EOF, return 0xffffffff.</span> -<span id="L44" class="LineNr"> 44 </span>read-byte: <span class="subxComment"># f : (address buffered-file) -> byte/EAX</span> +<span id="L44" class="LineNr"> 44 </span><span class="subxFunction">read-byte</span>: <span class="subxComment"># f : (address buffered-file) -> byte/EAX</span> <span id="L45" class="LineNr"> 45 </span> <span class="subxS1Comment"># . prolog</span> <span id="L46" class="LineNr"> 46 </span> 55/push-EBP <span id="L47" class="LineNr"> 47 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -140,14 +143,14 @@ if ('onhashchange' in window) { <span id="L77" class="LineNr"> 77 </span> 75/jump-if-not-equal $read-byte:from-stream/disp8 <span id="L78" class="LineNr"> 78 </span> b8/copy-to-EAX 0xffffffff/imm32 <span id="L79" class="LineNr"> 79 </span> eb/jump $read-byte:end/disp8 -<span id="L80" class="LineNr"> 80 </span>$read-byte:from-stream: +<span id="L80" class="LineNr"> 80 </span><span class="Constant">$read-byte:from-stream</span>: <span id="L81" class="LineNr"> 81 </span> <span class="subxComment"># reading from stream</span> <span id="L82" class="LineNr"> 82 </span> <span class="subxComment"># AL = f->data[f->read]</span> <span id="L83" class="LineNr"> 83 </span> 31/xor 3/mod/direct 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># clear EAX</span> <span id="L84" class="LineNr"> 84 </span> 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX <span class="CommentedCode"> . </span> 0/r32/AL 0x10/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(ESI+ECX+16) to AL</span> <span id="L85" class="LineNr"> 85 </span> <span class="subxComment"># ++f->read</span> <span id="L86" class="LineNr"> 86 </span> ff 0/subop/increment 1/mod/*+disp8 6/rm32/ESI <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 8/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># increment *(ESI+8)</span> -<span id="L87" class="LineNr"> 87 </span>$read-byte:end: +<span id="L87" class="LineNr"> 87 </span><span class="Constant">$read-byte:end</span>: <span id="L88" class="LineNr"> 88 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L89" class="LineNr"> 89 </span> 5e/pop-to-ESI <span id="L90" class="LineNr"> 90 </span> 59/pop-to-ECX @@ -161,7 +164,7 @@ if ('onhashchange' in window) { <span id="L98" class="LineNr"> 98 </span> <span id="L99" class="LineNr"> 99 </span><span class="subxH1Comment"># - tests</span> <span id="L100" class="LineNr">100 </span> -<span id="L101" class="LineNr">101 </span>test-read-byte-single: +<span id="L101" class="LineNr">101 </span><span class="subxTest">test-read-byte-single</span>: <span id="L102" class="LineNr">102 </span> <span class="subxH1Comment"># - check that read-byte returns first byte of 'file'</span> <span id="L103" class="LineNr">103 </span> <span class="subxComment"># setup</span> <span id="L104" class="LineNr">104 </span> <span class="subxS1Comment"># . clear-stream(_test-stream)</span> @@ -207,7 +210,7 @@ if ('onhashchange' in window) { <span id="L144" class="LineNr">144 </span> <span class="subxS1Comment"># . end</span> <span id="L145" class="LineNr">145 </span> c3/return <span id="L146" class="LineNr">146 </span> -<span id="L147" class="LineNr">147 </span>test-read-byte-multiple: +<span id="L147" class="LineNr">147 </span><span class="subxTest">test-read-byte-multiple</span>: <span id="L148" class="LineNr">148 </span> <span class="subxH1Comment"># - call read-byte twice, check that second call returns second byte</span> <span id="L149" class="LineNr">149 </span> <span class="subxComment"># setup</span> <span id="L150" class="LineNr">150 </span> <span class="subxS1Comment"># . clear-stream(_test-stream)</span> @@ -260,7 +263,7 @@ if ('onhashchange' in window) { <span id="L197" class="LineNr">197 </span> <span class="subxS1Comment"># . end</span> <span id="L198" class="LineNr">198 </span> c3/return <span id="L199" class="LineNr">199 </span> -<span id="L200" class="LineNr">200 </span>test-read-byte-end-of-file: +<span id="L200" class="LineNr">200 </span><span class="subxTest">test-read-byte-end-of-file</span>: <span id="L201" class="LineNr">201 </span> <span class="subxH1Comment"># - call read-byte on an empty 'file', check that it returns -1</span> <span id="L202" class="LineNr">202 </span> <span class="subxComment"># setup</span> <span id="L203" class="LineNr">203 </span> <span class="subxS1Comment"># . clear-stream(_test-stream)</span> @@ -300,7 +303,7 @@ if ('onhashchange' in window) { <span id="L237" class="LineNr">237 </span> <span id="L238" class="LineNr">238 </span>== data <span id="L239" class="LineNr">239 </span> -<span id="L240" class="LineNr">240 </span>_test-buffered-file: +<span id="L240" class="LineNr">240 </span><span class="subxMinorFunction">_test-buffered-file</span>: <span id="L241" class="LineNr">241 </span> <span class="subxComment"># file descriptor or (address stream)</span> <span id="L242" class="LineNr">242 </span> _test-stream/imm32 <span id="L243" class="LineNr">243 </span> <span class="subxComment"># current write index</span> diff --git a/html/subx/060write-stream.subx.html b/html/subx/060write-stream.subx.html index d8425da4..9b06b07b 100644 --- a/html/subx/060write-stream.subx.html +++ b/html/subx/060write-stream.subx.html @@ -23,6 +23,9 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } +.subxMinorFunction { color: #875f5f; } .Constant { color:#00a0a0; } .SpecialChar { color: #ff0000; } --> @@ -81,7 +84,7 @@ if ('onhashchange' in window) { <span id="L19" class="LineNr"> 19 </span> b8/copy-to-EAX 1/imm32 <span id="L20" class="LineNr"> 20 </span> cd/syscall 0x80/imm8 <span id="L21" class="LineNr"> 21 </span> -<span id="L22" class="LineNr"> 22 </span>write-stream: <span class="subxComment"># f : fd or (address stream), s : (address stream) -> <void></span> +<span id="L22" class="LineNr"> 22 </span><span class="subxFunction">write-stream</span>: <span class="subxComment"># f : fd or (address stream), s : (address stream) -> <void></span> <span id="L23" class="LineNr"> 23 </span> <span class="subxS1Comment"># . prolog</span> <span id="L24" class="LineNr"> 24 </span> 55/push-EBP <span id="L25" class="LineNr"> 25 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -96,7 +99,7 @@ if ('onhashchange' in window) { <span id="L34" class="LineNr"> 34 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L35" class="LineNr"> 35 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> <span id="L36" class="LineNr"> 36 </span> eb/jump $write-stream:end/disp8 -<span id="L37" class="LineNr"> 37 </span>$write-stream:fake: +<span id="L37" class="LineNr"> 37 </span><span class="Constant">$write-stream:fake</span>: <span id="L38" class="LineNr"> 38 </span> <span class="subxComment"># otherwise, treat 'f' as a stream to append to</span> <span id="L39" class="LineNr"> 39 </span> <span class="subxS1Comment"># . save registers</span> <span id="L40" class="LineNr"> 40 </span> 50/push-EAX @@ -135,13 +138,13 @@ if ('onhashchange' in window) { <span id="L73" class="LineNr"> 73 </span> 5f/pop-to-EDI <span id="L74" class="LineNr"> 74 </span> 5e/pop-to-ESI <span id="L75" class="LineNr"> 75 </span> 58/pop-to-EAX -<span id="L76" class="LineNr"> 76 </span>$write-stream:end: +<span id="L76" class="LineNr"> 76 </span><span class="Constant">$write-stream:end</span>: <span id="L77" class="LineNr"> 77 </span> <span class="subxS1Comment"># . epilog</span> <span id="L78" class="LineNr"> 78 </span> 89/copy 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 5/r32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy EBP to ESP</span> <span id="L79" class="LineNr"> 79 </span> 5d/pop-to-EBP <span id="L80" class="LineNr"> 80 </span> c3/return <span id="L81" class="LineNr"> 81 </span> -<span id="L82" class="LineNr"> 82 </span>_write-stream: <span class="subxComment"># fd : int, s : (address stream) -> <void></span> +<span id="L82" class="LineNr"> 82 </span><span class="subxMinorFunction">_write-stream</span>: <span class="subxComment"># fd : int, s : (address stream) -> <void></span> <span id="L83" class="LineNr"> 83 </span> <span class="subxS1Comment"># . prolog</span> <span id="L84" class="LineNr"> 84 </span> 55/push-EBP <span id="L85" class="LineNr"> 85 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -180,7 +183,7 @@ if ('onhashchange' in window) { <span id="L118" class="LineNr">118 </span> 5d/pop-to-EBP <span id="L119" class="LineNr">119 </span> c3/return <span id="L120" class="LineNr">120 </span> -<span id="L121" class="LineNr">121 </span>test-write-stream-single: +<span id="L121" class="LineNr">121 </span><span class="subxTest">test-write-stream-single</span>: <span id="L122" class="LineNr">122 </span> <span class="subxComment"># setup</span> <span id="L123" class="LineNr">123 </span> <span class="subxS1Comment"># . clear-stream(_test-stream)</span> <span id="L124" class="LineNr">124 </span> <span class="subxS2Comment"># . . push args</span> @@ -226,7 +229,7 @@ if ('onhashchange' in window) { <span id="L164" class="LineNr">164 </span> <span class="subxS1Comment"># . end</span> <span id="L165" class="LineNr">165 </span> c3/return <span id="L166" class="LineNr">166 </span> -<span id="L167" class="LineNr">167 </span>test-write-stream-appends: +<span id="L167" class="LineNr">167 </span><span class="subxTest">test-write-stream-appends</span>: <span id="L168" class="LineNr">168 </span> <span class="subxComment"># setup</span> <span id="L169" class="LineNr">169 </span> <span class="subxS1Comment"># . clear-stream(_test-stream)</span> <span id="L170" class="LineNr">170 </span> <span class="subxS2Comment"># . . push args</span> @@ -292,7 +295,7 @@ if ('onhashchange' in window) { <span id="L230" class="LineNr">230 </span> <span id="L231" class="LineNr">231 </span>== data <span id="L232" class="LineNr">232 </span> -<span id="L233" class="LineNr">233 </span>_test-stream2: +<span id="L233" class="LineNr">233 </span><span class="subxMinorFunction">_test-stream2</span>: <span id="L234" class="LineNr">234 </span> <span class="subxComment"># current write index</span> <span id="L235" class="LineNr">235 </span> 04 00 00 00 <span id="L236" class="LineNr">236 </span> <span class="subxComment"># current read index</span> diff --git a/html/subx/apps/crenshaw2-1.subx.html b/html/subx/apps/crenshaw2-1.subx.html index db1f08b6..05687d5e 100644 --- a/html/subx/apps/crenshaw2-1.subx.html +++ b/html/subx/apps/crenshaw2-1.subx.html @@ -24,6 +24,9 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } .Constant { color:#00a0a0; } +.subxFunction { color: #ff8700; } +.subxMinorFunction { color: #875f5f; } +.subxTest { color: #00af00; } .SpecialChar { color: #ff0000; } .subxH1Comment { color:#00ffff; } --> @@ -119,7 +122,7 @@ if ('onhashchange' in window) { <span id="L56" class="LineNr"> 56 </span> e8/call run-tests/disp32 <span id="L57" class="LineNr"> 57 </span> 8b/copy 0/mod/indirect 5/rm32/.disp32 <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 3/r32/EBX <span class="SpecialChar">Num-test-failures</span>/disp32 <span class="subxComment"># copy *Num-test-failures to EBX</span> <span id="L58" class="LineNr"> 58 </span> eb/jump $main:end/disp8 -<span id="L59" class="LineNr"> 59 </span>$run-main: +<span id="L59" class="LineNr"> 59 </span><span class="Constant">$run-main</span>: <span id="L60" class="LineNr"> 60 </span> <span class="subxH1Comment"># - otherwise read a program from stdin and emit its translation to stdout</span> <span id="L61" class="LineNr"> 61 </span> <span class="subxComment"># var ed/EAX : exit-descriptor</span> <span id="L62" class="LineNr"> 62 </span> 81 5/subop/subtract 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 8/imm32 <span class="subxComment"># subtract from ESP</span> @@ -139,12 +142,12 @@ if ('onhashchange' in window) { <span id="L76" class="LineNr"> 76 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0x10/imm32 <span class="subxComment"># add to ESP</span> <span id="L77" class="LineNr"> 77 </span> <span class="subxS1Comment"># . syscall(exit, 0)</span> <span id="L78" class="LineNr"> 78 </span> bb/copy-to-EBX 0/imm32 -<span id="L79" class="LineNr"> 79 </span>$main:end: +<span id="L79" class="LineNr"> 79 </span><span class="Constant">$main:end</span>: <span id="L80" class="LineNr"> 80 </span> b8/copy-to-EAX 1/imm32/exit <span id="L81" class="LineNr"> 81 </span> cd/syscall 0x80/imm8 <span id="L82" class="LineNr"> 82 </span> <span id="L83" class="LineNr"> 83 </span><span class="subxComment"># the main entry point</span> -<span id="L84" class="LineNr"> 84 </span>compile: <span class="subxComment"># in : (address buffered-file), out : fd or (address stream), err : fd or (address stream), ed : (address exit-descriptor) -> <void></span> +<span id="L84" class="LineNr"> 84 </span><span class="subxFunction">compile</span>: <span class="subxComment"># in : (address buffered-file), out : fd or (address stream), err : fd or (address stream), ed : (address exit-descriptor) -> <void></span> <span id="L85" class="LineNr"> 85 </span> <span class="subxS1Comment"># . prolog</span> <span id="L86" class="LineNr"> 86 </span> 55/push-EBP <span id="L87" class="LineNr"> 87 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -258,7 +261,7 @@ if ('onhashchange' in window) { <span id="L195" class="LineNr">195 </span><span class="subxComment"># Read a single digit into 'out'. Abort if there are none, or if there is no space in 'out'.</span> <span id="L196" class="LineNr">196 </span><span class="subxComment"># Input comes from the global variable 'Look', and we leave the next byte from</span> <span id="L197" class="LineNr">197 </span><span class="subxComment"># 'in' into it on exit.</span> -<span id="L198" class="LineNr">198 </span>get-num: <span class="subxComment"># in : (address buffered-file), out : (address stream), err : fd or (address stream), ed : (address exit-descriptor) -> <void></span> +<span id="L198" class="LineNr">198 </span><span class="subxFunction">get-num</span>: <span class="subxComment"># in : (address buffered-file), out : (address stream), err : fd or (address stream), ed : (address exit-descriptor) -> <void></span> <span id="L199" class="LineNr">199 </span> <span class="subxComment"># pseudocode:</span> <span id="L200" class="LineNr">200 </span> <span class="subxComment"># if !is-digit?(Look) expected(ed, err, "integer")</span> <span id="L201" class="LineNr">201 </span> <span class="subxComment"># if out.write >= out.length</span> @@ -302,7 +305,7 @@ if ('onhashchange' in window) { <span id="L239" class="LineNr">239 </span> e8/call expected/disp32 <span class="subxComment"># never returns</span> <span id="L240" class="LineNr">240 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L241" class="LineNr">241 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> -<span id="L242" class="LineNr">242 </span>$get-num:main: +<span id="L242" class="LineNr">242 </span><span class="Constant">$get-num:main</span>: <span id="L243" class="LineNr">243 </span> <span class="subxH1Comment"># - otherwise read a digit</span> <span id="L244" class="LineNr">244 </span> <span class="subxS1Comment"># . save registers</span> <span id="L245" class="LineNr">245 </span> 50/push-EAX @@ -332,7 +335,7 @@ if ('onhashchange' in window) { <span id="L269" class="LineNr">269 </span> e8/call error/disp32 <span class="subxComment"># never returns</span> <span id="L270" class="LineNr">270 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L271" class="LineNr">271 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> -<span id="L272" class="LineNr">272 </span>$get-num:stage2: +<span id="L272" class="LineNr">272 </span><span class="Constant">$get-num:stage2</span>: <span id="L273" class="LineNr">273 </span> <span class="subxComment"># out->data[out->write] = LSB(Look)</span> <span id="L274" class="LineNr">274 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 1/index/ECX <span class="CommentedCode"> . </span> 3/r32/EBX 0xc/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy EDI+ECX+12 to EBX</span> <span id="L275" class="LineNr">275 </span> 8b/copy 0/mod/indirect 5/rm32/.disp32 <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="SpecialChar">Look</span>/disp32 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *Look to EAX</span> @@ -346,7 +349,7 @@ if ('onhashchange' in window) { <span id="L283" class="LineNr">283 </span> e8/call get-char/disp32 <span id="L284" class="LineNr">284 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L285" class="LineNr">285 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/imm32 <span class="subxComment"># add to ESP</span> -<span id="L286" class="LineNr">286 </span>$get-num:loop-end: +<span id="L286" class="LineNr">286 </span><span class="Constant">$get-num:loop-end</span>: <span id="L287" class="LineNr">287 </span> <span class="subxComment"># persist necessary variables from registers</span> <span id="L288" class="LineNr">288 </span> 89/copy 0/mod/indirect 7/rm32/EDI <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 1/r32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ECX to *EDI</span> <span id="L289" class="LineNr">289 </span> <span class="subxS1Comment"># . restore registers</span> @@ -361,7 +364,7 @@ if ('onhashchange' in window) { <span id="L298" class="LineNr">298 </span> 5d/pop-to-EBP <span id="L299" class="LineNr">299 </span> c3/return <span id="L300" class="LineNr">300 </span> -<span id="L301" class="LineNr">301 </span>test-get-num-reads-single-digit: +<span id="L301" class="LineNr">301 </span><span class="subxTest">test-get-num-reads-single-digit</span>: <span id="L302" class="LineNr">302 </span> <span class="subxH1Comment"># - check that get-num returns first character if it's a digit</span> <span id="L303" class="LineNr">303 </span> <span class="subxComment"># This test uses exit-descriptors. Use EBP for setting up local variables.</span> <span id="L304" class="LineNr">304 </span> 55/push-EBP @@ -452,7 +455,7 @@ if ('onhashchange' in window) { <span id="L389" class="LineNr">389 </span> 5d/pop-to-EBP <span id="L390" class="LineNr">390 </span> c3/return <span id="L391" class="LineNr">391 </span> -<span id="L392" class="LineNr">392 </span>test-get-num-aborts-on-non-digit-in-Look: +<span id="L392" class="LineNr">392 </span><span class="subxTest">test-get-num-aborts-on-non-digit-in-Look</span>: <span id="L393" class="LineNr">393 </span> <span class="subxH1Comment"># - check that get-num returns first character if it's a digit</span> <span id="L394" class="LineNr">394 </span> <span class="subxComment"># This test uses exit-descriptors. Use EBP for setting up local variables.</span> <span id="L395" class="LineNr">395 </span> 55/push-EBP @@ -540,7 +543,7 @@ if ('onhashchange' in window) { <span id="L477" class="LineNr">477 </span><span class="subxComment">## helpers</span> <span id="L478" class="LineNr">478 </span> <span id="L479" class="LineNr">479 </span><span class="subxComment"># write(f, "Error: "+s+" expected\n") then stop(ed, 1)</span> -<span id="L480" class="LineNr">480 </span>expected: <span class="subxComment"># ed : (address exit-descriptor), f : fd or (address stream), s : (address array byte) -> <void></span> +<span id="L480" class="LineNr">480 </span><span class="subxFunction">expected</span>: <span class="subxComment"># ed : (address exit-descriptor), f : fd or (address stream), s : (address array byte) -> <void></span> <span id="L481" class="LineNr">481 </span> <span class="subxS1Comment"># . prolog</span> <span id="L482" class="LineNr">482 </span> 55/push-EBP <span id="L483" class="LineNr">483 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -589,7 +592,7 @@ if ('onhashchange' in window) { <span id="L526" class="LineNr">526 </span> c3/return <span id="L527" class="LineNr">527 </span> <span id="L528" class="LineNr">528 </span><span class="subxComment"># write(f, "Error: "+s+"\n") then stop(ed, 1)</span> -<span id="L529" class="LineNr">529 </span>error: <span class="subxComment"># ed : (address exit-descriptor), f : fd or (address stream), s : (address array byte) -> <void></span> +<span id="L529" class="LineNr">529 </span><span class="subxFunction">error</span>: <span class="subxComment"># ed : (address exit-descriptor), f : fd or (address stream), s : (address array byte) -> <void></span> <span id="L530" class="LineNr">530 </span> <span class="subxS1Comment"># . prolog</span> <span id="L531" class="LineNr">531 </span> 55/push-EBP <span id="L532" class="LineNr">532 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -630,7 +633,7 @@ if ('onhashchange' in window) { <span id="L567" class="LineNr">567 </span> c3/return <span id="L568" class="LineNr">568 </span> <span id="L569" class="LineNr">569 </span><span class="subxComment"># read a byte from 'f', and save it in 'Look'</span> -<span id="L570" class="LineNr">570 </span>get-char: <span class="subxComment"># f : (address buffered-file) -> <void></span> +<span id="L570" class="LineNr">570 </span><span class="subxFunction">get-char</span>: <span class="subxComment"># f : (address buffered-file) -> <void></span> <span id="L571" class="LineNr">571 </span> <span class="subxS1Comment"># . prolog</span> <span id="L572" class="LineNr">572 </span> 55/push-EBP <span id="L573" class="LineNr">573 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -677,7 +680,7 @@ if ('onhashchange' in window) { <span id="L614" class="LineNr">614 </span><span class="SpecialChar">Look</span>: <span class="subxComment"># (char)</span> <span id="L615" class="LineNr">615 </span> 00 00 00 00 <span class="subxComment"># = 0</span> <span id="L616" class="LineNr">616 </span> -<span id="L617" class="LineNr">617 </span>_test-output-stream: +<span id="L617" class="LineNr">617 </span><span class="subxMinorFunction">_test-output-stream</span>: <span id="L618" class="LineNr">618 </span> <span class="subxComment"># current write index</span> <span id="L619" class="LineNr">619 </span> 00 00 00 00 <span id="L620" class="LineNr">620 </span> <span class="subxComment"># current read index</span> @@ -687,7 +690,7 @@ if ('onhashchange' in window) { <span id="L624" class="LineNr">624 </span> <span class="subxComment"># data</span> <span id="L625" class="LineNr">625 </span> 00 00 00 00 00 00 00 00 <span class="subxComment"># 8 bytes</span> <span id="L626" class="LineNr">626 </span> -<span id="L627" class="LineNr">627 </span>_test-error-stream: +<span id="L627" class="LineNr">627 </span><span class="subxMinorFunction">_test-error-stream</span>: <span id="L628" class="LineNr">628 </span> <span class="subxComment"># current write index</span> <span id="L629" class="LineNr">629 </span> 00 00 00 00 <span id="L630" class="LineNr">630 </span> <span class="subxComment"># current read index</span> diff --git a/html/subx/apps/crenshaw2-1b.subx.html b/html/subx/apps/crenshaw2-1b.subx.html index 77d9d41a..9fad66d8 100644 --- a/html/subx/apps/crenshaw2-1b.subx.html +++ b/html/subx/apps/crenshaw2-1b.subx.html @@ -24,6 +24,9 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } .Constant { color:#00a0a0; } +.subxFunction { color: #ff8700; } +.subxMinorFunction { color: #875f5f; } +.subxTest { color: #00af00; } .SpecialChar { color: #ff0000; } .subxH1Comment { color:#00ffff; } --> @@ -119,7 +122,7 @@ if ('onhashchange' in window) { <span id="L56" class="LineNr"> 56 </span> e8/call run-tests/disp32 <span id="L57" class="LineNr"> 57 </span> 8b/copy 0/mod/indirect 5/rm32/.disp32 <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 3/r32/EBX <span class="SpecialChar">Num-test-failures</span>/disp32 <span class="subxComment"># copy *Num-test-failures to EBX</span> <span id="L58" class="LineNr"> 58 </span> eb/jump $main:end/disp8 -<span id="L59" class="LineNr"> 59 </span>$run-main: +<span id="L59" class="LineNr"> 59 </span><span class="Constant">$run-main</span>: <span id="L60" class="LineNr"> 60 </span> <span class="subxH1Comment"># - otherwise read a program from stdin and emit its translation to stdout</span> <span id="L61" class="LineNr"> 61 </span> <span class="subxComment"># var ed/EAX : exit-descriptor</span> <span id="L62" class="LineNr"> 62 </span> 81 5/subop/subtract 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 8/imm32 <span class="subxComment"># subtract from ESP</span> @@ -139,12 +142,12 @@ if ('onhashchange' in window) { <span id="L76" class="LineNr"> 76 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0x10/imm32 <span class="subxComment"># add to ESP</span> <span id="L77" class="LineNr"> 77 </span> <span class="subxS1Comment"># . syscall(exit, 0)</span> <span id="L78" class="LineNr"> 78 </span> bb/copy-to-EBX 0/imm32 -<span id="L79" class="LineNr"> 79 </span>$main:end: +<span id="L79" class="LineNr"> 79 </span><span class="Constant">$main:end</span>: <span id="L80" class="LineNr"> 80 </span> b8/copy-to-EAX 1/imm32/exit <span id="L81" class="LineNr"> 81 </span> cd/syscall 0x80/imm8 <span id="L82" class="LineNr"> 82 </span> <span id="L83" class="LineNr"> 83 </span><span class="subxComment"># the main entry point</span> -<span id="L84" class="LineNr"> 84 </span>compile: <span class="subxComment"># in : (address buffered-file), out : fd or (address stream), err : fd or (address stream), ed : (address exit-descriptor) -> <void></span> +<span id="L84" class="LineNr"> 84 </span><span class="subxFunction">compile</span>: <span class="subxComment"># in : (address buffered-file), out : fd or (address stream), err : fd or (address stream), ed : (address exit-descriptor) -> <void></span> <span id="L85" class="LineNr"> 85 </span> <span class="subxS1Comment"># . prolog</span> <span id="L86" class="LineNr"> 86 </span> 55/push-EBP <span id="L87" class="LineNr"> 87 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -260,7 +263,7 @@ if ('onhashchange' in window) { <span id="L197" class="LineNr">197 </span><span class="subxComment"># no space in 'out'.</span> <span id="L198" class="LineNr">198 </span><span class="subxComment"># Input comes from the global variable 'Look' (first byte) and the argument</span> <span id="L199" class="LineNr">199 </span><span class="subxComment"># 'in' (rest). We leave the next byte from 'in' into 'Look' on exit.</span> -<span id="L200" class="LineNr">200 </span>get-num: <span class="subxComment"># in : (address buffered-file), out : (address stream), err : fd or (address stream), ed : (address exit-descriptor) -> <void></span> +<span id="L200" class="LineNr">200 </span><span class="subxFunction">get-num</span>: <span class="subxComment"># in : (address buffered-file), out : (address stream), err : fd or (address stream), ed : (address exit-descriptor) -> <void></span> <span id="L201" class="LineNr">201 </span> <span class="subxComment"># pseudocode:</span> <span id="L202" class="LineNr">202 </span> <span class="subxComment"># if !is-digit?(Look) expected(ed, err, "integer")</span> <span id="L203" class="LineNr">203 </span> <span class="subxComment"># do</span> @@ -308,7 +311,7 @@ if ('onhashchange' in window) { <span id="L245" class="LineNr">245 </span> e8/call expected/disp32 <span class="subxComment"># never returns</span> <span id="L246" class="LineNr">246 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L247" class="LineNr">247 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> -<span id="L248" class="LineNr">248 </span>$get-num:main: +<span id="L248" class="LineNr">248 </span><span class="Constant">$get-num:main</span>: <span id="L249" class="LineNr">249 </span> <span class="subxH1Comment"># - otherwise read a digit</span> <span id="L250" class="LineNr">250 </span> <span class="subxS1Comment"># . save registers</span> <span id="L251" class="LineNr">251 </span> 50/push-EAX @@ -326,7 +329,7 @@ if ('onhashchange' in window) { <span id="L263" class="LineNr">263 </span> 8b/copy 0/mod/indirect 7/rm32/EDI <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 1/r32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy *EDI to ECX</span> <span id="L264" class="LineNr">264 </span> <span class="subxComment"># EDX = out->length</span> <span id="L265" class="LineNr">265 </span> 8b/copy 1/mod/*+disp8 7/rm32/EDI <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 2/r32/EDX 8/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(EDI+8) to EDX</span> -<span id="L266" class="LineNr">266 </span>$get-num:loop: +<span id="L266" class="LineNr">266 </span><span class="Constant">$get-num:loop</span>: <span id="L267" class="LineNr">267 </span> <span class="subxComment"># if out->write >= out->length error</span> <span id="L268" class="LineNr">268 </span> 3b/compare 3/mod/direct 1/rm32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 2/r32/EDX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># compare EDX with ECX</span> <span id="L269" class="LineNr">269 </span> 7d/jump-if-lesser $get-num:loop-stage2/disp8 @@ -339,7 +342,7 @@ if ('onhashchange' in window) { <span id="L276" class="LineNr">276 </span> e8/call error/disp32 <span class="subxComment"># never returns</span> <span id="L277" class="LineNr">277 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L278" class="LineNr">278 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> -<span id="L279" class="LineNr">279 </span>$get-num:loop-stage2: +<span id="L279" class="LineNr">279 </span><span class="Constant">$get-num:loop-stage2</span>: <span id="L280" class="LineNr">280 </span> <span class="subxComment"># out->data[out->write] = LSB(Look)</span> <span id="L281" class="LineNr">281 </span> 8d/copy-address 1/mod/*+disp8 4/rm32/sib 7/base/EDI 1/index/ECX <span class="CommentedCode"> . </span> 3/r32/EBX 0xc/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy EDI+ECX+12 to EBX</span> <span id="L282" class="LineNr">282 </span> 8b/copy 0/mod/indirect 5/rm32/.disp32 <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="SpecialChar">Look</span>/disp32 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *Look to EAX</span> @@ -364,7 +367,7 @@ if ('onhashchange' in window) { <span id="L301" class="LineNr">301 </span> <span class="subxS1Comment"># . if EAX loop</span> <span id="L302" class="LineNr">302 </span> 3d/compare-EAX 0/imm32 <span id="L303" class="LineNr">303 </span> 0f 85/jump-if-not-equal $get-num:loop/disp32 -<span id="L304" class="LineNr">304 </span>$get-num:loop-end: +<span id="L304" class="LineNr">304 </span><span class="Constant">$get-num:loop-end</span>: <span id="L305" class="LineNr">305 </span> <span class="subxComment"># persist necessary variables from registers</span> <span id="L306" class="LineNr">306 </span> 89/copy 0/mod/indirect 7/rm32/EDI <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 1/r32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ECX to *EDI</span> <span id="L307" class="LineNr">307 </span> <span class="subxS1Comment"># . restore registers</span> @@ -379,7 +382,7 @@ if ('onhashchange' in window) { <span id="L316" class="LineNr">316 </span> 5d/pop-to-EBP <span id="L317" class="LineNr">317 </span> c3/return <span id="L318" class="LineNr">318 </span> -<span id="L319" class="LineNr">319 </span>test-get-num-reads-single-digit: +<span id="L319" class="LineNr">319 </span><span class="subxTest">test-get-num-reads-single-digit</span>: <span id="L320" class="LineNr">320 </span> <span class="subxH1Comment"># - check that get-num returns first character if it's a digit</span> <span id="L321" class="LineNr">321 </span> <span class="subxComment"># This test uses exit-descriptors. Use EBP for setting up local variables.</span> <span id="L322" class="LineNr">322 </span> 55/push-EBP @@ -470,7 +473,7 @@ if ('onhashchange' in window) { <span id="L407" class="LineNr">407 </span> 5d/pop-to-EBP <span id="L408" class="LineNr">408 </span> c3/return <span id="L409" class="LineNr">409 </span> -<span id="L410" class="LineNr">410 </span>test-get-num-aborts-on-non-digit-in-Look: +<span id="L410" class="LineNr">410 </span><span class="subxTest">test-get-num-aborts-on-non-digit-in-Look</span>: <span id="L411" class="LineNr">411 </span> <span class="subxH1Comment"># - check that get-num returns first character if it's a digit</span> <span id="L412" class="LineNr">412 </span> <span class="subxComment"># This test uses exit-descriptors. Use EBP for setting up local variables.</span> <span id="L413" class="LineNr">413 </span> 55/push-EBP @@ -555,7 +558,7 @@ if ('onhashchange' in window) { <span id="L492" class="LineNr">492 </span> 5d/pop-to-EBP <span id="L493" class="LineNr">493 </span> c3/return <span id="L494" class="LineNr">494 </span> -<span id="L495" class="LineNr">495 </span>test-get-num-reads-multiple-digits: +<span id="L495" class="LineNr">495 </span><span class="subxTest">test-get-num-reads-multiple-digits</span>: <span id="L496" class="LineNr">496 </span> <span class="subxH1Comment"># - check that get-num returns all initial digits until it encounters a non-digit</span> <span id="L497" class="LineNr">497 </span> <span class="subxComment"># This test uses exit-descriptors. Use EBP for setting up local variables.</span> <span id="L498" class="LineNr">498 </span> 55/push-EBP @@ -646,7 +649,7 @@ if ('onhashchange' in window) { <span id="L583" class="LineNr">583 </span> 5d/pop-to-EBP <span id="L584" class="LineNr">584 </span> c3/return <span id="L585" class="LineNr">585 </span> -<span id="L586" class="LineNr">586 </span>test-get-num-reads-multiple-digits-followed-by-nondigit: +<span id="L586" class="LineNr">586 </span><span class="subxTest">test-get-num-reads-multiple-digits-followed-by-nondigit</span>: <span id="L587" class="LineNr">587 </span> <span class="subxH1Comment"># - check that get-num returns all initial digits until it encounters a non-digit</span> <span id="L588" class="LineNr">588 </span> <span class="subxComment"># This test uses exit-descriptors. Use EBP for setting up local variables.</span> <span id="L589" class="LineNr">589 </span> 55/push-EBP @@ -740,7 +743,7 @@ if ('onhashchange' in window) { <span id="L677" class="LineNr">677 </span><span class="subxComment">## helpers</span> <span id="L678" class="LineNr">678 </span> <span id="L679" class="LineNr">679 </span><span class="subxComment"># write(f, "Error: "+s+" expected\n") then stop(ed, 1)</span> -<span id="L680" class="LineNr">680 </span>expected: <span class="subxComment"># ed : (address exit-descriptor), f : fd or (address stream), s : (address array byte) -> <void></span> +<span id="L680" class="LineNr">680 </span><span class="subxFunction">expected</span>: <span class="subxComment"># ed : (address exit-descriptor), f : fd or (address stream), s : (address array byte) -> <void></span> <span id="L681" class="LineNr">681 </span> <span class="subxS1Comment"># . prolog</span> <span id="L682" class="LineNr">682 </span> 55/push-EBP <span id="L683" class="LineNr">683 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -789,7 +792,7 @@ if ('onhashchange' in window) { <span id="L726" class="LineNr">726 </span> c3/return <span id="L727" class="LineNr">727 </span> <span id="L728" class="LineNr">728 </span><span class="subxComment"># write(f, "Error: "+s+"\n") then stop(ed, 1)</span> -<span id="L729" class="LineNr">729 </span>error: <span class="subxComment"># ed : (address exit-descriptor), f : fd or (address stream), s : (address array byte) -> <void></span> +<span id="L729" class="LineNr">729 </span><span class="subxFunction">error</span>: <span class="subxComment"># ed : (address exit-descriptor), f : fd or (address stream), s : (address array byte) -> <void></span> <span id="L730" class="LineNr">730 </span> <span class="subxS1Comment"># . prolog</span> <span id="L731" class="LineNr">731 </span> 55/push-EBP <span id="L732" class="LineNr">732 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -830,7 +833,7 @@ if ('onhashchange' in window) { <span id="L767" class="LineNr">767 </span> c3/return <span id="L768" class="LineNr">768 </span> <span id="L769" class="LineNr">769 </span><span class="subxComment"># read a byte from 'f', and save it in 'Look'</span> -<span id="L770" class="LineNr">770 </span>get-char: <span class="subxComment"># f : (address buffered-file) -> <void></span> +<span id="L770" class="LineNr">770 </span><span class="subxFunction">get-char</span>: <span class="subxComment"># f : (address buffered-file) -> <void></span> <span id="L771" class="LineNr">771 </span> <span class="subxS1Comment"># . prolog</span> <span id="L772" class="LineNr">772 </span> 55/push-EBP <span id="L773" class="LineNr">773 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -877,7 +880,7 @@ if ('onhashchange' in window) { <span id="L814" class="LineNr">814 </span><span class="SpecialChar">Look</span>: <span class="subxComment"># (char)</span> <span id="L815" class="LineNr">815 </span> 00 00 00 00 <span class="subxComment"># = 0</span> <span id="L816" class="LineNr">816 </span> -<span id="L817" class="LineNr">817 </span>_test-output-stream: +<span id="L817" class="LineNr">817 </span><span class="subxMinorFunction">_test-output-stream</span>: <span id="L818" class="LineNr">818 </span> <span class="subxComment"># current write index</span> <span id="L819" class="LineNr">819 </span> 00 00 00 00 <span id="L820" class="LineNr">820 </span> <span class="subxComment"># current read index</span> @@ -887,7 +890,7 @@ if ('onhashchange' in window) { <span id="L824" class="LineNr">824 </span> <span class="subxComment"># data</span> <span id="L825" class="LineNr">825 </span> 00 00 00 00 00 00 00 00 <span class="subxComment"># 8 bytes</span> <span id="L826" class="LineNr">826 </span> -<span id="L827" class="LineNr">827 </span>_test-error-stream: +<span id="L827" class="LineNr">827 </span><span class="subxMinorFunction">_test-error-stream</span>: <span id="L828" class="LineNr">828 </span> <span class="subxComment"># current write index</span> <span id="L829" class="LineNr">829 </span> 00 00 00 00 <span id="L830" class="LineNr">830 </span> <span class="subxComment"># current read index</span> diff --git a/html/subx/apps/factorial.subx.html b/html/subx/apps/factorial.subx.html index 7e43deaf..7cee2ff1 100644 --- a/html/subx/apps/factorial.subx.html +++ b/html/subx/apps/factorial.subx.html @@ -24,6 +24,8 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } .Constant { color:#00a0a0; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } .SpecialChar { color: #ff0000; } .subxH1Comment { color:#00ffff; } --> @@ -105,20 +107,20 @@ if ('onhashchange' in window) { <span id="L42" class="LineNr"> 42 </span> 8b/copy 0/mod/indirect 5/rm32/.disp32 <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="SpecialChar">Num-test-failures</span>/disp32 <span class="subxComment"># copy *Num-test-failures to EAX</span> <span id="L43" class="LineNr"> 43 </span> eb/jump $main:end/disp8 <span class="subxComment"># where EAX will get copied to EBX</span> <span id="L44" class="LineNr"> 44 </span> <span class="subxH1Comment"># - otherwise return factorial(5)</span> -<span id="L45" class="LineNr"> 45 </span>$run-main: +<span id="L45" class="LineNr"> 45 </span><span class="Constant">$run-main</span>: <span id="L46" class="LineNr"> 46 </span> <span class="subxS2Comment"># . . push args</span> <span id="L47" class="LineNr"> 47 </span> 68/push 5/imm32 <span id="L48" class="LineNr"> 48 </span> <span class="subxS2Comment"># . . call</span> <span id="L49" class="LineNr"> 49 </span> e8/call factorial/disp32 <span id="L50" class="LineNr"> 50 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L51" class="LineNr"> 51 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/imm32 <span class="subxComment"># add to ESP</span> -<span id="L52" class="LineNr"> 52 </span>$main:end: +<span id="L52" class="LineNr"> 52 </span><span class="Constant">$main:end</span>: <span id="L53" class="LineNr"> 53 </span> <span class="subxComment"># syscall(exit, EAX)</span> <span id="L54" class="LineNr"> 54 </span> 89/copy 3/mod/direct 3/rm32/EBX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy EAX to EBX</span> <span id="L55" class="LineNr"> 55 </span> b8/copy-to-EAX 1/imm32 <span id="L56" class="LineNr"> 56 </span> cd/syscall 0x80/imm8 <span id="L57" class="LineNr"> 57 </span> -<span id="L58" class="LineNr"> 58 </span>factorial: <span class="subxComment"># n : int -> int/EAX</span> +<span id="L58" class="LineNr"> 58 </span><span class="subxFunction">factorial</span>: <span class="subxComment"># n : int -> int/EAX</span> <span id="L59" class="LineNr"> 59 </span> <span class="subxS1Comment"># . prolog</span> <span id="L60" class="LineNr"> 60 </span> 55/push-EBP <span id="L61" class="LineNr"> 61 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -141,14 +143,14 @@ if ('onhashchange' in window) { <span id="L78" class="LineNr"> 78 </span> <span class="subxComment"># return n * factorial(n-1)</span> <span id="L79" class="LineNr"> 79 </span> f7 4/subop/multiply 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none 8/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># multiply *(EBP+8) into EAX</span> <span id="L80" class="LineNr"> 80 </span> <span class="subxComment"># TODO: check for overflow</span> -<span id="L81" class="LineNr"> 81 </span>$factorial:end: +<span id="L81" class="LineNr"> 81 </span><span class="Constant">$factorial:end</span>: <span id="L82" class="LineNr"> 82 </span> <span class="subxS1Comment"># . epilog</span> <span id="L83" class="LineNr"> 83 </span> 5b/pop-to-EBX <span id="L84" class="LineNr"> 84 </span> 89/copy 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 5/r32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy EBP to ESP</span> <span id="L85" class="LineNr"> 85 </span> 5d/pop-to-EBP <span id="L86" class="LineNr"> 86 </span> c3/return <span id="L87" class="LineNr"> 87 </span> -<span id="L88" class="LineNr"> 88 </span>test-factorial: +<span id="L88" class="LineNr"> 88 </span><span class="subxTest">test-factorial</span>: <span id="L89" class="LineNr"> 89 </span> <span class="subxComment"># factorial(5)</span> <span id="L90" class="LineNr"> 90 </span> <span class="subxS2Comment"># . . push args</span> <span id="L91" class="LineNr"> 91 </span> 68/push 5/imm32 diff --git a/html/subx/examples/ex10.subx.html b/html/subx/examples/ex10.subx.html index f0f582f2..55b1c177 100644 --- a/html/subx/examples/ex10.subx.html +++ b/html/subx/examples/ex10.subx.html @@ -23,6 +23,8 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } +.Constant { color:#00a0a0; } --> </style> @@ -94,12 +96,12 @@ if ('onhashchange' in window) { <span id="L34" class="LineNr">34 </span> <span id="L35" class="LineNr">35 </span><span class="subxComment"># compare two null-terminated ascii strings</span> <span id="L36" class="LineNr">36 </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="L37" class="LineNr">37 </span>argv-equal: <span class="subxComment"># (s1, s2) : null-terminated ascii strings -> EAX : boolean</span> +<span id="L37" class="LineNr">37 </span><span class="subxFunction">argv-equal</span>: <span class="subxComment"># (s1, s2) : null-terminated ascii strings -> EAX : boolean</span> <span id="L38" class="LineNr">38 </span> <span class="subxComment"># initialize s1 (ECX) and s2 (EDX)</span> <span id="L39" class="LineNr">39 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none <span class="CommentedCode"> . </span> 1/r32/ECX 4/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(ESP+4) to ECX</span> <span id="L40" class="LineNr">40 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none <span class="CommentedCode"> . </span> 2/r32/EDX 8/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(ESP+8) to EDX</span> <span id="L41" class="LineNr">41 </span> <span class="subxComment"># while (true)</span> -<span id="L42" class="LineNr">42 </span>$argv-equal:loop: +<span id="L42" class="LineNr">42 </span><span class="Constant">$argv-equal:loop</span>: <span id="L43" class="LineNr">43 </span> <span class="subxComment"># c1/EAX, c2/EBX = *s1, *s2</span> <span id="L44" class="LineNr">44 </span> b8/copy-to-EAX 0/imm32 <span id="L45" class="LineNr">45 </span> 8a/copy 0/mod/indirect 1/rm32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy byte at *ECX to lower byte of EAX</span> @@ -116,15 +118,15 @@ if ('onhashchange' in window) { <span id="L56" class="LineNr">56 </span> 42/inc-EDX <span id="L57" class="LineNr">57 </span> <span class="subxComment"># end while</span> <span id="L58" class="LineNr">58 </span> eb/jump $argv-equal:loop/disp8 -<span id="L59" class="LineNr">59 </span>$argv-equal:break: +<span id="L59" class="LineNr">59 </span><span class="Constant">$argv-equal:break</span>: <span id="L60" class="LineNr">60 </span> <span class="subxComment"># if (c2 == 0) return true</span> <span id="L61" class="LineNr">61 </span> 81 7/subop/compare 3/mod/direct 3/rm32/EBX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/imm32 <span class="subxComment"># compare EBX</span> <span id="L62" class="LineNr">62 </span> 75/jump-if-not-equal $argv-equal:false/disp8 -<span id="L63" class="LineNr">63 </span>$argv-equal:success: +<span id="L63" class="LineNr">63 </span><span class="Constant">$argv-equal:success</span>: <span id="L64" class="LineNr">64 </span> b8/copy-to-EAX 1/imm32 <span id="L65" class="LineNr">65 </span> c3/return <span id="L66" class="LineNr">66 </span> <span class="subxComment"># return false</span> -<span id="L67" class="LineNr">67 </span>$argv-equal:false: +<span id="L67" class="LineNr">67 </span><span class="Constant">$argv-equal:false</span>: <span id="L68" class="LineNr">68 </span> b8/copy-to-EAX 0/imm32 <span id="L69" class="LineNr">69 </span> c3/return <span id="L70" class="LineNr">70 </span> diff --git a/html/subx/examples/ex11.subx.html b/html/subx/examples/ex11.subx.html index 9749967e..9ea97266 100644 --- a/html/subx/examples/ex11.subx.html +++ b/html/subx/examples/ex11.subx.html @@ -23,6 +23,8 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } +.subxTest { color: #00af00; } .Constant { color:#00a0a0; } .SpecialChar { color: #ff0000; } .subxH1Comment { color:#00ffff; } @@ -91,7 +93,7 @@ if ('onhashchange' in window) { <span id="L28" class="LineNr"> 28 </span> <span id="L29" class="LineNr"> 29 </span><span class="subxComment"># compare a null-terminated ascii string with a more idiomatic length-prefixed byte array</span> <span id="L30" class="LineNr"> 30 </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="L31" class="LineNr"> 31 </span>kernel-string-equal: <span class="subxComment"># s : null-terminated ascii string, benchmark : length-prefixed ascii string -> EAX : boolean</span> +<span id="L31" class="LineNr"> 31 </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="L32" class="LineNr"> 32 </span> <span class="subxS1Comment"># . prolog</span> <span id="L33" class="LineNr"> 33 </span> 55/push-EBP <span id="L34" class="LineNr"> 34 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -126,7 +128,7 @@ if ('onhashchange' in window) { <span id="L63" class="LineNr"> 63 </span> <span class="subxComment"># initialize loop counter i into ECX</span> <span id="L64" class="LineNr"> 64 </span> b9/copy-to-ECX 0/imm32/exit <span id="L65" class="LineNr"> 65 </span> <span class="subxComment"># while (i/ECX < n/EDX)</span> -<span id="L66" class="LineNr"> 66 </span>$kernel-string-equal:loop: +<span id="L66" class="LineNr"> 66 </span><span class="Constant">$kernel-string-equal:loop</span>: <span id="L67" class="LineNr"> 67 </span> 39/compare 3/mod/direct 1/rm32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 2/r32/EDX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># compare ECX with EDX</span> <span id="L68" class="LineNr"> 68 </span> 74/jump-if-equal $kernel-string-equal:break/disp8 <span id="L69" class="LineNr"> 69 </span> <span class="subxComment"># c1/EAX, c2/EBX = *s, *benchmark</span> @@ -146,20 +148,20 @@ if ('onhashchange' in window) { <span id="L83" class="LineNr"> 83 </span> 47/inc-EDI <span id="L84" class="LineNr"> 84 </span> <span class="subxComment"># end while</span> <span id="L85" class="LineNr"> 85 </span> eb/jump $kernel-string-equal:loop/disp8 -<span id="L86" class="LineNr"> 86 </span>$kernel-string-equal:break: +<span id="L86" class="LineNr"> 86 </span><span class="Constant">$kernel-string-equal:break</span>: <span id="L87" class="LineNr"> 87 </span> <span class="subxComment"># if (*s/EDI == 0) return true</span> <span id="L88" class="LineNr"> 88 </span> b8/copy-to-EAX 0/imm32 <span id="L89" class="LineNr"> 89 </span> 8a/copy 0/mod/indirect 7/rm32/EDI <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy byte at *EDI to lower byte of EAX</span> <span id="L90" class="LineNr"> 90 </span> 81 7/subop/compare 3/mod/direct 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/imm32 <span class="subxComment"># compare EAX</span> <span id="L91" class="LineNr"> 91 </span> 75/jump-if-not-equal $kernel-string-equal:false/disp8 <span id="L92" class="LineNr"> 92 </span> b8/copy-to-EAX 1/imm32 -<span id="L93" class="LineNr"> 93 </span>$kernel-string-equal:true: +<span id="L93" class="LineNr"> 93 </span><span class="Constant">$kernel-string-equal:true</span>: <span id="L94" class="LineNr"> 94 </span> eb/jump $kernel-string-equal:end/disp8 <span id="L95" class="LineNr"> 95 </span> <span class="subxComment"># return false</span> -<span id="L96" class="LineNr"> 96 </span>$kernel-string-equal:false: +<span id="L96" class="LineNr"> 96 </span><span class="Constant">$kernel-string-equal:false</span>: <span id="L97" class="LineNr"> 97 </span> b8/copy-to-EAX 0/imm32 <span id="L98" class="LineNr"> 98 </span> -<span id="L99" class="LineNr"> 99 </span>$kernel-string-equal:end: +<span id="L99" class="LineNr"> 99 </span><span class="Constant">$kernel-string-equal:end</span>: <span id="L100" class="LineNr">100 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L101" class="LineNr">101 </span> 5f/pop-to-EDI <span id="L102" class="LineNr">102 </span> 5e/pop-to-ESI @@ -173,7 +175,7 @@ if ('onhashchange' in window) { <span id="L110" class="LineNr">110 </span> <span id="L111" class="LineNr">111 </span><span class="subxH1Comment"># - tests</span> <span id="L112" class="LineNr">112 </span> -<span id="L113" class="LineNr">113 </span>test-compare-null-kernel-string-with-empty-array: +<span id="L113" class="LineNr">113 </span><span class="subxTest">test-compare-null-kernel-string-with-empty-array</span>: <span id="L114" class="LineNr">114 </span> <span class="subxComment"># EAX = kernel-string-equal(Null-kernel-string, "")</span> <span id="L115" class="LineNr">115 </span> <span class="subxS2Comment"># . . push args</span> <span id="L116" class="LineNr">116 </span> 68/push <span class="Constant">""</span>/imm32 @@ -193,7 +195,7 @@ if ('onhashchange' in window) { <span id="L130" class="LineNr">130 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L131" class="LineNr">131 </span> c3/return <span id="L132" class="LineNr">132 </span> -<span id="L133" class="LineNr">133 </span>test-compare-null-kernel-string-with-non-empty-array: +<span id="L133" class="LineNr">133 </span><span class="subxTest">test-compare-null-kernel-string-with-non-empty-array</span>: <span id="L134" class="LineNr">134 </span> <span class="subxComment"># EAX = kernel-string-equal(Null-kernel-string, "Abc")</span> <span id="L135" class="LineNr">135 </span> <span class="subxS2Comment"># . . push args</span> <span id="L136" class="LineNr">136 </span> 68/push <span class="Constant">"Abc"</span>/imm32 @@ -213,7 +215,7 @@ if ('onhashchange' in window) { <span id="L150" class="LineNr">150 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L151" class="LineNr">151 </span> c3/return <span id="L152" class="LineNr">152 </span> -<span id="L153" class="LineNr">153 </span>test-compare-kernel-string-with-equal-array: +<span id="L153" class="LineNr">153 </span><span class="subxTest">test-compare-kernel-string-with-equal-array</span>: <span id="L154" class="LineNr">154 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "Abc")</span> <span id="L155" class="LineNr">155 </span> <span class="subxS2Comment"># . . push args</span> <span id="L156" class="LineNr">156 </span> 68/push <span class="Constant">"Abc"</span>/imm32 @@ -233,7 +235,7 @@ if ('onhashchange' in window) { <span id="L170" class="LineNr">170 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L171" class="LineNr">171 </span> c3/return <span id="L172" class="LineNr">172 </span> -<span id="L173" class="LineNr">173 </span>test-compare-kernel-string-with-inequal-array: +<span id="L173" class="LineNr">173 </span><span class="subxTest">test-compare-kernel-string-with-inequal-array</span>: <span id="L174" class="LineNr">174 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "Adc")</span> <span id="L175" class="LineNr">175 </span> <span class="subxS2Comment"># . . push args</span> <span id="L176" class="LineNr">176 </span> 68/push <span class="Constant">"Adc"</span>/imm32 @@ -253,7 +255,7 @@ if ('onhashchange' in window) { <span id="L190" class="LineNr">190 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L191" class="LineNr">191 </span> c3/return <span id="L192" class="LineNr">192 </span> -<span id="L193" class="LineNr">193 </span>test-compare-kernel-string-with-empty-array: +<span id="L193" class="LineNr">193 </span><span class="subxTest">test-compare-kernel-string-with-empty-array</span>: <span id="L194" class="LineNr">194 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "")</span> <span id="L195" class="LineNr">195 </span> <span class="subxS2Comment"># . . push args</span> <span id="L196" class="LineNr">196 </span> 68/push <span class="Constant">""</span>/imm32 @@ -273,7 +275,7 @@ if ('onhashchange' in window) { <span id="L210" class="LineNr">210 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L211" class="LineNr">211 </span> c3/return <span id="L212" class="LineNr">212 </span> -<span id="L213" class="LineNr">213 </span>test-compare-kernel-string-with-shorter-array: +<span id="L213" class="LineNr">213 </span><span class="subxTest">test-compare-kernel-string-with-shorter-array</span>: <span id="L214" class="LineNr">214 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "Ab")</span> <span id="L215" class="LineNr">215 </span> <span class="subxS2Comment"># . . push args</span> <span id="L216" class="LineNr">216 </span> 68/push <span class="Constant">"Ab"</span>/imm32 @@ -293,7 +295,7 @@ if ('onhashchange' in window) { <span id="L230" class="LineNr">230 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> <span id="L231" class="LineNr">231 </span> c3/return <span id="L232" class="LineNr">232 </span> -<span id="L233" class="LineNr">233 </span>test-compare-kernel-string-with-longer-array: +<span id="L233" class="LineNr">233 </span><span class="subxTest">test-compare-kernel-string-with-longer-array</span>: <span id="L234" class="LineNr">234 </span> <span class="subxComment"># EAX = kernel-string-equal(Abc-kernel-string, "Abcd")</span> <span id="L235" class="LineNr">235 </span> <span class="subxS2Comment"># . . push args</span> <span id="L236" class="LineNr">236 </span> 68/push <span class="Constant">"Abcd"</span>/imm32 @@ -316,7 +318,7 @@ if ('onhashchange' in window) { <span id="L253" class="LineNr">253 </span><span class="subxH1Comment"># - helpers</span> <span id="L254" class="LineNr">254 </span> <span id="L255" class="LineNr">255 </span><span class="subxComment"># print msg to stderr if a != b, otherwise print "."</span> -<span id="L256" class="LineNr">256 </span>check-ints-equal: <span class="subxComment"># (a : int, b : int, msg : (address array byte)) -> boolean</span> +<span id="L256" class="LineNr">256 </span><span class="subxFunction">check-ints-equal</span>: <span class="subxComment"># (a : int, b : int, msg : (address array byte)) -> boolean</span> <span id="L257" class="LineNr">257 </span> <span class="subxS1Comment"># . prolog</span> <span id="L258" class="LineNr">258 </span> 55/push-EBP <span id="L259" class="LineNr">259 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> @@ -339,7 +341,7 @@ if ('onhashchange' in window) { <span id="L276" class="LineNr">276 </span> <span class="subxS1Comment"># . return</span> <span id="L277" class="LineNr">277 </span> eb/jump $check-ints-equal:end/disp8 <span id="L278" class="LineNr">278 </span> <span class="subxComment"># otherwise print(msg)</span> -<span id="L279" class="LineNr">279 </span>$check-ints-equal:else: +<span id="L279" class="LineNr">279 </span><span class="Constant">$check-ints-equal:else</span>: <span id="L280" class="LineNr">280 </span> <span class="subxComment"># copy msg into ECX</span> <span id="L281" class="LineNr">281 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none <span class="CommentedCode"> . </span> 1/r32/ECX 0x10/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(EBP+16) to ECX</span> <span id="L282" class="LineNr">282 </span> <span class="subxComment"># print(ECX)</span> @@ -356,7 +358,7 @@ if ('onhashchange' in window) { <span id="L293" class="LineNr">293 </span> e8/call write-stderr/disp32 <span id="L294" class="LineNr">294 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L295" class="LineNr">295 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/imm32 <span class="subxComment"># add to ESP</span> -<span id="L296" class="LineNr">296 </span>$check-ints-equal:end: +<span id="L296" class="LineNr">296 </span><span class="Constant">$check-ints-equal:end</span>: <span id="L297" class="LineNr">297 </span> <span class="subxS1Comment"># . restore registers</span> <span id="L298" class="LineNr">298 </span> 5b/pop-to-EBX <span id="L299" class="LineNr">299 </span> 59/pop-to-ECX @@ -365,7 +367,7 @@ if ('onhashchange' in window) { <span id="L302" class="LineNr">302 </span> 5d/pop-to-EBP <span id="L303" class="LineNr">303 </span> c3/return <span id="L304" class="LineNr">304 </span> -<span id="L305" class="LineNr">305 </span>write-stderr: <span class="subxComment"># s : (address array byte) -> <void></span> +<span id="L305" class="LineNr">305 </span><span class="subxFunction">write-stderr</span>: <span class="subxComment"># s : (address array byte) -> <void></span> <span id="L306" class="LineNr">306 </span> <span class="subxS1Comment"># . prolog</span> <span id="L307" class="LineNr">307 </span> 55/push-EBP <span id="L308" class="LineNr">308 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 4/r32/ESP <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy ESP to EBP</span> diff --git a/html/subx/examples/ex3.subx.html b/html/subx/examples/ex3.subx.html index 533bea07..d814af53 100644 --- a/html/subx/examples/ex3.subx.html +++ b/html/subx/examples/ex3.subx.html @@ -23,6 +23,7 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.Constant { color:#00a0a0; } --> </style> @@ -77,7 +78,7 @@ if ('onhashchange' in window) { <span id="L17" class="LineNr">17 </span> <span class="subxComment"># counter: ECX = 1</span> <span id="L18" class="LineNr">18 </span> b9/copy-to-ECX 1/imm32 <span id="L19" class="LineNr">19 </span> -<span id="L20" class="LineNr">20 </span>$loop: +<span id="L20" class="LineNr">20 </span><span class="Constant">$loop</span>: <span id="L21" class="LineNr">21 </span> <span class="subxComment"># while (counter <= 10)</span> <span id="L22" class="LineNr">22 </span> 81 7/subop/compare 3/mod/direct 1/rm32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0xa/imm32 <span class="subxComment"># compare ECX</span> <span id="L23" class="LineNr">23 </span> 7f/jump-if-greater $exit/disp8 @@ -88,7 +89,7 @@ if ('onhashchange' in window) { <span id="L28" class="LineNr">28 </span> <span class="subxComment"># loop</span> <span id="L29" class="LineNr">29 </span> eb/jump $loop/disp8 <span id="L30" class="LineNr">30 </span> -<span id="L31" class="LineNr">31 </span>$exit: +<span id="L31" class="LineNr">31 </span><span class="Constant">$exit</span>: <span id="L32" class="LineNr">32 </span> <span class="subxComment"># syscall(exit, EBX)</span> <span id="L33" class="LineNr">33 </span> b8/copy-to-EAX 1/imm32 <span id="L34" class="LineNr">34 </span> cd/syscall 0x80/imm8 diff --git a/html/subx/examples/ex8.subx.html b/html/subx/examples/ex8.subx.html index 50f28a7c..07534b4d 100644 --- a/html/subx/examples/ex8.subx.html +++ b/html/subx/examples/ex8.subx.html @@ -23,6 +23,8 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } +.Constant { color:#00a0a0; } --> </style> @@ -94,12 +96,12 @@ if ('onhashchange' in window) { <span id="L34" class="LineNr">34 </span> b8/copy-to-EAX 1/imm32/exit <span id="L35" class="LineNr">35 </span> cd/syscall 0x80/imm8 <span id="L36" class="LineNr">36 </span> -<span id="L37" class="LineNr">37 </span>ascii-length: <span class="subxComment"># s : (address array byte) -> n/EAX</span> +<span id="L37" class="LineNr">37 </span><span class="subxFunction">ascii-length</span>: <span class="subxComment"># s : (address array byte) -> n/EAX</span> <span id="L38" class="LineNr">38 </span> <span class="subxComment"># EDX = s</span> <span id="L39" class="LineNr">39 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none <span class="CommentedCode"> . </span> 2/r32/EDX 4/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(ESP+4) to EDX</span> <span id="L40" class="LineNr">40 </span> <span class="subxComment"># var result/EAX = 0</span> <span id="L41" class="LineNr">41 </span> b8/copy-to-EAX 0/imm32 -<span id="L42" class="LineNr">42 </span>$ascii-length-loop: +<span id="L42" class="LineNr">42 </span><span class="Constant">$ascii-length-loop</span>: <span id="L43" class="LineNr">43 </span> <span class="subxComment"># var c/ECX = *s</span> <span id="L44" class="LineNr">44 </span> 8a/copy 0/mod/* 2/rm32/EDX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 1/r32/ECX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy byte at *EDX to lower byte of ECX</span> <span id="L45" class="LineNr">45 </span> <span class="subxComment"># if c == '\0' break</span> @@ -111,7 +113,7 @@ if ('onhashchange' in window) { <span id="L51" class="LineNr">51 </span> 40/inc-EAX <span id="L52" class="LineNr">52 </span> <span class="subxComment"># loop</span> <span id="L53" class="LineNr">53 </span> eb/jump $ascii-length-loop/disp8 -<span id="L54" class="LineNr">54 </span>$ascii-length-ret: +<span id="L54" class="LineNr">54 </span><span class="Constant">$ascii-length-ret</span>: <span id="L55" class="LineNr">55 </span> <span class="subxComment"># return EAX</span> <span id="L56" class="LineNr">56 </span> c3/return <span id="L57" class="LineNr">57 </span> diff --git a/html/subx/examples/ex9.subx.html b/html/subx/examples/ex9.subx.html index 23e35839..0bb4659c 100644 --- a/html/subx/examples/ex9.subx.html +++ b/html/subx/examples/ex9.subx.html @@ -23,6 +23,7 @@ body { font-size:12pt; font-family: monospace; color: #aaaaaa; background-color: .LineNr { color:#444444; } .subxS1Comment { color:#2d8cff; } .CommentedCode { color: #6c6c6c; } +.subxFunction { color: #ff8700; } --> </style> @@ -98,7 +99,7 @@ if ('onhashchange' in window) { <span id="L38" class="LineNr">38 </span> b8/copy-to-EAX 1/imm32/exit <span id="L39" class="LineNr">39 </span> cd/syscall 0x80/imm8 <span id="L40" class="LineNr">40 </span> -<span id="L41" class="LineNr">41 </span>ascii-difference: <span class="subxComment"># (s1, s2) : null-terminated ascii strings</span> +<span id="L41" class="LineNr">41 </span><span class="subxFunction">ascii-difference</span>: <span class="subxComment"># (s1, s2) : null-terminated ascii strings</span> <span id="L42" class="LineNr">42 </span> <span class="subxComment"># a = first letter of s1 (ECX)</span> <span id="L43" class="LineNr">43 </span> 8b/copy 1/mod/*+disp8 4/rm32/sib 4/base/ESP 4/index/none 0/r32/EAX 4/disp8 <span class="CommentedCode"> . </span> <span class="subxComment"># copy *(ESP+4) to EAX</span> <span id="L44" class="LineNr">44 </span> 8b/copy 0/mod/indirect 0/rm32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> 0/r32/EAX <span class="CommentedCode"> . </span> <span class="CommentedCode"> . </span> <span class="subxComment"># copy *EAX to EAX</span> diff --git a/subx/subx.vim b/subx/subx.vim index 0a112fbb..c4071823 100644 --- a/subx/subx.vim +++ b/subx/subx.vim @@ -33,6 +33,8 @@ let b:cmt_head = "#? " syntax match subxDelimiter / \. / | highlight link subxDelimiter CommentedCode syntax match subxString %"[^"]*"% | highlight link subxString Constant + +"" definitions " match globals but not registers like 'EAX' " don't match capitalized words in metadata " don't match inside strings @@ -40,4 +42,13 @@ syntax match subxGlobal %\(/\)\@<!\<[A-Z][a-z0-9_-]*\>% | highlight link subxGlo " tweak the red color from the colorscheme just a tad to improve contrast highlight SpecialChar ctermfg=196 +" functions but not tests, globals or internal functions +syntax match subxFunction "^\(test_\)\@<![a-z][_a-zA-Z0-9-]*\(:\)\@=" | highlight subxFunction ctermfg=208 +" tests starting with 'test-' +syntax match subxTest "^test-[_a-zA-Z0-9-]*\(:\)\@=" | highlight subxTest ctermfg=34 +" internal functions starting with '_' +syntax match subxMinorFunction "^_[_a-zA-Z0-9-]*\(:\)\@=" | highlight subxMinorFunction ctermfg=95 +" other internal labels starting with '$' +syntax match subxLabel "^\$[_a-zA-Z0-9:-]*\(:\)\@=" | highlight link subxLabel Constant + let &cpo = s:save_cpo |