denver-code / pc_simulation_rs

Basic Rust app that will simulate some of the flows on computer like CPU, RAM, BIOS and ASM-like instructions
1 stars 0 forks source link

PC Simulation

Basic Rust app that will simulate some of the flows on computer, including:

Simulation has option to write simple assembly-like programs with small set of instructions:

While I'm aiming to make it as low-level and realistic as possible - some of the features jsut could't be realisied due to number of reasons, one of them - I'm still researching about flows and how everything is working.

Run asm-like code

BIOS> filename.asm

You can play around with some example programs:

Program example

; Example program
VER = 1                    ; Enable debug (VERBOSE) prints of execution
INIT [0x08] = 0b00000101   ; Initialize memory at address 0x08 with binary 5
INIT [0x10] = 0b00001010   ; Initialize memory at address 0x10 with binary 10
INIT [0x1F] = 0b00001010

LOAD R1, [0x08]            ; Load value from address 0x08 into register R1
LOAD R2, [0x10]            ; Load value from address 0x10 into register R2
ADD R1, R2, R3             ; Add R1 and R2, store result in R3

STORE R3, [0x20]           ; Store the result in memory address 0x20

OUT R3                     ; Display the register R3

CLEAR [0x20]               ; Clear the value in memory address 0x20
CLEAR [0x08]               ; Clear the value in memory address 0x08
CLEAR [0x10]               ; Clear the value in memory address 0x10
CLEAR [0x1F]               ; Clear the value in memory address 0x1F

VER = 0                    ; Disable debug (VERBOSE) prints of execution
HALT                       ; Stop execution

Getting Started

  1. Make sure you have rust installed
  2. Clone the repo:
    git clone https://github.com/denver-code/pc_simulation_rs
    cd pc_simulation_rs
  3. Run or Build the project:
    # Build
    cargo build --release (Optional)
    # Run
    cargo run

Usage

BIOS Commands

Once the simulator is powered on, you can use the following commands in the BIOS prompt:

- address [hex]: View the value stored in memory at the given address (in hexadecimal in square brackets).

- memory_dump: Display the entire contents of the RAM.

- exit: Quit the BIOS.

- [filename].asm: Load and run an assembly-like program from a file.