typo
[libreriscv.git] / simple_v_extension / daxpy_example.mdwn
1 # a0 is n, a1 is ptr to x[0], a2 is ptr to y[0], fa0 is a
2 VBLK.REG[0] = {type: F, regkey: a3, regidx: a3, elwidth: dflt}
3 VBLK.REG[1] = {type: F, regkey: a7, regidx: a7, elwidth: dflt}
4 VBLK.MVL = 4
5 loop:
6 setvl t0, a0 # vl = t0 = min(a0, MVL))
7 ld a3, a1 # load 4 registers a3-6 from x
8 slli t1, t0, 3 # t1 = vl * 8 (in bytes)
9 ld a7, a2 # load 4 registers a7-10 from y
10 add a1, a1, t1 # increment pointer to x by vl*8
11 fmadd a7, a3, fa0, a7 # v1 += v0 * fa0 (y = a * x + y)
12 sub a0, a0, t0 # n -= vl (t0)
13 st a7, a2 # store 4 registers a7-10 to y
14 add a2, a2, t1 # increment pointer to y by vl*8
15 bnez a0, loop # repeat if n != 0