From 95dde6e2c9295eefe7298f4ce028cd21648ed426 Mon Sep 17 00:00:00 2001 From: Jan-Peter von Hunnius Date: Mon, 29 Sep 2025 12:48:35 +0200 Subject: [PATCH] Re-created the fibonacci code and put programs into their own folder --- fibonacci.bin | 1 - programs/README.md | 34 ++++++++++++++++++++++++++++++++++ programs/fibonacci.bin | Bin 0 -> 33 bytes src/main.rs | 4 ++-- 4 files changed, 36 insertions(+), 3 deletions(-) delete mode 100644 fibonacci.bin create mode 100644 programs/README.md create mode 100644 programs/fibonacci.bin diff --git a/fibonacci.bin b/fibonacci.bin deleted file mode 100644 index a875cfe..0000000 --- a/fibonacci.bin +++ /dev/null @@ -1 +0,0 @@ --n -e '\x20\x00\x10\x00\x50\x21\x01\x10\x01\x50\x00\x02\x76\x00\x02\x00\x00\x10\x01\x50\x00\x01\x00\x00\x50\x00\x02\x30\x08\x40\x0C\x00\x00' diff --git a/programs/README.md b/programs/README.md new file mode 100644 index 0000000..17f9b54 --- /dev/null +++ b/programs/README.md @@ -0,0 +1,34 @@ +# MCS-4 Programs + +This directory contains binary program files for the Intel MCS-4 emulator. + +## Available Programs + +### fibonacci.bin +- **Size:** 33 bytes (16 instructions × 2 bytes each + 1 extra byte) +- **Description:** Fibonacci sequence generator +- **Algorithm:** Calculates first 8 Fibonacci numbers using registers and RAM +- **Instructions Used:** LDM, LD, WRM, IAC, ADD, JCN, NOP + +## Usage + +Programs are automatically loaded by the emulator. Use the `--file` option to specify a different program: + +```bash +# Use default fibonacci program +cargo run -- --system basic + +# Use specific program +cargo run -- --system basic --file programs/myprogram.bin +``` + +## Adding New Programs + +1. Create your MCS-4 assembly program +2. Assemble it into raw binary format (big-endian byte pairs) +3. Save as `.bin` file in this directory +4. Update this README with program details + +## Program Format + +MCS-4 programs are stored as raw binary data where each instruction is represented as 8-bit bytes. Multi-byte instructions (like addresses) use big-endian format. \ No newline at end of file diff --git a/programs/fibonacci.bin b/programs/fibonacci.bin new file mode 100644 index 0000000000000000000000000000000000000000..f9c38472326a1b2cdd146933aae89f3db2582303 GIT binary patch literal 33 kcmY#j5MT&UWE5ZwU|=d^U}9hZu^1T`fLsF(2Ob6n05J9fwg3PC literal 0 HcmV?d00001 diff --git a/src/main.rs b/src/main.rs index af35b5e..deee288 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ fn main() { // Parse command line arguments let args: Vec = env::args().collect(); let mut system_type = "basic".to_string(); - let mut program_file = "fibonacci.bin".to_string(); + let mut program_file = "programs/fibonacci.bin".to_string(); let mut i = 1; while i < args.len() { @@ -119,7 +119,7 @@ fn load_program_data(filename: &str) -> Result, String> { } Err(e) => { // If file doesn't exist, try to use default program - if filename == "fibonacci.bin" { + if filename == "programs/fibonacci.bin" { println!( "DEBUG: File {} not found ({}), using default fibonacci program", filename, e