Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f639240b6c | |||
| d2c1492dca | |||
| 4ef8bbdf46 |
@@ -0,0 +1,2 @@
|
|||||||
|
[build]
|
||||||
|
rustc-wrapper = "sccache"
|
||||||
Generated
+28
-27
@@ -424,9 +424,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.4.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit-set"
|
name = "bit-set"
|
||||||
@@ -1091,12 +1091,12 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
version = "0.3.12"
|
version = "0.3.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18"
|
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1641,9 +1641,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jpeg-decoder"
|
name = "jpeg-decoder"
|
||||||
version = "0.3.1"
|
version = "0.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0"
|
checksum = "00810f1d8b74be64b13dbf3db89ac67740615d6c891f0e7b6179326533011a07"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
@@ -1674,9 +1674,9 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.173"
|
version = "0.2.174"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8cfeafaffdbc32176b64fb251369d52ea9f0a8fbc6f8759edffef7b525d64bb"
|
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
@@ -1909,18 +1909,19 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_enum"
|
name = "num_enum"
|
||||||
version = "0.7.3"
|
version = "0.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179"
|
checksum = "a973b4e44ce6cad84ce69d797acf9a044532e4184c4f267913d1b546a0727b7a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num_enum_derive",
|
"num_enum_derive",
|
||||||
|
"rustversion",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_enum_derive"
|
name = "num_enum_derive"
|
||||||
version = "0.7.3"
|
version = "0.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
|
checksum = "77e878c846a8abae00dd069496dbe8751b16ac1c3d6bd2a7283a938e8228f90d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2435,9 +2436,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "profiling"
|
name = "profiling"
|
||||||
version = "1.0.16"
|
version = "1.0.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d"
|
checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-xml"
|
name = "quick-xml"
|
||||||
@@ -2495,9 +2496,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "r-efi"
|
name = "r-efi"
|
||||||
version = "5.2.0"
|
version = "5.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
|
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
@@ -2855,9 +2856,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.103"
|
version = "2.0.104"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e4307e30089d6fd6aff212f2da3a1f9e32f3223b1f010fb09b7c95f90f3ca1e8"
|
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -3046,9 +3047,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-attributes"
|
name = "tracing-attributes"
|
||||||
version = "0.1.29"
|
version = "0.1.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1b1ffbcf9c6f6b99d386e7444eb608ba646ae452a36b39737deb9663b610f662"
|
checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -3987,9 +3988,9 @@ checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xcursor"
|
name = "xcursor"
|
||||||
version = "0.3.8"
|
version = "0.3.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0ef33da6b1660b4ddbfb3aef0ade110c8b8a781a3b6382fa5f2b5b040fd55f61"
|
checksum = "635887f4315a33cb714eb059bdbd7c1c92bfa71bc5b9d5115460502f788c2ab5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xdg-home"
|
name = "xdg-home"
|
||||||
@@ -4151,18 +4152,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.8.25"
|
version = "0.8.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb"
|
checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy-derive",
|
"zerocopy-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy-derive"
|
name = "zerocopy-derive"
|
||||||
version = "0.8.25"
|
version = "0.8.26"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef"
|
checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
cargo-features = ["codegen-backend"]
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
codegen-backend = "cranelift"
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "emulator"
|
name = "emulator"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ pub fn run_emulator(
|
|||||||
println!("INFO: Starting emulator.");
|
println!("INFO: Starting emulator.");
|
||||||
|
|
||||||
let mut running = Running::Paused;
|
let mut running = Running::Paused;
|
||||||
|
let mut step = 0;
|
||||||
let mut addr;
|
let mut addr;
|
||||||
let mut history = Vec::<(u32, Instruction)>::new();
|
let mut history = Vec::<(u32, Instruction)>::new();
|
||||||
let size = 256;
|
let size = 256;
|
||||||
@@ -39,7 +40,7 @@ pub fn run_emulator(
|
|||||||
let mut update = false;
|
let mut update = false;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let cmd = if running == Running::Running {
|
let cmd = if running == Running::Running || step > 0 {
|
||||||
match cmd_rx.try_recv() {
|
match cmd_rx.try_recv() {
|
||||||
Ok(cmd) => Some(cmd),
|
Ok(cmd) => Some(cmd),
|
||||||
Err(mpsc::TryRecvError::Empty) => {
|
Err(mpsc::TryRecvError::Empty) => {
|
||||||
@@ -96,26 +97,8 @@ pub fn run_emulator(
|
|||||||
|
|
||||||
processor.reset();
|
processor.reset();
|
||||||
}
|
}
|
||||||
Command::Step => {
|
Command::Step(x) => {
|
||||||
update = true;
|
step = x;
|
||||||
|
|
||||||
running = Running::Paused;
|
|
||||||
|
|
||||||
// Execute one cycle.
|
|
||||||
match processor.cycle() {
|
|
||||||
Ok((addr, instruction)) => {
|
|
||||||
history.push((addr, instruction));
|
|
||||||
}
|
|
||||||
Err(why) => {
|
|
||||||
let pcx = processor.get(Register::Pcx);
|
|
||||||
eprintln!(
|
|
||||||
"Could not decode instruction at {pcx:x}. Reason: {why}"
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
instruction_count += 1;
|
|
||||||
}
|
}
|
||||||
Command::Write(offset, data) => {
|
Command::Write(offset, data) => {
|
||||||
update = true;
|
update = true;
|
||||||
@@ -200,6 +183,31 @@ pub fn run_emulator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if step > 0 {
|
||||||
|
step -= 1;
|
||||||
|
update = true;
|
||||||
|
running = Running::Paused;
|
||||||
|
|
||||||
|
// Execute one cycle.
|
||||||
|
match processor.cycle() {
|
||||||
|
Ok((addr, instruction)) => {
|
||||||
|
history.push((addr, instruction));
|
||||||
|
}
|
||||||
|
Err(why) => {
|
||||||
|
let pcx = processor.get(Register::Pcx);
|
||||||
|
report_err(
|
||||||
|
state_tx,
|
||||||
|
&format!(
|
||||||
|
"Could not decode instruction at {pcx:x}. Reason: {why}"
|
||||||
|
),
|
||||||
|
&mut processor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
instruction_count += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if running == Running::Running {
|
if running == Running::Running {
|
||||||
update = true;
|
update = true;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub enum Command {
|
|||||||
// set emulator state.
|
// set emulator state.
|
||||||
Start,
|
Start,
|
||||||
Stop,
|
Stop,
|
||||||
Step,
|
Step(usize),
|
||||||
Reset(usize),
|
Reset(usize),
|
||||||
Interrupt(Interrupt),
|
Interrupt(Interrupt),
|
||||||
Write(Address, Vec<u8>),
|
Write(Address, Vec<u8>),
|
||||||
|
|||||||
@@ -64,10 +64,7 @@ impl Processor {
|
|||||||
let instruction = Instruction::decode(val)
|
let instruction = Instruction::decode(val)
|
||||||
.map_err(|_| ProcessorError::InvalidInstruction(val))?;
|
.map_err(|_| ProcessorError::InvalidInstruction(val))?;
|
||||||
|
|
||||||
log(&instruction.to_string());
|
|
||||||
|
|
||||||
instruction.execute(self)?;
|
instruction.execute(self)?;
|
||||||
|
|
||||||
Ok((addr, instruction))
|
Ok((addr, instruction))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,18 @@ use common::{instructions::Register, prelude::Instruction};
|
|||||||
|
|
||||||
pub struct ControlPanel {
|
pub struct ControlPanel {
|
||||||
visible: bool,
|
visible: bool,
|
||||||
|
step_amount_input: String,
|
||||||
|
step_amount: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ControlPanel {
|
impl ControlPanel {
|
||||||
#[allow(clippy::must_use_candidate)]
|
#[allow(clippy::must_use_candidate)]
|
||||||
pub const fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self { visible: false }
|
Self {
|
||||||
|
visible: false,
|
||||||
|
step_amount_input: String::from("1"),
|
||||||
|
step_amount: 1,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +65,10 @@ impl Component for ControlPanel {
|
|||||||
|
|
||||||
// Step
|
// Step
|
||||||
if ui.button("Step").clicked() {
|
if ui.button("Step").clicked() {
|
||||||
state.cmd_sender.send(Command::Step).unwrap_or_else(|_| {
|
state
|
||||||
|
.cmd_sender
|
||||||
|
.send(Command::Step(self.step_amount))
|
||||||
|
.unwrap_or_else(|_| {
|
||||||
state.error_log.push("Failed to send command".to_string());
|
state.error_log.push("Failed to send command".to_string());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -98,6 +107,21 @@ impl Component for ControlPanel {
|
|||||||
|
|
||||||
state.send(Command::RegisterRequest);
|
state.send(Command::RegisterRequest);
|
||||||
state.send(Command::RunningRequest);
|
state.send(Command::RunningRequest);
|
||||||
|
state.send(Command::InstructionCountRequest);
|
||||||
|
|
||||||
|
if ui
|
||||||
|
.text_edit_singleline(&mut self.step_amount_input)
|
||||||
|
.changed()
|
||||||
|
{
|
||||||
|
self.step_amount = if let Ok(amount) = self.step_amount_input.parse() {
|
||||||
|
amount
|
||||||
|
} else {
|
||||||
|
state
|
||||||
|
.error_log
|
||||||
|
.push("Unable to parse step amount".to_string());
|
||||||
|
1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Status info
|
// Status info
|
||||||
ui.label(format!(
|
ui.label(format!(
|
||||||
|
|||||||
+6
-10
@@ -20,6 +20,7 @@ _init_stack:
|
|||||||
start:
|
start:
|
||||||
// load the start of the program into rg0
|
// load the start of the program into rg0
|
||||||
lwi program, rg0
|
lwi program, rg0
|
||||||
|
lwi data, rg1
|
||||||
|
|
||||||
// rg0 is our instruction pointer
|
// rg0 is our instruction pointer
|
||||||
// rg1 is our data pointer
|
// rg1 is our data pointer
|
||||||
@@ -41,11 +42,11 @@ loop_start:
|
|||||||
ldb rg0, rg3
|
ldb rg0, rg3
|
||||||
|
|
||||||
|
|
||||||
// pusha 2
|
pusha 2
|
||||||
// push rg3
|
push rg3
|
||||||
// call print::print_byte
|
call print::print_byte
|
||||||
// pop zero
|
pop zero
|
||||||
// popa 2
|
popa 2
|
||||||
|
|
||||||
// switch on the instruction
|
// switch on the instruction
|
||||||
// all cases will return to either loop_start or loop_end
|
// all cases will return to either loop_start or loop_end
|
||||||
@@ -69,11 +70,6 @@ loop_start:
|
|||||||
jeq end
|
jeq end
|
||||||
|
|
||||||
// if we get here, we don't know what the instruction is
|
// if we get here, we don't know what the instruction is
|
||||||
lwi error, rg0
|
|
||||||
push rg0
|
|
||||||
call print::print
|
|
||||||
pop zero
|
|
||||||
|
|
||||||
end:
|
end:
|
||||||
lwi error, rg2
|
lwi error, rg2
|
||||||
pusha 2
|
pusha 2
|
||||||
|
|||||||
Reference in New Issue
Block a user