def instr_Jmp(instruction, pointers, fo, assembly_failed): if len(instruction) < 4: if len(instruction) < 3: CustomError.ERR_missingArgument(instruction[-1], '1') return False CustomError.ERR_missingArgument(instruction[-1], '2') return False topmid_byte_bottom_nibble = jump_flags.get(instruction[1], None) if topmid_byte_bottom_nibble == None: CustomError.ERR_invalidArgument(instruction[-1], '1') return False if instruction[2][0] != '&': CustomError.ERR_invalidArgumentType(instruction[-1], '2', "label reference") return False temp = pointers.get(instruction[2], None) if temp == None: CustomError.ERR_labelMissing(instruction[-1]) return False low_bytes = int(temp) * 2 if low_bytes > 65535: CustomError.ERR_outOfBounds(instruction[-1]) return False if not assembly_failed: fo.write("{}{} {}".format("0d0", topmid_byte_bottom_nibble, "%.4x" % (low_bytes))) return True
def instr_Call(instruction, pointers, fo, assembly_failed): if len(instruction) < 3: CustomError.ERR_missingArgument(instruction[-1], '1') return False if instruction[1][0] != '&': CustomError.ERR_invalidArgumentType(instruction[-1], '1', "label reference") return False temp = pointers.get(instruction[1], None) if temp == None: CustomError.ERR_labelMissing(instruction[-1]) return False low_bytes = int(temp) * 2 if low_bytes > 65535: CustomError.ERR_outOfBounds(instruction[-1]) return False if not assembly_failed: fo.write("{} {}".format("0efe", "%.4x" % (low_bytes))) return True