aboutsummaryrefslogtreecommitdiffstats
path: root/test.py
blob: 9934f7a86267d7941034b2f23983eeead3c9295a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3
from riscv import format_u, format_i, format_s, format_j
from subx import format_instr

if __name__ == "__main__":
    t0 = 0x5
    t1 = 0x6
    print("== code 0x80000000")
    print(format_instr(format_u(0x37, t0, 0x10010), "lui t0, 0x10010"))
    print(format_instr(format_i(0x13, t1, 0, 72, 0x0), "addi t1, x0, 72"))
    print(format_instr(format_s(0x23, t0, t1, 0, 0x2), "sw t1, 0(t0)"))
    print(format_instr(format_i(0x13, t1, 0, 101, 0x0), "addi t1, x0, 101"))
    print(format_instr(format_s(0x23, t0, t1, 0, 0x2), "sw t1, 0(t0)"))
    print(format_instr(format_i(0x13, t1, 0, 108, 0x0), "addi t1, x0, 108"))
    print(format_instr(format_s(0x23, t0, t1, 0, 0x2), "sw t1, 0(t0)"))
    print(format_instr(format_i(0x13, t1, 0, 108, 0x0), "addi t1, x0, 108"))
    print(format_instr(format_s(0x23, t0, t1, 0, 0x2), "sw t1, 0(t0)"))
    print(format_instr(format_i(0x13, t1, 0, 111, 0x0), "addi t1, x0, 111"))
    print(format_instr(format_s(0x23, t0, t1, 0, 0x2), "sw t1, 0(t0)"))
    print(format_instr(format_i(0x13, t1, 0, 10, 0x0), "addi t1, x0, 10"))
    print(format_instr(format_s(0x23, t0, t1, 0, 0x2), "sw t1, 0(t0)"))
    print(format_instr(format_j(0x6f, 0, -26), "jal x0, -26"))