hal.fs can't have comments and can't use asm/riscv, which means that there are
numerical opcode literals around. Those opcodes are documented here.

HAL opcode structure (close to RISC-V structure)
b0     +)
b1     m)
b2     8b) => 8-bit if set
b3     <>)
b4     &)
b5     i)
b6     16b) => 32-bit if set, 16-bit if unset
b11:7  rd
b14:12 Zeroes (funct 3)
b19:15 rs1
b24:20 rs2
b26:25 Zeroes
b31:27 hbank index

Register assignment:
x2=RSP x3=PSP x4=W x5=A x6=S x7=SYSVARS x28=Acmp x29=Bcmp
Scratch registers to use
x10-x20
Forbidden of use registers
x30-31

CAUTIOUS:
x10 used as holding register for lblimmwr (when we are using immediates they are
hold in x10)
x11 used as holding register for source value (when we are fetching the source
we hold its value in the x11 register)

Z) NZ) <) >=) etc..
  b2:0 correspond to funct3, but b3 is special and handled by "brc," before
  orring the condition in. This bit indicates that we should swap rs1 and rs2.

rs1! ( instr r -- instr )
rs2! ( instr r -- instr )
funct3! ( instr n -- instr )
  Set the specified fields in "instr".

Bimm! ( instr n -- instr )
  Encode n immediate so that it corresponds to the B-type encoding.
  Because it's supposed to encode a multiple of 2, "n" is divided by 2 before
  being encoded.

dropf, ( -- )
  0001a203 lw) xTOS rd) xPSP base)
  00418193 addi) xPSP rd) xPSP rs1) 4 imm)

dropcmp, ( -- )
  Move W to xAcmp for brz, and brnz, then drop W.

  00020e13 mv) xAcmp rd) xTOS rs1)

brci, ( a cond -- )
  Jump to absolute "a" if "cond" is met. Cannot be used with the "inverted"
  conditions (greater than 7).

mvreg, ( rd rs1 -- )
  Write a "mv)".

zop, ( instr -- )
  Write "instr" followed by a mv) of its "rd" field to xAcmp, and 0 to xBcmp
  thus "setting" the Z flag.

shift, ( op instr -- )
  Write shift instruction with base opcode "instr" with HAL operand "op".

## Range words

pre,
  00030e63 beq) xS rs1) xZERO rs2) 28 imm)

post,
  fff30313 subi) xS rd) xS rs1) 1 imm)
  fe0316e3 bne) xS rs1) xZERO rs2) -20 imm)

move,
  00022983 lw) x19 rd) xTOS base)
  0132a023 sw) x19 src) xA base)
  00420213 addi) xTOS rd) xTOS rs1) 4 imm)
  00428293 addi) xA rd) xA rs1) 4 imm)

wmove,
  00025983 lhu) x19 rd) xTOS base)
  01329023 sh) x19 src) xA base)
  00220213 addi) xTOS rd) xTOS rs1) 2 imm)
  00228293 addi) xA rd) xA rs1) 2 imm)

cmove,
  00024983 lbu) x19 rd) xTOS base)
  01328023 sb) x19 src) xA base)
  00120213 addi) xTOS rd) xTOS rs1) 1 imm)
  00128293 addi) xA rd) xA rs1) 1 imm)

pre,
  00000e13 xAcmp 0 li,
  00000e93 xBcmp 0 li,
  02030063 beq) xS rs1) xZERO rs2) 32 imm)

post,
  fff30313 subi) xS rd) xS rs1) 1 imm)
  01de1463 bne) xAcmp rs1) xBcmp rs2) 8 imm)
  fe0314e3 bne) xS rs1) xZERO rs2) -24 imm)

[]=,
  00022e03 lw) xAcmp rd) xTOS base)
  0002ae83 lw) xBcmp rd) xA base)
  00420213 addi) xTOS rd) xTOS rs1) 4 imm)
  00428293 addi) xA rd) xA rs1) 4 imm)

w[]=,
  00025e03 lhu) xAcmp rd) xTOS base)
  0002de83 lhu) xBcmp rd) xA base)
  00220213 addi) xTOS rd) xTOS rs1) 2 imm)
  00228293 addi) xA rd) xA rs1) 2 imm)

c[]=,
  00024e03 lbu) xAcmp rd) xTOS base)
  0002ce83 lbu) xBcmp rd) xA base)
  00120213 addi) xTOS rd) xTOS rs1) 1 imm)
  00128293 addi) xA rd) xA rs1) 1 imm)

pre,
  00020e13 mv) xAcmp rd) xTOS rs1)
  001e0e93 addi) xBcmp rd) xAcmp rs1) 1 imm)
  02030063 beq) xS rs1) xZERO rs2) 32 imm)
  00030993 mv) x19 rd) xS rs1)

post,
  01de0663 beq) xAcmp rs1) xBcmp rs2) 12 imm)
  fff98993 subi) x19 rd) x19 rs1) 1 imm)
  fe0998e3 bne) x19 rs1) xZERO rs2) -16 imm)
  41330333 sub) xS rd) xS rs1) x19 rs2)

idx,
  0002ae83 lw) xBcmp rd) xA base)
  00428293 addi) xA rd) xA rs1) 4 imm)

widx,
  0002de83 lhu) xBcmp rd) xA base)
  00228293 addi) xA rd) xA rs1) 2 imm)

cidx,
  0002ce83 lbu) xBcmp rd) xA base)
  00128293 addi) xA rd) xA rs1) 1 imm)

post,
  fff30313 subi) xS rd) xS rs1) 1 imm)
  fe031ae3 bne) xS rs1) xZERO rs2) -12 imm)

fill,
  0042a023 sw) xTOS src) xA base)
  00428293 addi) xA rd) xA rs1) 4 imm)

wfill,
  00429023 sh) xTOS src) xA base)
  00228293 addi) xA rd) xA rs1) 2 imm)

cfill,
  00428023 sb) xTOS src) xA base)
  00128293 addi) xA rd) xA rs1) 1 imm)
