From 18ad364c3704d656ea63e681cfb93777fa58105a Mon Sep 17 00:00:00 2001 From: dmykyten Date: Tue, 27 Dec 2022 16:16:11 +0200 Subject: [PATCH 1/2] commented out curses functionality --- modules/processor.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/processor.py b/modules/processor.py index 3d9c949..461e17e 100644 --- a/modules/processor.py +++ b/modules/processor.py @@ -87,9 +87,12 @@ # TODO: Should we have a SIMD switch on / off for CISC? +# DONE: +# * at the moment commented out curses functionality + import os import json -import curses +# import curses import logging from bitarray import bitarray from bitarray.util import ba2hex @@ -178,6 +181,9 @@ def __init__(self, isa, architecture, io_arch, program_text, program_start=512, self.instruction = bitarray('') + ''' + Deprecated curses functionality + # Draw the main interface if self.curses_mode: self.start_screen() @@ -192,6 +198,7 @@ def __init__(self, isa, architecture, io_arch, program_text, program_start=512, # Close the curses module screen if we are in its mode self.close_screen() + ''' def __create_registers(self): """ @@ -336,9 +343,13 @@ def __execute_cycle(self): Execute the current instruction, and move on to the next one, moving the instruction pointer """ is_close = False + ''' + Deprecated curses functionality + # Waiting for the key or button to be pressed, depending on the mode if self.curses_mode: is_close = self.curses_next_instruction() + ''' # Executing the instruction if it's not a 'nop' - no operation instruction if (instr_name := self.instructions_dict[self.opcode.to01()][0]) == "nop": @@ -913,6 +924,9 @@ def input_finish(self, char): else: self.input_result_destination.write_data(char) + ''' + Deprecated curses functionality + # Below are the methods for curses-driven command-line interface def start_program(self): """ @@ -1078,6 +1092,7 @@ def close_screen(self): self.std_screen.keypad(False) curses.curs_set(True) curses.endwin() + ''' class SimulatorError(Exception): From 516f4bdae6b560d0f4b49997c4105888240328a6 Mon Sep 17 00:00:00 2001 From: dmykyten Date: Tue, 27 Dec 2022 17:01:44 +0200 Subject: [PATCH 2/2] change signature of __define_directives function --- modules/assembler.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/assembler.py b/modules/assembler.py index 8c80d14..83afa9b 100644 --- a/modules/assembler.py +++ b/modules/assembler.py @@ -240,10 +240,8 @@ def preprocess(self, text : str): # If the label is mentioned with directive specification and its value, we have to encode it into memory elif len(words) == 3: - if words[1] == "db": - self.mov_labels[words[0]] = self.__decode_directive(True, words[2]) - elif words[1] == "dw": - self.mov_labels[words[0]] = self.__decode_directive(False, words[2]) + if words[1] in ["db", "dw"]: + self.mov_labels[words[0]] = self.__decode_directive(words[1], words[2]) else: raise AssemblerError("Provide a valid assembly directive") @@ -258,15 +256,16 @@ def preprocess(self, text : str): return result_text @staticmethod - def __decode_directive(is_byte, value): + def __decode_directive(directive, value): """ Decodes operands for directives (db, dw) - :param is_byte: bool - to encode value in a byte or word + :param directive: str - valid assembly directive :param value: str - an operand to encode """ # We just figure out what's being encoded into bits - a number (which should fit in 8/16 bits) or a string of # characters (every ASCII character is 1 byte), and return the value we found + is_byte = directive == 'db' limits = (-2 ** 7 + 1, 2 ** 8) if is_byte else (-2 ** 15 + 1, 2 ** 16) int_pattern = r"^\d+$" str_pattern = r"^\"[a-zA-Z0-9\\]+\"$"