From 812296d2dbd4d08820d871ac709f2e397c3aa8c1 Mon Sep 17 00:00:00 2001 From: Bedohswe <> Date: Thu, 8 Feb 2024 23:56:57 +0500 Subject: [PATCH] Allow pushing negative addresses. --- src/parse.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/parse.rs b/src/parse.rs index 437317d..db340e7 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -29,10 +29,8 @@ pub fn parse(stack: &mut Stack, file_content: &str) { arg = splited_data.get(0).unwrap().clone(); } else if name.chars().nth(0) == Some('$') || name.chars().nth(1) == Some('$') { arg = command[1].clone(); - } else if command[1] == "-1" { // required for - data = 65535; // _unix_random - } else if let Ok(number) = command[1].parse() { - data = number; + } else if let Ok(number) = command[1].parse::() { + data = number as u16; } else { eprintln!("{}", ParseError::ArgumentNotRequired(command[0].to_string(), i + 1, line.to_string())); std::process::exit(2); @@ -42,4 +40,4 @@ pub fn parse(stack: &mut Stack, file_content: &str) { let inst = Instruction { name, arg, data }; stack.program.push(inst); } -} \ No newline at end of file +} -- 2.39.5