Esempio n. 1
0
    program.append(Inst.ADDI(pattern_tmp, 0, seg_pattern[i]))
    program.append(Inst.SB(pattern_mem, pattern_tmp, i))

seg = 6
counter = 7
pattern_mem_addr = 8
pattern = 9
max = 15

program_main = [
    'main',
    Inst.LUI(seg, 0x04000000),
    Inst.ADDI(counter, x_0, 0),
    Inst.ADDI(max, x_0, 9), 'loop',
    Inst.ADD(pattern_mem_addr, counter, pattern_mem),
    Inst.LBU(pattern, pattern_mem_addr, 0),
    Inst.SB(seg, pattern, 0),
    Inst.ADDI(counter, counter, 1),
    Inst.LBEQ(counter, max, 'reset'),
    Inst.LJAL(x_0, 'loop'), 'reset',
    Inst.ADDI(20, x_0, 0xFC),
    Inst.SB(seg, 20, 0),
    Inst.LJAL(x_0, 'main')
]

program.extend(program_main)

r = asm(program)
print_asm(r)
print()
print_ihex(r)
Esempio n. 2
0
from inst import Inst, asm, print_asm, print_ihex

program = [
Inst.LUI(5, 0x10000000), # memory = 0x10000000
Inst.ADD(6, 0, 0), # x6 = 0 (counter)
'loop',
Inst.SW(5, 6, 0x100), # memory[x5+0x100] = x6
Inst.ADDI(6, 6, 1), # x6++
Inst.LJAL(0, 'loop') # goto loop
]

r = asm(program)
print_asm(r)
print()
print_ihex(r)
Esempio n. 3
0
]

for i in range(10):
    program.append(Inst.ADDI(rd[6],rs[0],seg_pattern[i]))
    program.append(Inst.SB(rd[5],rs[6],i))

program_main = [    
    Inst.LUI(rd[6], 0x04000000),
    Inst.ADD(rd[7],rs[0],rs[0]), 
    Inst.LW(rd[10], rs[6], 0x48),
    'mainloop',
    Inst.ADD(rd[8],rs[7],rs[5]),
    Inst.ANDI(rd[11],rs[10],0x01),
    Inst.LBEQ(rd[11],0,'dontpush'),

    'push',
    Inst.LBU(rd[9],rs[8],0),
    Inst.SB(rd[6],rs[9],0x000),
    Inst.ADDI(rd[7],rs[7],1),
    Inst.LJAL(0,'mainloop'),
    'dontpush',
    Inst.SB(rd[6],rs[9],0x000),
    Inst.LJAL(0,'mainloop')
]

program.extend(program_main)

r = asm(program)
print_asm(r)
print()
print_ihex(r)