aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2026-05-24 01:07:51 +0000
committeriximeow <me@iximeow.net>2026-05-24 22:20:18 +0000
commit4532dbcfe444a05dea7022d86a502308eedd367f (patch)
treefb7c883c38b10ed99e5474c7c283635133549a06 /README.md
parent347d8f4b677d6879856241a1c2b39783a61df026 (diff)
Diffstat (limited to 'README.md')
-rw-r--r--README.md28
1 files changed, 26 insertions, 2 deletions
diff --git a/README.md b/README.md
index 1d229c6..15ec30e 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,30 @@ eprintln!("ending rip: {:016x}", regs.rip);
eprintln!("ending rax: {:016x}", regs.rax);
```
+for non-x86-64 modes, the path is slightly longer:
+```
+use asmlinator::x86_64::{IsaMode, VcpuExit, VmSettings, Vm};
+
+let settings = VmSettings::new(1024 * 1024, IsaMode::Real);
+let mut vm = Vm::create_by_settings(settings)
+ .expect("can create the VM");
+
+let mut regs = vm.get_regs().unwrap();
+regs.rax = 0x11223344_55667788;
+
+// program VM with "xor al, al; hlt"
+vm.program(&[0x33, 0xc0, 0xf4], &mut regs);
+vm.set_regs(&regs).unwrap();
+
+let res = vm.run().expect("can run cpu");
+assert_eq!(res, VcpuExit::Hlt);
+
+let regs = vm.get_regs().unwrap();
+eprintln!("ending rip: {:016x}", regs.rip);
+eprintln!("ending rax: {:016x}", regs.rax);
+assert_eq!(regs.rax, 0x1122334455660000);
+```
+
### design
it's just a glorified virtual CPU wrapper. there is no device emulation, there
@@ -46,8 +70,8 @@ require setting up an IDT, GDT, paging, ...
### future
-it'd be nice to set up aarch64 processors for code execution too. and
-32-bit/16-bit x86. and to do all this on other OSes with other VM APIs.
+it'd be nice to set up aarch64 processors for code execution too. and to do all
+this on other OSes with other VM APIs.
it would probably nice to expose a C ffi to embed this into other programs!
such an ffi interface should be straightforward. i haven't needed one yet.