riscemu.assembler module
- riscemu.assembler.INSTRUCTION_SECTION_NAMES = ('.text', '.init', '.fini')
A tuple containing all section names which contain executable code (instead of data)
The first segment of each segment (first segment of “.text.main” is “.text”) is checked against this list to determine the type of it.
- class riscemu.assembler.MemorySectionType(value)
Bases:
Enum
An enumeration.
- Data = 1
- Instructions = 2
- class riscemu.assembler.CurrentSection(name: str, type: MemorySectionType, base: int = 0)
Bases:
object
- __init__(name: str, type: MemorySectionType, base: int = 0)
- name: str
- type: MemorySectionType
- base: int
- data: Union[List[Instruction], bytearray]
- current_address() int
- class riscemu.assembler.ParseContext(name: str)
Bases:
object
- __init__(name: str)
- context: InstructionContext
- section: Optional[CurrentSection]
- new_section(name: str, type: MemorySectionType, alignment: int = 4)
- add_label(name: str, value: int, is_global: bool = False, is_relative: bool = False)
- current_address()
- riscemu.assembler.ASSERT_IN_SECTION_TYPE(context: ParseContext, type: MemorySectionType)
- class riscemu.assembler.AssemblerDirectives
Bases:
object
This class represents a collection of all assembler directives as documented by https://github.com/riscv-non-isa/riscv-asm-manual/blob/master/riscv-asm.md#pseudo-ops
All class methods prefixed with op_ are directly used as assembler directives.
- classmethod op_align(token: Token, args: Tuple[str], context: ParseContext)
- classmethod op_section(token: Token, args: Tuple[str], context: ParseContext)
- classmethod op_globl(token: Token, args: Tuple[str], context: ParseContext)
- classmethod op_global(token: Token, args: Tuple[str], context: ParseContext)
- classmethod op_equ(token: Token, args: Tuple[str], context: ParseContext)
- classmethod op_space(token: Token, args: Tuple[str], context: ParseContext)
- classmethod op_zero(token: Token, args: Tuple[str], context: ParseContext)
- classmethod add_bytes(size: int, content: Union[None, int, bytearray], context: ParseContext)
- classmethod add_text(text: str, context: ParseContext, zero_terminate: bool = True)
- classmethod handle_instruction(token: Token, args: Tuple[str], context: ParseContext)