aboutsummaryrefslogtreecommitdiffstats
path: root/ex.subv
blob: 16e9baf3dc074f04f1a821177e76d75265d198ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
== code 0x80000000
# repeatedly print "Hi\n"
main:
  # load 0x10010000 (UART0) into t0
  37/lui 5/rd/t0 0x10010/imm20
  # store 0x48 (H) in UART0+0
  13/opi 0/subop/add 6/rd/t1 0/rs/x0 48/imm12
  23/store 2/width/word 5/rs/t0 6/rs/t1 0/off12
  # store 0x69 (i) in UART0+0
  13/opi 0/subop/add 6/rd/t1 0/rs/x0 69/imm12
  23/store 2/width/word 5/rs/t0 6/rs/t1 0/off12
  # store 0x0a (\n) in UART0+0
  13/opi 0/subop/add 6/rd/t1 0/rs/x0 0a/imm12
  23/store 2/width/word 5/rs/t0 6/rs/t1 0/off12
  # jump back up to the top (three versions):
  # a) jal 21bit relative (with 0th bit forced to 0)
  #   6f/jal 0/rd/x0 main/off21
  # b) auipc+jalr 32bit relative (note label offset)
     17/auipc 7/rd/t2 main/off20hi
     67/jalr 0/subop 0/rd/x0 7/rs/t2 main+4/off12lo
  # c) lui+jalr 32bit absolute
  #   37/lui 7/rd/t2 main/imm32
  #   67/jalr 0/subop 0/rd/x0 7/rs/t2 main/imm32