diff --git a/cocas/assembler/targets/cdm16/target_instructions.py b/cocas/assembler/targets/cdm16/target_instructions.py index 70c886e5..014cecb6 100644 --- a/cocas/assembler/targets/cdm16/target_instructions.py +++ b/cocas/assembler/targets/cdm16/target_instructions.py @@ -335,9 +335,9 @@ def special(line: InstructionNode, temp_storage: dict, _): arg = line.arguments[0] if len(arg.add_terms) != 0 or len(arg.sub_terms) != 0: raise CdmTempException('Const number expected') - if arg.const_term < 0: - raise CdmTempException('Interrupt number must be not negative') - return [InstructionBytesSegment(pack("u3u4s9", 0b100, 0, arg.const_term), line.location)] + if not 0 <= arg.const_term < 512: + raise CdmTempException('Interrupt number out of range') + return [InstructionBytesSegment(pack("u3u4u9", 0b100, 0, arg.const_term), line.location)] elif line.mnemonic == 'reset': if len(line.arguments) == 0: arg = RelocatableExpressionNode(None, [], [], 0) @@ -348,9 +348,9 @@ def special(line: InstructionNode, temp_storage: dict, _): raise CdmTempException(f'Expected 0 or 1 arguments, found {len(line.arguments)}') if len(arg.add_terms) != 0 or len(arg.sub_terms) != 0: raise CdmTempException('Const number expected') - if arg.const_term < 0: - raise CdmTempException('Vector number must be not negative') - return [InstructionBytesSegment(pack("u3u4s9", 0b100, 1, arg.const_term), line.location)] + if not 0 <= arg.const_term < 512: + raise CdmTempException('Vector number out of range') + return [InstructionBytesSegment(pack("u3u4u9", 0b100, 1, arg.const_term), line.location)] elif line.mnemonic == 'addsp': assert_count_args(line.arguments, Union[RelocatableExpressionNode, RegisterNode]) if isinstance(line.arguments[0], RelocatableExpressionNode):