Allow specifying immediates as target (right-hand side) operands

This commit is contained in:
jn 2023-02-02 01:48:55 +01:00
parent b23f2b4315
commit 7371aed79f

View File

@ -1148,6 +1148,7 @@ fn condition_source_destination_to_byte(node: &AstNode) -> u8 {
match lhs.as_ref() { match lhs.as_ref() {
AstNode::Register(_) => 0x00, AstNode::Register(_) => 0x00,
AstNode::RegisterPointer(_) => 0x04, AstNode::RegisterPointer(_) => 0x04,
AstNode::Immediate8(_) | AstNode::Immediate16(_) | AstNode::Immediate32(_) | AstNode::LabelOperand {..} => 0x08,
AstNode::ImmediatePointer(_) | AstNode::LabelOperandPointer {..} => 0x0C, AstNode::ImmediatePointer(_) | AstNode::LabelOperandPointer {..} => 0x0C,
_ => panic!("Attempting to parse a non-instruction AST node as an instruction: {:#?}", node), _ => 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::Register (register) => vec.push(register),
AstNode::RegisterPointer(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::ImmediatePointer(immediate) => vec.extend_from_slice(&immediate.to_le_bytes()),
AstNode::LabelOperand {ref name, ref size, is_relative} => { AstNode::LabelOperand {ref name, ref size, is_relative} => {