# Path: skoolkit/components.py
# def get_component(name, *args):
#     """Return a component declared in the ``[skoolkit]`` section of
#     `skoolkit.ini`.
# 
#     :param name: The component name.
#     :param args: Arguments passed to the component's constructor.
#     """
#     obj = get_object(get_value(name))
#     if callable(obj):
#         return obj(*args)
#     return obj
# 
# Path: skoolkit/ctlparser.py
# DEFAULT_BASE = 'n'


from skoolkit.components import get_component
from skoolkit.ctlparser import DEFAULT_BASE
# This file is part of SkoolKit.
#
# SkoolKit is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# SkoolKit is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# SkoolKit. If not, see <http://www.gnu.org/licenses/>.


class OperandFormatter:
    """Initialise the operand formatter.

    :param config: Configuration object with the following attributes:

                   * `asm_hex` - if `True`, default base is hexadecimal
                   * `asm_lower` - if `True`, format operands in lower case
    """
    # Component API
    def __init__(self, config):
        self.byte_formats = {
            'b': '%{:08b}',
            'd': '{}',
            'h': '${:02X}',
            'm': '-{}',

# Path: skoolkit/components.py
# def get_component(name, *args):
#     """Return a component declared in the ``[skoolkit]`` section of
#     `skoolkit.ini`.
# 
#     :param name: The component name.
#     :param args: Arguments passed to the component's constructor.
#     """
#     obj = get_object(get_value(name))
#     if callable(obj):
#         return obj(*args)
#     return obj
# 
# Path: skoolkit/ctlparser.py
# DEFAULT_BASE = 'n'


# Path: skoolkit/disassembler.py
from skoolkit.components import get_component
from skoolkit.ctlparser import DEFAULT_BASE

# This file is part of SkoolKit.
#
# SkoolKit is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# SkoolKit is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# SkoolKit. If not, see <http://www.gnu.org/licenses/>.


class OperandFormatter:
    """Initialise the operand formatter.

    :param config: Configuration object with the following attributes:

                   * `asm_hex` - if `True`, default base is hexadecimal
                   * `asm_lower` - if `True`, format operands in lower case
    """
    # Component API
    def __init__(self, config):
        self.byte_formats = {
            'b': '%{:08b}',
            'd': '{}',
            'h': '${:02X}',
            'm': '-{}',

            DEFAULT_BASE: '{}'