From e169a010c4942c610314a335e7c79f0cb421eef1 Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 5 Mar 2023 21:22:11 +0000 Subject: deploy: 8316b628bbc9945fd1d08305317cf49a6482801f --- src/juicebox_asm/insn.rs.html | 14 ++++++++++++++ src/juicebox_asm/insn/call.rs.html | 16 ++++++++++++++++ src/juicebox_asm/insn/nop.rs.html | 16 ++++++++++++++++ src/juicebox_asm/prelude.rs.html | 2 +- src/juicebox_asm/rt.rs.html | 6 ++++-- 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/juicebox_asm/insn/call.rs.html create mode 100644 src/juicebox_asm/insn/nop.rs.html (limited to 'src/juicebox_asm') diff --git a/src/juicebox_asm/insn.rs.html b/src/juicebox_asm/insn.rs.html index 2affb2d..fd7a473 100644 --- a/src/juicebox_asm/insn.rs.html +++ b/src/juicebox_asm/insn.rs.html @@ -46,14 +46,23 @@ 46 47 48 +49 +50 +51 +52 +53 +54 +55
//! Trait definitions of various instructions.
 
 mod add;
+mod call;
 mod dec;
 mod jmp;
 mod jnz;
 mod jz;
 mod mov;
+mod nop;
 mod ret;
 mod test;
 
@@ -62,6 +71,11 @@
     fn add(&mut self, op1: T, op2: U);
 }
 
+pub trait Call<T> {
+    /// Emit a call instruction.
+    fn call(&mut self, op1: T);
+}
+
 pub trait Dec<T> {
     /// Emit a decrement instruction.
     fn dec(&mut self, op1: T);
diff --git a/src/juicebox_asm/insn/call.rs.html b/src/juicebox_asm/insn/call.rs.html
new file mode 100644
index 0000000..c9d073e
--- /dev/null
+++ b/src/juicebox_asm/insn/call.rs.html
@@ -0,0 +1,16 @@
+call.rs - source
1
+2
+3
+4
+5
+6
+7
+
use crate::prelude::*;
+
+impl Call<Reg64> for Asm {
+    fn call(&mut self, op1: Reg64) {
+        self.encode_r(0xff, 0x2, op1);
+    }
+}
+
+
\ No newline at end of file diff --git a/src/juicebox_asm/insn/nop.rs.html b/src/juicebox_asm/insn/nop.rs.html new file mode 100644 index 0000000..49a1571 --- /dev/null +++ b/src/juicebox_asm/insn/nop.rs.html @@ -0,0 +1,16 @@ +nop.rs - source
1
+2
+3
+4
+5
+6
+7
+
use crate::Asm;
+
+impl Asm {
+    pub fn nop(&mut self) {
+        self.emit(&[0x90]);
+    }
+}
+
+
\ No newline at end of file diff --git a/src/juicebox_asm/prelude.rs.html b/src/juicebox_asm/prelude.rs.html index be1334b..a066379 100644 --- a/src/juicebox_asm/prelude.rs.html +++ b/src/juicebox_asm/prelude.rs.html @@ -17,6 +17,6 @@ pub use crate::label::Label; pub use crate::reg::{Reg16, Reg32, Reg64, Reg8}; -pub use crate::insn::{Add, Dec, Jmp, Jnz, Jz, Mov, Test}; +pub use crate::insn::{Add, Call, Dec, Jmp, Jnz, Jz, Mov, Test};
\ No newline at end of file diff --git a/src/juicebox_asm/rt.rs.html b/src/juicebox_asm/rt.rs.html index 62ee9b7..254745c 100644 --- a/src/juicebox_asm/rt.rs.html +++ b/src/juicebox_asm/rt.rs.html @@ -51,6 +51,7 @@ 51 52 53 +54
//! A simple runtime which can be used to execute emitted instructions.
 
 use core::ffi::c_void;
@@ -64,7 +65,7 @@
 
 impl Runtime {
     /// Create a new [Runtime].
-    pub fn new(code: &[u8]) -> Runtime {
+    pub fn new(code: impl AsRef<[u8]>) -> Runtime {
         // Allocate a single page.
         let len = core::num::NonZeroUsize::new(4096).unwrap();
         let buf = unsafe {
@@ -80,7 +81,8 @@
         };
         {
             // Copy over code.
-            assert!(code.len() < len.get());
+            let code = code.as_ref();
+            assert!(code.len() < len.get());
             unsafe { std::ptr::copy_nonoverlapping(code.as_ptr(), buf.cast(), len.get()) };
         }
 
-- 
cgit v1.2.3