# Path: msp430/asm/mcu_definition_parser.py
# class MCUDefintitionError(Exception):
# class MCUDefintitions(rpn.RPN):
# def filtered_words(words, mapping):
#     def __init__(self):
#     def address_range(self, range_str):
#     def word_TEMPLATE_BEGIN(self, stack):
#     def word_PROGRAMMABLE(self, stack):
#     def word_READ_ONLY(self, stack):
#     def word_MEMORY_MAP_BEGIN(self, stack):
#     def word_MEMORY_MAP_END(self, stack):
#     def word_SEGMENT(self, stack):
#     def word_SYMBOL(self, stack):
#     def word_NAME(self, stack):
#     def word_BASED_ON(self, stack):
# def parse_words(iterable):
# def expand_definition(memory_maps, name):
# def load_internal():
# def load_from_file(filename):
# 
# Path: msp430/asm/rpn.py
# class Word(unicode):
# class RPNError(Exception):
# class RPNBase(list):
# class RPNStackOps(object):
# class RPNSimpleMathOps(object):
# class RPNMoreMathOps(object):
# class RPNBitOps(object):
# class RPNLogicOps(object):
# class RPNCompareOps(object):
# class RPN(RPNBase, RPNStackOps, RPNSimpleMathOps, RPNMoreMathOps,
#           RPNBitOps, RPNLogicOps, RPNCompareOps):
#     def __new__(cls, word, filename, lineno, text):
#     def lower(self):
# def annotated_words(sequence, filename=None, lineno=None, offset=None, text=None):
# def words_in_string(data, name='<string>', include_newline=False):
# def words_in_file(filename, fileobj=None, include_newline=False):
#     def __init__(self, message, filename=None, lineno=None, column=None, offset=None, text=None):
#     def __str__(self):
# def rpn_function(code):
#     def wrapper(stack):
# def word(name):
#     def decorate_word(function):
#     def __init__(self, namespace=None):
#     def interpret_sequence(self, sequence, filename=None):
#     def interpret(self, iterator):
#     def look_up(self, word):
#     def next_word(self):
#     def interpret_word(self, word):
#     def push(self, obj):
#     def pop(self):
#     def pop2(self):
#     def prettyprint(self, stack):
#     def __str__(self):
#     def printer(self, obj):
#     def clear(self, stack=None):
#     def dup(self, stack):
#     def drop(self, stack):
#     def swap(self, stack):
#     def over(self, stack):
#     def pick(self, stack):
#     def add(self, stack):
#     def sub(self, stack):
#     def mul(self, stack):
#     def div(self, stack):
#     def minimum(self, stack):
#     def maximum(self, stack):
#     def word_INT(self, stack):
#     def word_FLOAT(self, stack):
#     def negate(self, stack):
#     def bitor(self, stack):
#     def bitand(self, stack):
#     def bitxor(self, stack):
#     def bit_shift_left(self, stack):
#     def bit_shift_right(self, stack):
#     def bitnot(self, stack):
#     def word_NOT(self, stack):
#     def word_AND(self, stack):
#     def word_OR(self, stack):
#     def word_IFTE(self, stack):
#     def word_LIST(self, stack):
#     def smaller(self, stack):
#     def smaller_equal(self, stack):
#     def larger(self, stack):
#     def larger_equal(self, stack):
#     def equal(self, stack):
#     def not_equal(self, stack):
# def eval(words, stack=[], namespace={}):
# def python_function(code, namespace={}):
#     def wrapper(*args):
# def interpreter_loop(namespace={}, debug=False, rpn_class=RPN, rpn_instance=None):
#             N = min(4, len(self))
# 
# Path: msp430/asm/peripherals.py
# class SymbolError(Exception):
# class SymbolDefinitions(rpn.RPN):
#     def __init__(self):
#     def word_INCLUDE(self, stack):
#     def word_BIT(self, stack):
#     def word_VALUE(self, stack):
#     def word_REGISTER(self, stack):
#     def word_SHORTCUT(self, stack):
#         def update_bits(stack, bits=self.bits):
#     def word_NAMED(self, stack):
#     def word_VIRTUAL(self, stack):
#     def word_BYTE_ACCESS(self, stack):
#     def word_WORD_ACCESS(self, stack):
#     def word_END_REGISTER(self, stack):
#     def word_PERIPHERAL(self, stack):
#     def word_END_PERIPHERAL(self, stack):
# def parse_words(iterable):
# def load_symbols(filename):
# def load_internal(name):


import sys
import codecs
    import os
    import logging
from msp430.asm import mcu_definition_parser
from msp430.asm import rpn, peripherals
    from optparse import OptionParser
                sys.exit(1)

    linker = Linker(instructions)

    # load symbols
    if options.symbols is not None:
        all_peripherals = peripherals.load_internal(options.symbols)
        for peripheral in all_peripherals.peripherals.values():
            for reg_name, register in peripheral.items():
                if reg_name.startswith('__'): continue
                if '__address__' in register:
                    linker.labels[register['__name__']] = register['__address__']
                for value, name in register['__bits__'].items():
                    linker.labels[name] = value
                for value, name in register['__values__'].items():
                    linker.labels[name] = value
            if '__values__' in peripheral:
                for value, name in peripheral['__values__'].items():
                    linker.labels[name] = value

    # ========= load MCU definition =========

    if options.verbose > 1:
        sys.stderr.write("Step 1: load segment descriptions.\n")

    # load the file and get the desired MCU description
    try:
        if options.segmentfile:
            mem_maps = mcu_definition_parser.load_from_file(options.segmentfile)
        else:

# Path: msp430/asm/mcu_definition_parser.py
# class MCUDefintitionError(Exception):
# class MCUDefintitions(rpn.RPN):
# def filtered_words(words, mapping):
#     def __init__(self):
#     def address_range(self, range_str):
#     def word_TEMPLATE_BEGIN(self, stack):
#     def word_PROGRAMMABLE(self, stack):
#     def word_READ_ONLY(self, stack):
#     def word_MEMORY_MAP_BEGIN(self, stack):
#     def word_MEMORY_MAP_END(self, stack):
#     def word_SEGMENT(self, stack):
#     def word_SYMBOL(self, stack):
#     def word_NAME(self, stack):
#     def word_BASED_ON(self, stack):
# def parse_words(iterable):
# def expand_definition(memory_maps, name):
# def load_internal():
# def load_from_file(filename):
# 
# Path: msp430/asm/rpn.py
# class Word(unicode):
# class RPNError(Exception):
# class RPNBase(list):
# class RPNStackOps(object):
# class RPNSimpleMathOps(object):
# class RPNMoreMathOps(object):
# class RPNBitOps(object):
# class RPNLogicOps(object):
# class RPNCompareOps(object):
# class RPN(RPNBase, RPNStackOps, RPNSimpleMathOps, RPNMoreMathOps,
#           RPNBitOps, RPNLogicOps, RPNCompareOps):
#     def __new__(cls, word, filename, lineno, text):
#     def lower(self):
# def annotated_words(sequence, filename=None, lineno=None, offset=None, text=None):
# def words_in_string(data, name='<string>', include_newline=False):
# def words_in_file(filename, fileobj=None, include_newline=False):
#     def __init__(self, message, filename=None, lineno=None, column=None, offset=None, text=None):
#     def __str__(self):
# def rpn_function(code):
#     def wrapper(stack):
# def word(name):
#     def decorate_word(function):
#     def __init__(self, namespace=None):
#     def interpret_sequence(self, sequence, filename=None):
#     def interpret(self, iterator):
#     def look_up(self, word):
#     def next_word(self):
#     def interpret_word(self, word):
#     def push(self, obj):
#     def pop(self):
#     def pop2(self):
#     def prettyprint(self, stack):
#     def __str__(self):
#     def printer(self, obj):
#     def clear(self, stack=None):
#     def dup(self, stack):
#     def drop(self, stack):
#     def swap(self, stack):
#     def over(self, stack):
#     def pick(self, stack):
#     def add(self, stack):
#     def sub(self, stack):
#     def mul(self, stack):
#     def div(self, stack):
#     def minimum(self, stack):
#     def maximum(self, stack):
#     def word_INT(self, stack):
#     def word_FLOAT(self, stack):
#     def negate(self, stack):
#     def bitor(self, stack):
#     def bitand(self, stack):
#     def bitxor(self, stack):
#     def bit_shift_left(self, stack):
#     def bit_shift_right(self, stack):
#     def bitnot(self, stack):
#     def word_NOT(self, stack):
#     def word_AND(self, stack):
#     def word_OR(self, stack):
#     def word_IFTE(self, stack):
#     def word_LIST(self, stack):
#     def smaller(self, stack):
#     def smaller_equal(self, stack):
#     def larger(self, stack):
#     def larger_equal(self, stack):
#     def equal(self, stack):
#     def not_equal(self, stack):
# def eval(words, stack=[], namespace={}):
# def python_function(code, namespace={}):
#     def wrapper(*args):
# def interpreter_loop(namespace={}, debug=False, rpn_class=RPN, rpn_instance=None):
#             N = min(4, len(self))
# 
# Path: msp430/asm/peripherals.py
# class SymbolError(Exception):
# class SymbolDefinitions(rpn.RPN):
#     def __init__(self):
#     def word_INCLUDE(self, stack):
#     def word_BIT(self, stack):
#     def word_VALUE(self, stack):
#     def word_REGISTER(self, stack):
#     def word_SHORTCUT(self, stack):
#         def update_bits(stack, bits=self.bits):
#     def word_NAMED(self, stack):
#     def word_VIRTUAL(self, stack):
#     def word_BYTE_ACCESS(self, stack):
#     def word_WORD_ACCESS(self, stack):
#     def word_END_REGISTER(self, stack):
#     def word_PERIPHERAL(self, stack):
#     def word_END_PERIPHERAL(self, stack):
# def parse_words(iterable):
# def load_symbols(filename):
# def load_internal(name):


# Path: msp430/asm/ld.py
import sys
import codecs
    import os
    import logging
from msp430.asm import mcu_definition_parser
from msp430.asm import rpn, peripherals
    from optparse import OptionParser

                sys.exit(1)

    linker = Linker(instructions)

    # load symbols
    if options.symbols is not None:
        all_peripherals = peripherals.load_internal(options.symbols)
        for peripheral in all_peripherals.peripherals.values():
            for reg_name, register in peripheral.items():
                if reg_name.startswith('__'): continue
                if '__address__' in register:
                    linker.labels[register['__name__']] = register['__address__']
                for value, name in register['__bits__'].items():
                    linker.labels[name] = value
                for value, name in register['__values__'].items():
                    linker.labels[name] = value
            if '__values__' in peripheral:
                for value, name in peripheral['__values__'].items():
                    linker.labels[name] = value

    # ========= load MCU definition =========

    if options.verbose > 1:
        sys.stderr.write("Step 1: load segment descriptions.\n")

    # load the file and get the desired MCU description
    try:
        if options.segmentfile:
            mem_maps = mcu_definition_parser.load_from_file(options.segmentfile)
        else:

            mem_maps = mcu_definition_parser.load_internal()