From 7371aed79ff806e5befae323d5c0a9a13a4db31d Mon Sep 17 00:00:00 2001 From: jn Date: Thu, 2 Feb 2023 01:48:55 +0100 Subject: [PATCH] Allow specifying immediates as target (right-hand side) operands --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index 6a21afa..7865e46 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1148,6 +1148,7 @@ fn condition_source_destination_to_byte(node: &AstNode) -> u8 { match lhs.as_ref() { AstNode::Register(_) => 0x00, AstNode::RegisterPointer(_) => 0x04, + AstNode::Immediate8(_) | AstNode::Immediate16(_) | AstNode::Immediate32(_) | AstNode::LabelOperand {..} => 0x08, AstNode::ImmediatePointer(_) | AstNode::LabelOperandPointer {..} => 0x0C, _ => panic!("Attempting to parse a non-instruction AST node as an instruction: {:#?}", node), } @@ -1286,6 +1287,9 @@ fn node_to_immediate_values(node: &AstNode, instruction: &AssembledInstruction) AstNode::Register (register) => vec.push(register), AstNode::RegisterPointer(register) => vec.push(register), + AstNode::Immediate8 (immediate) => vec.push(immediate), + AstNode::Immediate16 (immediate) => vec.extend_from_slice(&immediate.to_le_bytes()), + AstNode::Immediate32 (immediate) => vec.extend_from_slice(&immediate.to_le_bytes()), AstNode::ImmediatePointer(immediate) => vec.extend_from_slice(&immediate.to_le_bytes()), AstNode::LabelOperand {ref name, ref size, is_relative} => {