added assembler skeleton code
This commit is contained in:
Generated
+4
@@ -234,6 +234,9 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "assembler"
|
name = "assembler"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
dependencies = [
|
||||||
|
"common",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-broadcast"
|
name = "async-broadcast"
|
||||||
@@ -975,6 +978,7 @@ dependencies = [
|
|||||||
name = "emulator"
|
name = "emulator"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"assembler",
|
||||||
"common",
|
"common",
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui",
|
"egui",
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ edition.workspace = true
|
|||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
common = { path = "../common" }
|
||||||
+10
-10
@@ -1,14 +1,14 @@
|
|||||||
pub fn add(left: u64, right: u64) -> u64 {
|
use common::prelude::Instruction;
|
||||||
left + right
|
|
||||||
|
pub fn assemble(src: &str) -> Vec<Instruction> {
|
||||||
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
pub fn disassemble(binary: Vec<Instruction>) -> String {
|
||||||
mod tests {
|
// TODO: disassembling functionality
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
// - we probably don't need to implement this for a while yet.
|
||||||
fn it_works() {
|
// - this method should recover symbols such as labels and variables from the human written assembly, recognising
|
||||||
let result = add(2, 2);
|
// sequences that are expansions of pseduo-instructions and reversing this to produce near enough the original source code.
|
||||||
assert_eq!(result, 4);
|
todo!()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
common = { path = "../common" }
|
common = { path = "../common" }
|
||||||
|
assembler = { path = "../assembler" }
|
||||||
eframe = "0.31.1"
|
eframe = "0.31.1"
|
||||||
egui = "0.31.1"
|
egui = "0.31.1"
|
||||||
rfd = "0.15.3"
|
rfd = "0.15.3"
|
||||||
@@ -279,6 +279,14 @@ impl Editor {
|
|||||||
|
|
||||||
// builds the current file
|
// builds the current file
|
||||||
if ui.button("Build").clicked() {
|
if ui.button("Build").clicked() {
|
||||||
|
let instructions = assembler::assemble(&self.text);
|
||||||
|
|
||||||
|
// TODO: uncomment this once assembler works!!!
|
||||||
|
// self.output = instructions
|
||||||
|
// .iter()
|
||||||
|
// .flat_map(|i| i.encode().to_le_bytes().to_vec())
|
||||||
|
// .collect();
|
||||||
|
|
||||||
self.output = vec![0x00; 256];
|
self.output = vec![0x00; 256];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user