Exemplo n.º 1
0
Inst.ADDI(6, 0, 0b11011010), # 2
Inst.SB(5, 6, 0x2),
Inst.ADDI(6, 0, 0b11110010), # 3
Inst.SB(5, 6, 0x3),
Inst.ADDI(6, 0, 0b01100110), # 4
Inst.SB(5, 6, 0x4),
Inst.ADDI(6, 0, 0b10110110), # 5
Inst.SB(5, 6, 0x5),
Inst.ADDI(6, 0, 0b10111110), # 6
Inst.SB(5, 6, 0x6),
Inst.ADDI(6, 0, 0b11100000), # 7
Inst.SB(5, 6, 0x7),
Inst.ADDI(6, 0, 0b11111110), # 8
Inst.SB(5, 6, 0x8),
Inst.ADDI(6, 0, 0b11110110), # 9
Inst.SB(5, 6, 0x9),
# Main
Inst.LUI(6, 0x04000000),
Inst.ADD(7, 0, 0), # x7 = 0 (counter)
’loop’,
Inst.ADD(8, 7, 5), # address of memory[x7]
Inst.LBU(9, 8, 0), # x9 = memory[x7]
Inst.SB(6, 9, 0),
Inst.ADDI(7, 7, 1), # x7++
Inst.LJAL(0, ’loop’) # goto loop
]

r = asm(program)
print_asm(r)
print()
print_ihex(r)
Exemplo n.º 2
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)
Exemplo 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)