From 0ce5c496d3fed6d9619231879dc1193dbbb778dc Mon Sep 17 00:00:00 2001 From: dzmat Date: Sat, 27 Jul 2019 15:23:33 +0700 Subject: [PATCH] Add more translation diagnostics Prevent from silently accepting commands like "ld 14", where user mistyped from "ldm 14" --- intel4004_emu/translator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intel4004_emu/translator.py b/intel4004_emu/translator.py index 715b21b..d340aff 100644 --- a/intel4004_emu/translator.py +++ b/intel4004_emu/translator.py @@ -95,6 +95,8 @@ def parseInstruction(self, addr): raise Exception("Unknown instruction %s %s" % (self.opcode, inTheLine)) if len(self.parts) != params + 1: raise Exception("Expected %d parameters %s" % (params, inTheLine)) + if self.opcode=='ld' and not (type(self.params[0]) is str) : + raise Exception("Expected register parameter for ld instruction %s" % ( inTheLine)) self.size = size self.addr = addr