Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
assembler help message
Browse files Browse the repository at this point in the history
  • Loading branch information
filiparag committed Jan 14, 2023
1 parent a711da6 commit 408cbbc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ version = "0.4.0"
edition = "2021"
authors = ["Filip Parag <filip@parag.rs>"]
license = "MIT"
description = "Emulator and debugger for LPRS1 ISA & CPU"
description = "Emulator, debugger and assembler for LPRS1 ISA & CPU"
readme = "README.md"
repository = "https://github.com/filiparag/ftn-lprsemu"
keywords = ["emulator", "assembler", "assembly"]
categories = ["command-line-interface", "emulators", "parsing"]
keywords = ["emulator", "debugger", "assembler", "assembly"]
categories = [
"command-line-interface",
"emulators",
"parsing",
"development-tools::debugging",
]
include = ["/src"]
maintenance = { status = "passively-maintained" }
rust-version = "1.68"
Expand Down
13 changes: 12 additions & 1 deletion src/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ macro_rules! concat {

fn parse_rom(rom: &[Instruction]) -> Vec<u8> {
let mut vhdl = Vec::new();
concat!(vhdl <= "-- instr_rom.vhd";);
concat!(vhdl <= "architecture Behavioral of instr_rom is";);
concat!(vhdl <= "begin";);
for (a, ins) in rom.iter().enumerate() {
Expand All @@ -42,16 +43,26 @@ fn parse_rom(rom: &[Instruction]) -> Vec<u8> {

fn parse_ram(ram: &[u16]) -> Vec<u8> {
let mut vhdl = Vec::new();
concat!(vhdl <= "-- data_ram.vhd";);
for (index, value) in ram.iter().enumerate() {
concat!(vhdl <= "sMEM({index}) <= x\"{value:04x}\";";)
}
vhdl
}

fn print_help() {
println!("{} {}", env!("CARGO_BIN_NAME"), env!("CARGO_PKG_VERSION"),);
println!("{}", env!("CARGO_PKG_DESCRIPTION"));
println!("{}", env!("CARGO_PKG_AUTHORS"));
}

fn main() {
let path = match std::env::args().nth(1) {
Some(p) => p,
None => return,
None => {
print_help();
return;
}
};

#[allow(unused)]
Expand Down
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ fn prompt(separator: &str) -> Option<Vec<String>> {
}

fn print_help() {
println!(
"{} {} - {}",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
env!("CARGO_PKG_DESCRIPTION")
);
println!("{} {}", env!("CARGO_BIN_NAME"), env!("CARGO_PKG_VERSION"),);
println!("{}", env!("CARGO_PKG_DESCRIPTION"));
println!("{}", env!("CARGO_PKG_AUTHORS"));
println!();
println!("Usage:");
Expand Down

0 comments on commit 408cbbc

Please sign in to comment.