py_register_machine2.tools.assembler.assember: The Basic Assembler
Just replaces mnemonics with opcodes and handles references.
py_register_machine2.tools.assembler.assembler.
ArgumentError
(*args)[source]¶Raised if an argument does not fit the requirements.
py_register_machine2.tools.assembler.assembler.
AssembleError
(*args)[source]¶Rasied if the assemler terminates without success.
py_register_machine2.tools.assembler.assembler.
Assembler
(processor, open_stream, directives=[], commentstarts=[';'])[source]¶Reads assembly code from open_stream
and converts it to
a list
of integers that can be programmed to the ROM or the Flash.
Stages:
[(lineno, "command", <command>, arguments), ...]`
or
[(lineno, "data", <data description>, data), ...]`
str
objects are
interpreted as addresses.assemble
()[source]¶Chains split_run, argument_run, dereference_run and program_run.
checkargs
(lineno, command, args)[source]¶Check if the arguments fit the requirements of the command.
Raises ArgumentError, if an argument does not fit.
dereference_run
(arg_r)[source]¶Converts the commands to opcodes and inserts the (relative or static) references.
py_register_machine2.tools.assembler.directives.
BaseDirective
(name)[source]¶Every Directive has to provide the following Attributes/Methods:
name
(like .set
)get_words(line)
: return the data to storeget_word_count(line)
: return the number of words to storeisstatic()
returns True, if the reference should be staticpy_register_machine2.tools.assembler.directives.
ConvertingDirective
(name, function)[source]¶The function function
will have to take the rest of the line (as a list)
and convert it to an iterable of int
objects
Example: The .string
directive:
# usage: .string name string
# ie.: .string foo this is a test
def string_function(line):
line = " ".join(line)
res = []
for char in line:
res.append(ord(char))
return res