示例#1
0
def link_asmfiles(asmfiles):
    """ Given a list of assembly files, assembles and links them
        and returns the executable image.
    """
    # assemble all the .lasm files
    asm = Assembler()
    objs = [asm.assemble(filename=f) for f in asmfiles]
    
    # link into a binary image
    link = Linker(USER_MEMORY_START, USER_MEMORY_SIZE)
    img = link.link(objs)

    return img
示例#2
0
from lib.simlib.interactive_cli import interactive_cli_sim

if __name__ == '__main__':
    from lib.asmlib.assembler import Assembler
    from lib.asmlib.linker import Linker
    from lib.commonlib.luz_defs import (USER_MEMORY_START, USER_MEMORY_SIZE)

    code = r'''
        .segment code
        .global asm_main
    asm_main:
        addi $r5, $zero, 0x45
        halt
    '''

    asm = Assembler()
    objs = [asm.assemble(code)]
    link = Linker(USER_MEMORY_START, USER_MEMORY_SIZE)
    img = link.link(objs)

    interactive_cli_sim(img)
示例#3
0
from lib.simlib.interactive_cli import interactive_cli_sim


if __name__ == '__main__':
    from lib.asmlib.assembler import Assembler
    from lib.asmlib.linker import Linker
    from lib.commonlib.luz_defs import (
        USER_MEMORY_START, USER_MEMORY_SIZE)
    
    code = r'''
        .segment code
        .global asm_main
    asm_main:
        addi $r5, $zero, 0x45
        halt
    '''
    
    asm = Assembler()
    objs = [asm.assemble(code)]
    link = Linker(USER_MEMORY_START, USER_MEMORY_SIZE)
    img = link.link(objs)
    
    interactive_cli_sim(img)