OpenCores
URL https://opencores.org/ocsvn/ssbcc/ssbcc/trunk

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [asmDef_9x8.py] - Diff between revs 9 and 11

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 9 Rev 11
Line 80... Line 80...
  #
  #
  # Configure the class for identifying and processing macros.
  # Configure the class for identifying and processing macros.
  #
  #
  ################################################################################
  ################################################################################
 
 
  def AddMacro(self,name,macroLength,args):
  def AddMacro(self,name,macroLength,args,doc=None):
    """
    """
    Add a macro to the list of recognized macros.
    Add a macro to the list of recognized macros.
      name              string with the name of the macro
      name              string with the name of the macro
      macroLength       number of instructions the macro expands to
      macroLength       number of instructions the macro expands to
                        Note:  A negative value means that the macro has a
                        Note:  A negative value means that the macro has a
Line 98... Line 98...
                          2.  The remaining elements of the list are the types
                          2.  The remaining elements of the list are the types
                              of arguments that can be accepted for the
                              of arguments that can be accepted for the
                              required or optional arguments.
                              required or optional arguments.
                        Note:  Only the last list in args is allowed to
                        Note:  Only the last list in args is allowed to
                               indicate an optional value for that argument.
                               indicate an optional value for that argument.
 
      doc               doc string for the macro
 
 
    Also record the allowed number of allowed arguments to the macro.
    Also record the allowed number of allowed arguments to the macro.
    """
    """
    if name in self.macros['list']:
    if name in self.macros['list']:
      raise Exception('Program Bug -- name "%s" has already been listed as a macro' % name);
      raise Exception('Program Bug -- name "%s" has already been listed as a macro' % name);
    self.macros['list'].append(name);
    self.macros['list'].append(name);
    self.macros['length'].append(macroLength);
    self.macros['length'].append(macroLength);
    self.macros['args'].append(args);
    self.macros['args'].append(args);
 
    self.macros['doc'].append(doc)
    # Compute the range of the number of allowed arguments by first counting
    # Compute the range of the number of allowed arguments by first counting
    # the number of required arguments and then determining whether or not
    # the number of required arguments and then determining whether or not
    # there is at most one optional argument.
    # there is at most one optional argument.
    nRequired = 0;
    nRequired = 0;
    while (nRequired < len(args)) and (args[nRequired][0] == ''):
    while (nRequired < len(args)) and (args[nRequired][0] == ''):
Line 138... Line 140...
        break;
        break;
    else:
    else:
      raise asmDef.AsmException('Definition for macro "%s" not found' % macroName);
      raise asmDef.AsmException('Definition for macro "%s" not found' % macroName);
    execfile(fullMacro);
    execfile(fullMacro);
    exec('%s(self)' % macroName);
    exec('%s(self)' % macroName);
 
    exec('docString = %s.__doc__' % macroName)
 
    if docString and not self.macros['doc'][-1]:
 
      self.macros['doc'][-1] = docString
 
 
  def IsBuiltInMacro(self,name):
  def IsBuiltInMacro(self,name):
    """
    """
    Indicate if the macro is built-in to the assembler or is taken from the
    Indicate if the macro is built-in to the assembler or is taken from the
    ./macros directory.
    ./macros directory.
Line 1278... Line 1283...
    # Note:  'symbol' is a catch-call for functions, labels, variables, etc.
    # Note:  'symbol' is a catch-call for functions, labels, variables, etc.
    #        These are restricted to the appropriate types when the macros are
    #        These are restricted to the appropriate types when the macros are
    #        expanded.
    #        expanded.
    #
    #
 
 
    self.macros = dict(list=list(), length=list(), args=list(), nArgs=list(), builtIn = list());
    self.macros = dict(list=list(), length=list(), args=list(), nArgs=list(), builtIn = list(), doc = list());
    self.EmitFunction = dict();
    self.EmitFunction = dict();
 
 
    # Macros built in to the assembler (to access primitives).
    # Macros built in to the assembler (to access primitives).
    self.AddMacro('.call',              3, [
    self.AddMacro('.call',              3, [
                                             ['','symbol'],
                                             ['','symbol'],

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.