diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-20 23:35:12 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-20 23:35:12 +0100 |
commit | 2bb15c8d75a75f1d75d52ca63017e9492753b8ef (patch) | |
tree | b3d68435d865238f393878c6a5d7cb861fd57646 /src/rt.rs | |
parent | 8ca27aeeb99a0da43e92e39918aa07c0b1443c07 (diff) | |
download | juicebox-asm-2bb15c8d75a75f1d75d52ca63017e9492753b8ef.tar.gz juicebox-asm-2bb15c8d75a75f1d75d52ca63017e9492753b8ef.zip |
disasm: move out and implement on asm/rt
Diffstat (limited to 'src/rt.rs')
-rw-r--r-- | src/rt.rs | 39 |
1 files changed, 1 insertions, 38 deletions
@@ -167,44 +167,7 @@ impl Runtime { /// the `ndisasm` child process. pub fn disasm(&self) { assert!(self.idx <= self.len); - let code = unsafe { core::slice::from_raw_parts(self.buf, self.idx) }; - - // Create ndisasm process, which expects input on stdin. - let mut child = match std::process::Command::new("ndisasm") - .args(["-b64", "-"]) - .stdin(std::process::Stdio::piped()) - .stdout(std::process::Stdio::piped()) - .spawn() - { - Ok(child) => child, - Err(err) if err.kind() == std::io::ErrorKind::NotFound => { - println!("Runtime::disasm: ndisasm not found, skipping!"); - return; - } - Err(err) => { - panic!("{:?}", err); - } - }; - - // Write code to stdin of ndisasm. - use std::io::Write; - child - .stdin - .take() - .expect("failed to take stdin") - .write_all(code) - .expect("failed to write bytes to stdin"); - - // Wait for output from ndisasm and print to stdout. - println!( - "{}", - String::from_utf8_lossy( - &child - .wait_with_output() - .expect("failed to get stdout") - .stdout - ) - ); + crate::disasm::disasm(unsafe { core::slice::from_raw_parts(self.buf, self.idx) }); } /// Reinterpret the block of code pointed to by `fn_start` as `F`. |