added assembler skeleton code

This commit is contained in:
2025-06-15 21:53:57 +01:00
parent 2b8281157e
commit 2b5ad0885b
5 changed files with 24 additions and 10 deletions
Generated
+4
View File
@@ -234,6 +234,9 @@ dependencies = [
[[package]]
name = "assembler"
version = "0.2.0"
dependencies = [
"common",
]
[[package]]
name = "async-broadcast"
@@ -975,6 +978,7 @@ dependencies = [
name = "emulator"
version = "0.1.0"
dependencies = [
"assembler",
"common",
"eframe",
"egui",
+1
View File
@@ -5,3 +5,4 @@ edition.workspace = true
authors.workspace = true
[dependencies]
common = { path = "../common" }
+10 -10
View File
@@ -1,14 +1,14 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
use common::prelude::Instruction;
pub fn assemble(src: &str) -> Vec<Instruction> {
todo!()
}
#[cfg(test)]
mod tests {
use super::*;
pub fn disassemble(binary: Vec<Instruction>) -> String {
// TODO: disassembling functionality
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
// - we probably don't need to implement this for a while yet.
// - this method should recover symbols such as labels and variables from the human written assembly, recognising
// sequences that are expansions of pseduo-instructions and reversing this to produce near enough the original source code.
todo!()
}
+1
View File
@@ -9,6 +9,7 @@ path = "src/lib.rs"
[dependencies]
common = { path = "../common" }
assembler = { path = "../assembler" }
eframe = "0.31.1"
egui = "0.31.1"
rfd = "0.15.3"
+8
View File
@@ -279,6 +279,14 @@ impl Editor {
// builds the current file
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];
}