rename instructions while working on assembler/disassembler

This commit is contained in:
2024-10-19 11:55:29 -04:00
parent dea4b1aa92
commit f6751557c6
5 changed files with 188 additions and 68 deletions
+44
View File
@@ -0,0 +1,44 @@
use std::path::Path;
use clap::Parser;
/// Ch8Asm
/// Converts well formed CH8ASM.
/// no variables.
/// no labels.
/// nothing fun.
pub struct Assembler {}
impl Assembler {
pub fn instruction_to_string() -> String {
// Format the output as
// IST [P0] [P1] [P2] ; XXXX
// IST = 3 letter instruction code
// P0-2 = Parameters to Instruction
// XXXX = Hex representation of data
// ** OR **
// DW XXXX ;
// DW = DATAWORD
// XXXX = HEX OF DATA
String::new()
}
}
#[derive(Parser)]
#[command(version, about, long_about = None)]
struct AssemblerApp {
#[arg(short)]
input_file: Box<Path>,
#[arg(short)]
output_file: Option<Path>
}
fn main() {
println!("Taxation is Theft");
let result = AssemblerApp::parse();
println!("Preparing to assemble {}", result.input_file.file_name());
}
+4 -2
View File
@@ -22,6 +22,8 @@ fn main() {
println!("PREPARING TO DISASSEMBLE {:?}", result.input_file.file_name());
let mut last_byte: u8 = 0x00;
let mut working_instruction: u16 = 0x0000;
let mut dump_as_data: bool = false;
// read the input file and loop through it byte by byte.
for (offset, byte) in std::fs::read(result.input_file).unwrap().iter().enumerate() {
@@ -35,8 +37,8 @@ fn main() {
println!("FOUND ERROR INSTRUCTION. LIKELY DATA.");
}
Chip8CpuInstructions::JpAddr(x) => {
if x == (offset + 0x1ff) as u16 {
println!("FOUND JUMP TO SELF. INFINITE LOOP DETECTED.");
if (offset + 0x200) == x as usize {
println!("INFINITE LOOP")
}
}
_ => {
+3
View File
@@ -0,0 +1,3 @@
#[test]
fn smoke() { assert!(true) }