diff options
author | Kartik Agaram <vc@akkartik.com> | 2021-06-24 21:50:38 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2021-06-24 21:50:38 -0700 |
commit | 718fd031f9e7a60f092c830ed547f5e461fb66ec (patch) | |
tree | dd3740d2a7f7199a1e6a6f05284420f7cb946ac1 | |
parent | ec32c11d3bde6772ddd250d3b217e0541409e0ce (diff) | |
download | mu-718fd031f9e7a60f092c830ed547f5e461fb66ec.tar.gz |
.
-rw-r--r-- | html/mu_instructions.html | 82 |
1 files changed, 44 insertions, 38 deletions
diff --git a/html/mu_instructions.html b/html/mu_instructions.html index e5e43cd9..6f7f85f8 100644 --- a/html/mu_instructions.html +++ b/html/mu_instructions.html @@ -2,22 +2,28 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>~/play/mu/mu_instructions.html</title> +<title>Mu's instructions and their table-driven translation</title> <meta name="Generator" content="Vim/8.1"> <meta name="plugin-version" content="vim8.1_v1"> <meta name="syntax" content="none"> <meta name="settings" content="use_css,no_foldcolumn,expand_tabs,prevent_copy="> -<meta name="colorscheme" content="minimal-dark"> +<meta name="colorscheme" content="minimal-light"> <style type="text/css"> <!-- -pre { font-family: monospace; color: #000000; background-color: #a8a8a8; } -body { font-family: monospace; color: #000000; background-color: #a8a8a8; } +pre { font-family: monospace; color: #000000; background-color: #eeeeee; } +body { font-family: monospace; color: #000000; background-color: #eeeeee; } * { font-size: 1em; } +.muRegEdx { color: #878700; } .PreProc { color: #c000c0; } +.muRegEsi { color: #87d787; } .muComment { color: #005faf; } +.muRegEdi { color: #87ffd7; } +.muRegEbx { color: #8787af; } .Delimiter { color: #c000c0; } .Constant { color: #008787; } .Special { color: #ff6060; } +.muRegEax { color: #875f00; } +.muRegEcx { color: #af875f; } --> </style> </head> @@ -42,21 +48,21 @@ the SubX instruction they're translated to. These instructions use the general-purpose registers. -var/<span class="Constant">eax</span> <span class="Special"><-</span> increment => <span class="Constant">"40/increment-eax"</span> -var/<span class="Constant">ecx</span> <span class="Special"><-</span> increment => <span class="Constant">"41/increment-ecx"</span> -var/<span class="Constant">edx</span> <span class="Special"><-</span> increment => <span class="Constant">"42/increment-edx"</span> -var/<span class="Constant">ebx</span> <span class="Special"><-</span> increment => <span class="Constant">"43/increment-ebx"</span> -var/<span class="Constant">esi</span> <span class="Special"><-</span> increment => <span class="Constant">"46/increment-esi"</span> -var/<span class="Constant">edi</span> <span class="Special"><-</span> increment => <span class="Constant">"47/increment-edi"</span> +var/<span class="muRegEax">eax</span> <span class="Special"><-</span> increment => <span class="Constant">"40/increment-eax"</span> +var/<span class="muRegEcx">ecx</span> <span class="Special"><-</span> increment => <span class="Constant">"41/increment-ecx"</span> +var/<span class="muRegEdx">edx</span> <span class="Special"><-</span> increment => <span class="Constant">"42/increment-edx"</span> +var/<span class="muRegEbx">ebx</span> <span class="Special"><-</span> increment => <span class="Constant">"43/increment-ebx"</span> +var/<span class="muRegEsi">esi</span> <span class="Special"><-</span> increment => <span class="Constant">"46/increment-esi"</span> +var/<span class="muRegEdi">edi</span> <span class="Special"><-</span> increment => <span class="Constant">"47/increment-edi"</span> increment var => <span class="Constant">"ff 0/subop/increment *(ebp+"</span> var.stack-offset <span class="Constant">")"</span> increment *var/reg => <span class="Constant">"ff 0/subop/increment *"</span> reg -var/<span class="Constant">eax</span> <span class="Special"><-</span> decrement => <span class="Constant">"48/decrement-eax"</span> -var/<span class="Constant">ecx</span> <span class="Special"><-</span> decrement => <span class="Constant">"49/decrement-ecx"</span> -var/<span class="Constant">edx</span> <span class="Special"><-</span> decrement => <span class="Constant">"4a/decrement-edx"</span> -var/<span class="Constant">ebx</span> <span class="Special"><-</span> decrement => <span class="Constant">"4b/decrement-ebx"</span> -var/<span class="Constant">esi</span> <span class="Special"><-</span> decrement => <span class="Constant">"4e/decrement-esi"</span> -var/<span class="Constant">edi</span> <span class="Special"><-</span> decrement => <span class="Constant">"4f/decrement-edi"</span> +var/<span class="muRegEax">eax</span> <span class="Special"><-</span> decrement => <span class="Constant">"48/decrement-eax"</span> +var/<span class="muRegEcx">ecx</span> <span class="Special"><-</span> decrement => <span class="Constant">"49/decrement-ecx"</span> +var/<span class="muRegEdx">edx</span> <span class="Special"><-</span> decrement => <span class="Constant">"4a/decrement-edx"</span> +var/<span class="muRegEbx">ebx</span> <span class="Special"><-</span> decrement => <span class="Constant">"4b/decrement-ebx"</span> +var/<span class="muRegEsi">esi</span> <span class="Special"><-</span> decrement => <span class="Constant">"4e/decrement-esi"</span> +var/<span class="muRegEdi">edi</span> <span class="Special"><-</span> decrement => <span class="Constant">"4f/decrement-edi"</span> decrement var => <span class="Constant">"ff 1/subop/decrement *(ebp+"</span> var.stack-offset <span class="Constant">")"</span> decrement *var/reg => <span class="Constant">"ff 1/subop/decrement *"</span> reg @@ -65,7 +71,7 @@ var/reg <span class="Special"><-</span> add var2 => <span cl var/reg <span class="Special"><-</span> add *var2/reg2 => <span class="Constant">"03/add *"</span> reg2 <span class="Constant">" "</span> reg <span class="Constant">"/r32"</span> add-to var1, var2/reg => <span class="Constant">"01/add-to *(ebp+"</span> var1.stack-offset <span class="Constant">") "</span> reg <span class="Constant">"/r32"</span> add-to *var1/reg1, var2/reg2 => <span class="Constant">"01/add-to *"</span> reg1 <span class="Constant">" "</span> reg2 <span class="Constant">"/r32"</span> -var/<span class="Constant">eax</span> <span class="Special"><-</span> add n => <span class="Constant">"05/add-to-eax "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEax">eax</span> <span class="Special"><-</span> add n => <span class="Constant">"05/add-to-eax "</span> n <span class="Constant">"/imm32"</span> var/reg <span class="Special"><-</span> add n => <span class="Constant">"81 0/subop/add %"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> add-to var, n => <span class="Constant">"81 0/subop/add *(ebp+"</span> var.stack-offset <span class="Constant">") "</span> n <span class="Constant">"/imm32"</span> add-to *var/reg, n => <span class="Constant">"81 0/subop/add *"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> @@ -75,7 +81,7 @@ var/reg <span class="Special"><-</span> subtract var2 => <span cl var/reg <span class="Special"><-</span> subtract *var2/reg2 => <span class="Constant">"2b/subtract *"</span> reg2 <span class="Constant">" "</span> reg1 <span class="Constant">"/r32"</span> subtract-from var1, var2/reg2 => <span class="Constant">"29/subtract-from *(ebp+"</span> var1.stack-offset <span class="Constant">") "</span> reg2 <span class="Constant">"/r32"</span> subtract-from *var1/reg1, var2/reg2 => <span class="Constant">"29/subtract-from *"</span> reg1 <span class="Constant">" "</span> reg2 <span class="Constant">"/r32"</span> -var/<span class="Constant">eax</span> <span class="Special"><-</span> subtract n => <span class="Constant">"2d/subtract-from-eax "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEax">eax</span> <span class="Special"><-</span> subtract n => <span class="Constant">"2d/subtract-from-eax "</span> n <span class="Constant">"/imm32"</span> var/reg <span class="Special"><-</span> subtract n => <span class="Constant">"81 5/subop/subtract %"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> subtract-from var, n => <span class="Constant">"81 5/subop/subtract *(ebp+"</span> var.stack-offset <span class="Constant">") "</span> n <span class="Constant">"/imm32"</span> subtract-from *var/reg, n => <span class="Constant">"81 5/subop/subtract *"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> @@ -85,7 +91,7 @@ var/reg <span class="Special"><-</span> and var2 => <span cl var/reg <span class="Special"><-</span> and *var2/reg2 => <span class="Constant">"23/and *"</span> reg2 <span class="Constant">" "</span> reg <span class="Constant">"/r32"</span> and-with var1, var2/reg => <span class="Constant">"21/and-with *(ebp+"</span> var1.stack-offset <span class="Constant">") "</span> reg <span class="Constant">"/r32"</span> and-with *var1/reg1, var2/reg2 => <span class="Constant">"21/and-with *"</span> reg1 <span class="Constant">" "</span> reg2 <span class="Constant">"/r32"</span> -var/<span class="Constant">eax</span> <span class="Special"><-</span> and n => <span class="Constant">"25/and-with-eax "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEax">eax</span> <span class="Special"><-</span> and n => <span class="Constant">"25/and-with-eax "</span> n <span class="Constant">"/imm32"</span> var/reg <span class="Special"><-</span> and n => <span class="Constant">"81 4/subop/and %"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> and-with var, n => <span class="Constant">"81 4/subop/and *(ebp+"</span> var.stack-offset <span class="Constant">") "</span> n <span class="Constant">"/imm32"</span> and-with *var/reg, n => <span class="Constant">"81 4/subop/and *"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> @@ -95,7 +101,7 @@ var/reg <span class="Special"><-</span> or var2 => <span cl var/reg <span class="Special"><-</span> or *var2/reg2 => <span class="Constant">"0b/or *"</span> reg2 <span class="Constant">" "</span> reg <span class="Constant">"/r32"</span> or-with var1, var2/reg2 => <span class="Constant">"09/or-with *(ebp+"</span> var1.stack-offset <span class="Constant">" "</span> reg2 <span class="Constant">"/r32"</span> or-with *var1/reg1, var2/reg2 => <span class="Constant">"09/or-with *"</span> reg1 <span class="Constant">" "</span> reg2 <span class="Constant">"/r32"</span> -var/<span class="Constant">eax</span> <span class="Special"><-</span> or n => <span class="Constant">"0d/or-with-eax "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEax">eax</span> <span class="Special"><-</span> or n => <span class="Constant">"0d/or-with-eax "</span> n <span class="Constant">"/imm32"</span> var/reg <span class="Special"><-</span> or n => <span class="Constant">"81 1/subop/or %"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> or-with var, n => <span class="Constant">"81 1/subop/or *(ebp+"</span> var.stack-offset <span class="Constant">") "</span> n <span class="Constant">"/imm32"</span> or-with *var/reg, n => <span class="Constant">"81 1/subop/or *"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> @@ -109,7 +115,7 @@ var/reg <span class="Special"><-</span> xor var2 => <span cl var/reg <span class="Special"><-</span> xor *var2/reg2 => <span class="Constant">"33/xor *"</span> reg2 <span class="Constant">" "</span> reg <span class="Constant">"/r32"</span> xor-with var1, var2/reg => <span class="Constant">"31/xor-with *(ebp+"</span> var1.stack-offset <span class="Constant">") "</span> reg <span class="Constant">"/r32"</span> xor-with *var1/reg1, var2/reg2 => <span class="Constant">"31/xor-with *"</span> reg1 <span class="Constant">" "</span> reg2 <span class="Constant">"/r32"</span> -var/<span class="Constant">eax</span> <span class="Special"><-</span> xor n => <span class="Constant">"35/xor-with-eax "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEax">eax</span> <span class="Special"><-</span> xor n => <span class="Constant">"35/xor-with-eax "</span> n <span class="Constant">"/imm32"</span> var/reg <span class="Special"><-</span> xor n => <span class="Constant">"81 6/subop/xor %"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> xor-with var, n => <span class="Constant">"81 6/subop/xor *(ebp+"</span> var.stack-offset <span class="Constant">") "</span> n <span class="Constant">"/imm32"</span> xor-with *var/reg, n => <span class="Constant">"81 6/subop/xor *"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> @@ -128,12 +134,12 @@ shift-right *var/reg, n => <span class="Constant">"c1/shift 5/ shift-right-signed var, n => <span class="Constant">"c1/shift 7/subop/right-signed *(ebp+"</span> var.stack-offset <span class="Constant">") "</span> n <span class="Constant">"/imm32"</span> shift-right-signed *var/reg, n => <span class="Constant">"c1/shift 7/subop/right-signed *"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> -var/<span class="Constant">eax</span> <span class="Special"><-</span> copy n => <span class="Constant">"b8/copy-to-eax "</span> n <span class="Constant">"/imm32"</span> -var/<span class="Constant">ecx</span> <span class="Special"><-</span> copy n => <span class="Constant">"b9/copy-to-ecx "</span> n <span class="Constant">"/imm32"</span> -var/<span class="Constant">edx</span> <span class="Special"><-</span> copy n => <span class="Constant">"ba/copy-to-edx "</span> n <span class="Constant">"/imm32"</span> -var/<span class="Constant">ebx</span> <span class="Special"><-</span> copy n => <span class="Constant">"bb/copy-to-ebx "</span> n <span class="Constant">"/imm32"</span> -var/<span class="Constant">esi</span> <span class="Special"><-</span> copy n => <span class="Constant">"be/copy-to-esi "</span> n <span class="Constant">"/imm32"</span> -var/<span class="Constant">edi</span> <span class="Special"><-</span> copy n => <span class="Constant">"bf/copy-to-edi "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEax">eax</span> <span class="Special"><-</span> copy n => <span class="Constant">"b8/copy-to-eax "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEcx">ecx</span> <span class="Special"><-</span> copy n => <span class="Constant">"b9/copy-to-ecx "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEdx">edx</span> <span class="Special"><-</span> copy n => <span class="Constant">"ba/copy-to-edx "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEbx">ebx</span> <span class="Special"><-</span> copy n => <span class="Constant">"bb/copy-to-ebx "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEsi">esi</span> <span class="Special"><-</span> copy n => <span class="Constant">"be/copy-to-esi "</span> n <span class="Constant">"/imm32"</span> +var/<span class="muRegEdi">edi</span> <span class="Special"><-</span> copy n => <span class="Constant">"bf/copy-to-edi "</span> n <span class="Constant">"/imm32"</span> var/reg <span class="Special"><-</span> copy var2/reg2 => <span class="Constant">"89/<- %"</span> reg <span class="Constant">" "</span> reg2 <span class="Constant">"/r32"</span> copy-to var1, var2/reg => <span class="Constant">"89/<- *(ebp+"</span> var1.stack-offset <span class="Constant">") "</span> reg <span class="Constant">"/r32"</span> copy-to *var1/reg1, var2/reg2 => <span class="Constant">"89/<- *"</span> reg1 <span class="Constant">" "</span> reg2 <span class="Constant">"/r32"</span> @@ -153,7 +159,7 @@ compare var1, var2/reg2 => <span class="Constant">"39/compare compare *var1/reg1, var2/reg2 => <span class="Constant">"39/compare *"</span> reg1 <span class="Constant">" "</span> reg2 <span class="Constant">"/r32"</span> compare var1/reg1, var2 => <span class="Constant">"3b/compare<- *(ebp+"</span> var2.stack-offset <span class="Constant">") "</span> reg1 <span class="Constant">"/r32"</span> compare var/reg, *var2/reg2 => <span class="Constant">"3b/compare<- *"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> -compare var/<span class="Constant">eax</span>, n => <span class="Constant">"3d/compare-eax-with "</span> n <span class="Constant">"/imm32"</span> +compare var/<span class="muRegEax">eax</span>, n => <span class="Constant">"3d/compare-eax-with "</span> n <span class="Constant">"/imm32"</span> compare var/reg, n => <span class="Constant">"81 7/subop/compare %"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> compare var, n => <span class="Constant">"81 7/subop/compare *(ebp+"</span> var.stack-offset <span class="Constant">") "</span> n <span class="Constant">"/imm32"</span> compare *var/reg, n => <span class="Constant">"81 7/subop/compare *"</span> reg <span class="Constant">" "</span> n <span class="Constant">"/imm32"</span> @@ -408,30 +414,30 @@ var/reg: int <span class="Special"><-</span> length arr/reg2: (addr array T) <span class="Constant">"c1/shift 5/subop/logic-right %"</span> reg <span class="Constant">" "</span> log2(size-of(T)) <span class="Constant">"/imm8"</span> | otherwise x86 has no instruction to divide by a literal, so - we need up to <span class="Constant">3</span> extra registers! <span class="Constant">eax</span>/<span class="Constant">edx</span> for division and say <span class="Constant">ecx</span> - => if reg is not <span class="Constant">eax</span> + we need up to <span class="Constant">3</span> extra registers! <span class="muRegEax">eax</span>/<span class="muRegEdx">edx</span> for division and say <span class="muRegEcx">ecx</span> + => if reg is not <span class="muRegEax">eax</span> <span class="Constant">"50/push-eax"</span> - if reg is not <span class="Constant">ecx</span> + if reg is not <span class="muRegEcx">ecx</span> <span class="Constant">"51/push-ecx"</span> - if reg is not <span class="Constant">edx</span> + if reg is not <span class="muRegEdx">edx</span> <span class="Constant">"52/push-edx"</span> <span class="Constant">"8b/-> *"</span> reg2 <span class="Constant">" eax/r32"</span> <span class="Constant">"31/xor %edx 2/r32/edx"</span> <span class="muComment"># sign-extend, but array size can't be negative</span> <span class="Constant">"b9/copy-to-ecx "</span> size-of(T) <span class="Constant">"/imm32"</span> <span class="Constant">"f7 7/subop/idiv-eax-edx-by %ecx"</span> - if reg is not <span class="Constant">eax</span> + if reg is not <span class="muRegEax">eax</span> <span class="Constant">"89/<- %"</span> reg <span class="Constant">" 0/r32/eax"</span> - if reg is not <span class="Constant">edx</span> + if reg is not <span class="muRegEdx">edx</span> <span class="Constant">"5a/pop-to-edx"</span> - if reg is not <span class="Constant">ecx</span> + if reg is not <span class="muRegEcx">ecx</span> <span class="Constant">"59/pop-to-ecx"</span> - if reg is not <span class="Constant">eax</span> + if reg is not <span class="muRegEax">eax</span> <span class="Constant">"58/pop-to-eax"</span> <span class="muComment"># User-defined types</span> -If a record (product) <span class="PreProc">type</span> T was defined to have elements a, b, c, ... of -types T_a, T_b, T_c, ..., then accessing one of those elements f of <span class="PreProc">type</span> T_f: +If a record (product) type T was defined to have elements a, b, c, ... of +types T_a, T_b, T_c, ..., then accessing one of those elements f of type T_f: var/reg: (addr T_f) <span class="Special"><-</span> get var2/reg2: (addr T), f => <span class="Constant">"81 7/subop/compare %"</span> reg2 <span class="Constant">" 0/imm32"</span> |