git.s-ol.nu subv / 14222e0
close to working AUIPC+JALR jump s-ol 28 days ago
3 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
Binary diff not shown
1111 # store 0x0a (\n) in UART0+0
1212 13/opi 0/subop/add 6/rd/t1 0/rs/x0 0a/imm12
1313 23/store 2/subop/word 5/rs/t0 6/rs/t1 0/off12
14 # jump back up to the top
15 6f/jal 0/rd/x0 main/off21
14 # jump back up to the top (three versions):
15 # a) jal 21bit relative (with 0th bit forced to 0)
16 # 6f/jal 0/rd/x0 main/off21
17 # b) auipc+jalr 32bit relative (note label offset)
18 17/auipc 7/rd/t2 main/off32
19 67/jalr 0/subop 0/rd/x0 7/rs/t2 main+4/off32
20 # c) lui+jalr 32bit absolute
21 # 37/lui 7/rd/t2 main/imm32
22 # 67/jalr 0/subop 0/rd/x0 7/rs/t2 main/imm32
134134 '13/7 06/5 0/3 00/5 label/imm12/[11:0]'
135135 """
136136 (op, sub, rd, rs, imm) = instr
137 op_tag = op[1]
137138 op = bits.u(subv.untag(op), 7)
138139 sub = bits.u(subv.untag(sub, 'subop'), 3)
139140 rd = bits.u(subv.untag(rd, 'rd'), 5)
140141 rs = bits.u(subv.untag(rs, 'rs'), 5)
141142 if subv.is_reference(imm):
142 imm = bits.ref(imm, slice(11, 0))
143 if op_tag == 'jalr':
144 imm = bits.ref(imm, slice(12, 1))
145 else:
146 imm = bits.ref(imm, slice(11, 0))
143147 else:
144148 imm = bits.i(subv.untag(imm, 'imm12'), 12)
145149