diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bf/bf.rs.html | 144 | ||||
-rw-r--r-- | src/gen/gen.rs.html | 91 | ||||
-rw-r--r-- | src/juicebox_asm/insn.rs.html | 24 | ||||
-rw-r--r-- | src/juicebox_asm/insn/add.rs.html | 16 | ||||
-rw-r--r-- | src/juicebox_asm/insn/sub.rs.html | 29 |
5 files changed, 268 insertions, 36 deletions
diff --git a/src/bf/bf.rs.html b/src/bf/bf.rs.html index 25b814e..9bd6202 100644 --- a/src/bf/bf.rs.html +++ b/src/bf/bf.rs.html @@ -290,7 +290,50 @@ <a href="#289" id="289">289</a> <a href="#290" id="290">290</a> <a href="#291" id="291">291</a> -<a href="#292" id="292">292</a></pre></div><pre class="rust"><code><span class="doccomment">//! Brainfuck VM. +<a href="#292" id="292">292</a> +<a href="#293" id="293">293</a> +<a href="#294" id="294">294</a> +<a href="#295" id="295">295</a> +<a href="#296" id="296">296</a> +<a href="#297" id="297">297</a> +<a href="#298" id="298">298</a> +<a href="#299" id="299">299</a> +<a href="#300" id="300">300</a> +<a href="#301" id="301">301</a> +<a href="#302" id="302">302</a> +<a href="#303" id="303">303</a> +<a href="#304" id="304">304</a> +<a href="#305" id="305">305</a> +<a href="#306" id="306">306</a> +<a href="#307" id="307">307</a> +<a href="#308" id="308">308</a> +<a href="#309" id="309">309</a> +<a href="#310" id="310">310</a> +<a href="#311" id="311">311</a> +<a href="#312" id="312">312</a> +<a href="#313" id="313">313</a> +<a href="#314" id="314">314</a> +<a href="#315" id="315">315</a> +<a href="#316" id="316">316</a> +<a href="#317" id="317">317</a> +<a href="#318" id="318">318</a> +<a href="#319" id="319">319</a> +<a href="#320" id="320">320</a> +<a href="#321" id="321">321</a> +<a href="#322" id="322">322</a> +<a href="#323" id="323">323</a> +<a href="#324" id="324">324</a> +<a href="#325" id="325">325</a> +<a href="#326" id="326">326</a> +<a href="#327" id="327">327</a> +<a href="#328" id="328">328</a> +<a href="#329" id="329">329</a> +<a href="#330" id="330">330</a> +<a href="#331" id="331">331</a> +<a href="#332" id="332">332</a> +<a href="#333" id="333">333</a> +<a href="#334" id="334">334</a> +<a href="#335" id="335">335</a></pre></div><pre class="rust"><code><span class="doccomment">//! Brainfuck VM. //! //! This example implements a simple //! [brainfuck](https://en.wikipedia.org/wiki/Brainfuck) interpreter @@ -313,7 +356,9 @@ <span class="kw">use </span>juicebox_asm::Runtime; <span class="kw">use </span>juicebox_asm::{Asm, Imm64, Imm8, Label, MemOp, MemOp8, Reg64, Reg8}; -<span class="kw">struct </span>BrainfuckInterp { +<span class="comment">// -- BRAINFUCK INTERPRETER ---------------------------------------------------- + +</span><span class="kw">struct </span>BrainfuckInterp { pc: usize, imem: Vec<char>, dptr: usize, @@ -323,8 +368,9 @@ <span class="kw">impl </span>BrainfuckInterp { <span class="kw">fn </span>new(prog: <span class="kw-2">&</span>str) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>, String> { - <span class="comment">// Do a first pass over the bf program to filter whitespace and detect invalid tokens. - // Additionally validate all conditional branches, and compute their branch target. + <span class="comment">// Do a first pass over the bf program to filter whitespace and detect + // invalid tokens. Additionally validate all conditional branches, and + // compute their branch target. </span><span class="kw">let </span>(imem, branches) = { <span class="comment">// Instruction memory holding the final bf program. </span><span class="kw">let </span><span class="kw-2">mut </span>imem = Vec::new(); @@ -422,7 +468,7 @@ } } -<span class="comment">// -- BRAINFUCK JIT -------------------------------------------------------------- +<span class="comment">// -- BRAINFUCK JIT ------------------------------------------------------------ </span><span class="attr">#[cfg(not(any(target_arch = <span class="string">"x86_64"</span>, target_os = <span class="string">"linux"</span>)))] </span><span class="macro">compile_error!</span>(<span class="string">"Only supported on x86_64 with SystemV abi"</span>); @@ -434,7 +480,8 @@ <span class="kw">impl </span>BrainfuckJit { <span class="kw">fn </span>new(prog: <span class="kw-2">&</span>str) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>, String> { - <span class="comment">// Do a first pass over the bf program to filter whitespace and detect invalid tokens. + <span class="comment">// Do a first pass over the bf program to filter whitespace and detect + // invalid tokens. </span><span class="kw">let </span>imem = prog .chars() .filter(|c| !c.is_whitespace()) @@ -460,25 +507,25 @@ <span class="kw">fn </span>run_jit(prog: <span class="kw-2">&</span>str) { <span class="kw">let </span><span class="kw-2">mut </span>vm = BrainfuckJit::new(prog).unwrap(); - <span class="comment">// Use callee saved registers to hold vm state, such that we don't - // need to save any state before calling out to putchar. + <span class="comment">// Use callee saved registers to hold vm state, such that we don't need to + // save any state before calling out to putchar. </span><span class="kw">let </span>dmem_base = Reg64::rbx; <span class="kw">let </span>dmem_idx = Reg64::r12; <span class="kw">let </span><span class="kw-2">mut </span>asm = Asm::new(); - <span class="comment">// Move data memory pointer (argument on jit entry) into correct - // register. + <span class="comment">// Move data memory pointer (argument on jit entry) into correct register. </span>asm.mov(dmem_base, Reg64::rdi); <span class="comment">// Clear data memory index. </span>asm.xor(dmem_idx, dmem_idx); - <span class="comment">// A stack of label pairs, used to link up forward and backward - // jumps for a given '[]' pair. + <span class="comment">// A stack of label pairs, used to link up forward and backward jumps for a + // given '[]' pair. </span><span class="kw">let </span><span class="kw-2">mut </span>label_stack = Vec::new(); <span class="comment">// Generate code for each instruction in the bf program. - </span><span class="kw">for </span>insn <span class="kw">in </span>vm.imem { - <span class="kw">match </span>insn { + </span><span class="kw">let </span><span class="kw-2">mut </span>pc = <span class="number">0</span>; + <span class="kw">while </span>pc < vm.imem.len() { + <span class="kw">match </span>vm.imem[pc] { <span class="string">'>' </span>=> { <span class="comment">// TODO: generate runtime bounds check. </span>asm.inc(dmem_idx); @@ -488,18 +535,53 @@ </span>asm.dec(dmem_idx); } <span class="string">'+' </span>=> { - asm.inc(MemOp8::from(MemOp::IndirectBaseIndex(dmem_base, dmem_idx))); + <span class="comment">// Apply optimization to fold consecutive '+' instructions to a + // single add instruction during compile time. + + </span><span class="kw">match </span>vm.imem[pc..].iter().take_while(|&&i| i.eq(<span class="kw-2">&</span><span class="string">'+'</span>)).count() { + <span class="number">1 </span>=> asm.inc(MemOp8::from(MemOp::IndirectBaseIndex(dmem_base, dmem_idx))), + cnt <span class="kw">if </span>cnt <= i8::MAX <span class="kw">as </span>usize => { + <span class="comment">// For add m64, imm8, the immediate is sign-extend and + // hence treated as signed. + </span>asm.add( + MemOp::IndirectBaseIndex(dmem_base, dmem_idx), + Imm8::from(cnt <span class="kw">as </span>u8), + ); + + <span class="comment">// Advance pc, but account for pc increment at the end + // of the loop. + </span>pc += cnt - <span class="number">1</span>; + } + cnt @ <span class="kw">_ </span>=> <span class="macro">unimplemented!</span>(<span class="string">"cnt={cnt} oob, add with larger imm"</span>), + } } <span class="string">'-' </span>=> { - asm.dec(MemOp8::from(MemOp::IndirectBaseIndex(dmem_base, dmem_idx))); + <span class="comment">// Apply optimization to fold consecutive '-' instructions to a + // single sub instruction during compile time. + + </span><span class="kw">match </span>vm.imem[pc..].iter().take_while(|&&i| i.eq(<span class="kw-2">&</span><span class="string">'-'</span>)).count() { + <span class="number">1 </span>=> asm.dec(MemOp8::from(MemOp::IndirectBaseIndex(dmem_base, dmem_idx))), + cnt <span class="kw">if </span>cnt <= i8::MAX <span class="kw">as </span>usize => { + <span class="comment">// For sub m64, imm8, the immediate is sign-extend and + // hence treated as signed. + </span>asm.sub( + MemOp::IndirectBaseIndex(dmem_base, dmem_idx), + Imm8::from(cnt <span class="kw">as </span>u8), + ); + + <span class="comment">// Advance pc, but account for pc increment at the end + // of the loop. + </span>pc += cnt - <span class="number">1</span>; + } + cnt @ <span class="kw">_ </span>=> <span class="macro">unimplemented!</span>(<span class="string">"cnt={cnt} oob, sub with larger imm"</span>), + } } <span class="string">'.' </span>=> { - <span class="comment">// Load data memory from active cell into di register, - // which is the first argument register according to - // the SystemV abi, then call into putchar. Since we - // stored all out vm state in callee saved registers - // we don't need to save any registers before the - // call. + <span class="comment">// Load data memory from active cell into di register, which is + // the first argument register according to the SystemV abi, + // then call into putchar. Since we stored all out vm state in + // callee saved registers we don't need to save any registers + // before the call. </span>asm.mov(Reg8::dil, MemOp::IndirectBaseIndex(dmem_base, dmem_idx)); asm.mov(Reg64::rax, Imm64::from(putchar <span class="kw">as </span>usize)); asm.call(Reg64::rax); @@ -521,8 +603,8 @@ ); asm.jz(<span class="kw-2">&mut </span>label_pair.<span class="number">0</span>); - <span class="comment">// Bind label_pair.1 after the jump instruction, which - // will be the branch target for the matching ']'. + <span class="comment">// Bind label_pair.1 after the jump instruction, which will be + // the branch target for the matching ']'. </span>asm.bind(<span class="kw-2">&mut </span>label_pair.<span class="number">1</span>); } <span class="string">']' </span>=> { @@ -530,8 +612,7 @@ .pop() .expect(<span class="string">"encountered un-balanced brackets, found ']' without matching '['"</span>); - <span class="comment">// Goto label_pair.1 if data memory at active cell is - // not 0. + <span class="comment">// Goto label_pair.1 if data memory at active cell is not 0. // if vm.dmem[vm.dptr] != 0 goto label_pair.1 </span>asm.cmp( MemOp::IndirectBaseIndex(dmem_base, dmem_idx), @@ -539,12 +620,15 @@ ); asm.jnz(<span class="kw-2">&mut </span>label_pair.<span class="number">1</span>); - <span class="comment">// Bind label_pair.0 after the jump instruction, which - // is the branch target for the matching '['. + <span class="comment">// Bind label_pair.0 after the jump instruction, which is the + // branch target for the matching '['. </span>asm.bind(<span class="kw-2">&mut </span>label_pair.<span class="number">0</span>); } <span class="kw">_ </span>=> <span class="macro">unreachable!</span>(), } + + <span class="comment">// Increment pc to next instruction. + </span>pc += <span class="number">1</span>; } <span class="comment">// Return from bf program. @@ -560,7 +644,9 @@ bf_entry(<span class="kw-2">&mut </span>vm.dmem <span class="kw">as </span><span class="kw-2">*mut </span>u8); } -<span class="kw">fn </span>main() { +<span class="comment">// -- MAIN --------------------------------------------------------------------- + +</span><span class="kw">fn </span>main() { <span class="comment">// https://en.wikipedia.org/wiki/Brainfuck#Adding_two_values //let inp = "++>+++++ [<+>-] ++++++++[<++++++>-]<."; //println!("add-print-7 (wikipedia.org) - interp"); diff --git a/src/gen/gen.rs.html b/src/gen/gen.rs.html new file mode 100644 index 0000000..1df336a --- /dev/null +++ b/src/gen/gen.rs.html @@ -0,0 +1,91 @@ +<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `examples/gen.rs`."><title>gen.rs - source</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-b0742ba02757f159.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="gen" data-themes="" data-resource-suffix="" data-rustdoc-version="1.83.0 (90b35a623 2024-11-26)" data-channel="1.83.0" data-search-js="search-f0d225181b97f9a4.js" data-settings-js="settings-805db61a62df4bd2.js" ><script src="../../static.files/storage-1d39b6787ed640ff.js"></script><script defer src="../../static.files/src-script-e66d777a5a92e9b2.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-f070b9041d14864c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-0111fcff984fae8f.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="src-sidebar-title"><h2>Files</h2></div></nav><div class="sidebar-resizer"></div><main><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1><div class="sub-heading">gen/</div>gen.rs</h1><rustdoc-toolbar></rustdoc-toolbar></div><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"> +<a href="#1" id="1">1</a> +<a href="#2" id="2">2</a> +<a href="#3" id="3">3</a> +<a href="#4" id="4">4</a> +<a href="#5" id="5">5</a> +<a href="#6" id="6">6</a> +<a href="#7" id="7">7</a> +<a href="#8" id="8">8</a> +<a href="#9" id="9">9</a> +<a href="#10" id="10">10</a> +<a href="#11" id="11">11</a> +<a href="#12" id="12">12</a> +<a href="#13" id="13">13</a> +<a href="#14" id="14">14</a> +<a href="#15" id="15">15</a> +<a href="#16" id="16">16</a> +<a href="#17" id="17">17</a> +<a href="#18" id="18">18</a> +<a href="#19" id="19">19</a> +<a href="#20" id="20">20</a> +<a href="#21" id="21">21</a> +<a href="#22" id="22">22</a> +<a href="#23" id="23">23</a> +<a href="#24" id="24">24</a> +<a href="#25" id="25">25</a> +<a href="#26" id="26">26</a> +<a href="#27" id="27">27</a> +<a href="#28" id="28">28</a> +<a href="#29" id="29">29</a> +<a href="#30" id="30">30</a> +<a href="#31" id="31">31</a> +<a href="#32" id="32">32</a> +<a href="#33" id="33">33</a> +<a href="#34" id="34">34</a> +<a href="#35" id="35">35</a> +<a href="#36" id="36">36</a> +<a href="#37" id="37">37</a> +<a href="#38" id="38">38</a> +<a href="#39" id="39">39</a> +<a href="#40" id="40">40</a> +<a href="#41" id="41">41</a> +<a href="#42" id="42">42</a> +<a href="#43" id="43">43</a> +<a href="#44" id="44">44</a> +<a href="#45" id="45">45</a></pre></div><pre class="rust"><code><span class="doccomment">//! Add example. +//! +//! Jit compile a function at runtime (generate native host code) which calls a function defined in +//! the example based on the SystemV abi to demonstrate the [`juicebox_asm`] crate. + +</span><span class="attr">#[cfg(not(any(target_arch = <span class="string">"x86_64"</span>, target_os = <span class="string">"linux"</span>)))] +</span><span class="macro">compile_error!</span>(<span class="string">"Only supported on x86_64 with SystemV abi"</span>); + +<span class="kw">use </span>juicebox_asm::insn::<span class="kw-2">*</span>; +<span class="kw">use </span>juicebox_asm::{Asm, Imm16, Imm64, Imm8, Label, Reg16, Reg64::<span class="kw-2">*</span>, Runtime}; +<span class="kw">use </span>juicebox_asm::{MemOp, MemOp16, MemOp32, MemOp64, MemOp8}; + +<span class="kw">extern </span><span class="string">"C" </span><span class="kw">fn </span>add(a: u32, b: u32) -> u32 { + a + b +} + +<span class="kw">fn </span>main() { + <span class="kw">let </span><span class="kw-2">mut </span>asm1 = Asm::new(); + asm1.xor(r11, r11); + + <span class="macro">assert!</span>(<span class="number">0x7fu8 </span><= i8::MAX <span class="kw">as </span>u8); + + asm1.add(MemOp::IndirectBaseIndex(rdi, r11), Imm8::from(<span class="number">0x10u8</span>)); + asm1.ret(); + + <span class="kw">let </span>code = asm1.into_code(); + std::fs::write(<span class="string">"jit.asm"</span>, <span class="kw-2">&</span>code).unwrap(); + + <span class="kw">let </span><span class="kw-2">mut </span>asm2 = Asm::new(); + asm2.mov(Reg16::cx, Imm16::from(<span class="number">1u16</span>)); + asm2.mov(MemOp::Indirect(rdi), Reg16::cx); + asm2.ret(); + + <span class="kw">let </span><span class="kw-2">mut </span>rt = Runtime::new(); + <span class="kw">let </span>fn1 = <span class="kw">unsafe </span>{ rt.add_code::<<span class="kw">extern </span><span class="string">"C" </span><span class="kw">fn</span>(<span class="kw-2">*mut </span>u64)>(code) }; + <span class="kw">let </span>fn2 = <span class="kw">unsafe </span>{ rt.add_code::<<span class="kw">extern </span><span class="string">"C" </span><span class="kw">fn</span>(<span class="kw-2">*mut </span>u64)>(asm2.into_code()) }; + + <span class="kw">let </span><span class="kw-2">mut </span>data = <span class="number">0xffff_ffff_ffff_ff00u64</span>; + fn1(<span class="kw-2">&mut </span>data <span class="kw">as </span><span class="kw-2">*mut </span>u64); + <span class="macro">println!</span>(<span class="string">"data={:x}"</span>, data); + + <span class="kw">let </span><span class="kw-2">mut </span>data = <span class="number">0xffff_ffff_ffff_ffffu64</span>; + fn2(<span class="kw-2">&mut </span>data <span class="kw">as </span><span class="kw-2">*mut </span>u64); + <span class="macro">println!</span>(<span class="string">"data={:x}"</span>, data); +} +</code></pre></div></section></main></body></html>
\ No newline at end of file diff --git a/src/juicebox_asm/insn.rs.html b/src/juicebox_asm/insn.rs.html index 99a3dd6..432d3da 100644 --- a/src/juicebox_asm/insn.rs.html +++ b/src/juicebox_asm/insn.rs.html @@ -117,7 +117,14 @@ <a href="#116" id="116">116</a> <a href="#117" id="117">117</a> <a href="#118" id="118">118</a> -<a href="#119" id="119">119</a></pre></div><pre class="rust"><code><span class="doccomment">//! Trait definitions of various instructions. +<a href="#119" id="119">119</a> +<a href="#120" id="120">120</a> +<a href="#121" id="121">121</a> +<a href="#122" id="122">122</a> +<a href="#123" id="123">123</a> +<a href="#124" id="124">124</a> +<a href="#125" id="125">125</a> +<a href="#126" id="126">126</a></pre></div><pre class="rust"><code><span class="doccomment">//! Trait definitions of various instructions. </span><span class="kw">mod </span>add; <span class="kw">mod </span>call; @@ -134,6 +141,7 @@ <span class="kw">mod </span>pop; <span class="kw">mod </span>push; <span class="kw">mod </span>ret; +<span class="kw">mod </span>sub; <span class="kw">mod </span>test; <span class="kw">mod </span>xor; @@ -210,16 +218,22 @@ </span><span class="kw">fn </span>mov(<span class="kw-2">&mut </span><span class="self">self</span>, op1: T, op2: U); } +<span class="doccomment">/// Trait for [`pop`](https://www.felixcloutier.com/x86/pop) instruction kinds. +</span><span class="kw">pub trait </span>Pop<T> { + <span class="doccomment">/// Emit a pop instruction. + </span><span class="kw">fn </span>pop(<span class="kw-2">&mut </span><span class="self">self</span>, op1: T); +} + <span class="doccomment">/// Trait for [`push`](https://www.felixcloutier.com/x86/push) instruction kinds. </span><span class="kw">pub trait </span>Push<T> { <span class="doccomment">/// Emit a push instruction. </span><span class="kw">fn </span>push(<span class="kw-2">&mut </span><span class="self">self</span>, op1: T); } -<span class="doccomment">/// Trait for [`pop`](https://www.felixcloutier.com/x86/pop) instruction kinds. -</span><span class="kw">pub trait </span>Pop<T> { - <span class="doccomment">/// Emit a pop instruction. - </span><span class="kw">fn </span>pop(<span class="kw-2">&mut </span><span class="self">self</span>, op1: T); +<span class="doccomment">/// Trait for [`sub`](https://www.felixcloutier.com/x86/sub) instruction kinds. +</span><span class="kw">pub trait </span>Sub<T, U> { + <span class="doccomment">/// Emit an sub instruction. + </span><span class="kw">fn </span>sub(<span class="kw-2">&mut </span><span class="self">self</span>, op1: T, op2: U); } <span class="doccomment">/// Trait for [`test`](https://www.felixcloutier.com/x86/test) instruction kinds. diff --git a/src/juicebox_asm/insn/add.rs.html b/src/juicebox_asm/insn/add.rs.html index e62bc4a..f91aa25 100644 --- a/src/juicebox_asm/insn/add.rs.html +++ b/src/juicebox_asm/insn/add.rs.html @@ -36,8 +36,14 @@ <a href="#35" id="35">35</a> <a href="#36" id="36">36</a> <a href="#37" id="37">37</a> -<a href="#38" id="38">38</a></pre></div><pre class="rust"><code><span class="kw">use </span><span class="kw">super</span>::Add; -<span class="kw">use crate</span>::{Asm, Imm16, MemOp, Reg16, Reg32, Reg64}; +<a href="#38" id="38">38</a> +<a href="#39" id="39">39</a> +<a href="#40" id="40">40</a> +<a href="#41" id="41">41</a> +<a href="#42" id="42">42</a> +<a href="#43" id="43">43</a> +<a href="#44" id="44">44</a></pre></div><pre class="rust"><code><span class="kw">use </span><span class="kw">super</span>::Add; +<span class="kw">use crate</span>::{Asm, Imm16, Imm8, MemOp, Reg16, Reg32, Reg64}; <span class="kw">impl </span>Add<Reg64, Reg64> <span class="kw">for </span>Asm { <span class="kw">fn </span>add(<span class="kw-2">&mut </span><span class="self">self</span>, op1: Reg64, op2: Reg64) { @@ -63,6 +69,12 @@ } } +<span class="kw">impl </span>Add<MemOp, Imm8> <span class="kw">for </span>Asm { + <span class="kw">fn </span>add(<span class="kw-2">&mut </span><span class="self">self</span>, op1: MemOp, op2: Imm8) { + <span class="self">self</span>.encode_mi(<span class="number">0x83</span>, <span class="number">0</span>, op1, op2); + } +} + <span class="kw">impl </span>Add<MemOp, Imm16> <span class="kw">for </span>Asm { <span class="kw">fn </span>add(<span class="kw-2">&mut </span><span class="self">self</span>, op1: MemOp, op2: Imm16) { <span class="self">self</span>.encode_mi(<span class="number">0x81</span>, <span class="number">0</span>, op1, op2); diff --git a/src/juicebox_asm/insn/sub.rs.html b/src/juicebox_asm/insn/sub.rs.html new file mode 100644 index 0000000..f350d05 --- /dev/null +++ b/src/juicebox_asm/insn/sub.rs.html @@ -0,0 +1,29 @@ +<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `src/insn/sub.rs`."><title>sub.rs - source</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-b0742ba02757f159.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="juicebox_asm" data-themes="" data-resource-suffix="" data-rustdoc-version="1.83.0 (90b35a623 2024-11-26)" data-channel="1.83.0" data-search-js="search-f0d225181b97f9a4.js" data-settings-js="settings-805db61a62df4bd2.js" ><script src="../../../static.files/storage-1d39b6787ed640ff.js"></script><script defer src="../../../static.files/src-script-e66d777a5a92e9b2.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-f070b9041d14864c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-0111fcff984fae8f.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="src-sidebar-title"><h2>Files</h2></div></nav><div class="sidebar-resizer"></div><main><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1><div class="sub-heading">juicebox_asm/insn/</div>sub.rs</h1><rustdoc-toolbar></rustdoc-toolbar></div><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers"> +<a href="#1" id="1">1</a> +<a href="#2" id="2">2</a> +<a href="#3" id="3">3</a> +<a href="#4" id="4">4</a> +<a href="#5" id="5">5</a> +<a href="#6" id="6">6</a> +<a href="#7" id="7">7</a> +<a href="#8" id="8">8</a> +<a href="#9" id="9">9</a> +<a href="#10" id="10">10</a> +<a href="#11" id="11">11</a> +<a href="#12" id="12">12</a> +<a href="#13" id="13">13</a> +<a href="#14" id="14">14</a></pre></div><pre class="rust"><code><span class="kw">use </span><span class="kw">super</span>::Sub; +<span class="kw">use crate</span>::{Asm, Imm8, MemOp, Reg64}; + +<span class="kw">impl </span>Sub<Reg64, Reg64> <span class="kw">for </span>Asm { + <span class="kw">fn </span>sub(<span class="kw-2">&mut </span><span class="self">self</span>, op1: Reg64, op2: Reg64) { + <span class="self">self</span>.encode_rr(<span class="kw-2">&</span>[<span class="number">0x29</span>], op1, op2); + } +} + +<span class="kw">impl </span>Sub<MemOp, Imm8> <span class="kw">for </span>Asm { + <span class="kw">fn </span>sub(<span class="kw-2">&mut </span><span class="self">self</span>, op1: MemOp, op2: Imm8) { + <span class="self">self</span>.encode_mi(<span class="number">0x83</span>, <span class="number">5</span>, op1, op2); + } +} +</code></pre></div></section></main></body></html>
\ No newline at end of file |