[otbn/sw] Specify CSR index in hex
Specify the CSR number in hexadecimal (instead of decimal) to make it
match the documentation and increase consistency within the code base.
No functional change.
Signed-off-by: Philipp Wagner <phw@lowrisc.org>
diff --git a/sw/otbn/code-snippets/p256.s b/sw/otbn/code-snippets/p256.s
index 0e75742..7cf9fdd 100644
--- a/sw/otbn/code-snippets/p256.s
+++ b/sw/otbn/code-snippets/p256.s
@@ -788,7 +788,7 @@
/* skip multiplication if C flag not set */
bn.sel w1, w1, w3, C
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, nomul
@@ -1328,7 +1328,7 @@
ebgcd_loop:
/* test if u is odd */
bn.or w4, w4, w4
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 4
bne x2, x0, ebgcd_u_odd
@@ -1338,7 +1338,7 @@
/* test if r is odd */
bn.or w2, w2, w2
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 4
bne x2, x0, ebgcd_r_odd
@@ -1357,7 +1357,7 @@
ebgcd_u_odd:
/* test if v is odd */
bn.or w5, w5, w5
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 4
bne x2, x0, ebgcd_uv_odd
@@ -1367,7 +1367,7 @@
/* test if s is odd */
bn.or w3, w3, w3
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 4
bne x2, x0, ebgcd_s_odd
@@ -1386,7 +1386,7 @@
ebgcd_uv_odd:
/* test if v >= u */
bn.cmp w5, w4
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, ebgcd_v_gte_u
@@ -1406,7 +1406,7 @@
bn.sub w5, w5, w4
/* if v > 0 go back to start of loop */
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 8
beq x2, x0, ebgcd_loop
@@ -1505,13 +1505,13 @@
/* goto 'fail' if w0 == w31 <=> s == 0 */
bn.cmp w0, w31
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 8
bne x2, x0, fail
/* goto 'fail' if w0 >= w29 <=> s >= n */
bn.cmp w0, w29
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, fail
@@ -1524,13 +1524,13 @@
/* goto 'fail' if w24 == w31 <=> r == 0 */
bn.cmp w24, w31
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 8
bne x2, x0, fail
/* goto 'fail' if w0 >= w29 <=> r >= n */
bn.cmp w24, w29
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, fail
@@ -1604,7 +1604,7 @@
/* if either u_1[i] == 0 or u_2[i] == 0 jump to 'no_both' */
bn.add w2, w2, w2
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, no_both
@@ -1621,7 +1621,7 @@
/* if u2[i] is not set jump to 'no_g' */
bn.add w6, w0, w0
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, no_g
@@ -1634,7 +1634,7 @@
no_g:
/* if u1[i] is not set jump to 'no_q' */
bn.add w6, w1, w1
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, no_q
diff --git a/sw/otbn/code-snippets/p384_sign.s b/sw/otbn/code-snippets/p384_sign.s
index 39ab7ae..2ccfa3e 100644
--- a/sw/otbn/code-snippets/p384_sign.s
+++ b/sw/otbn/code-snippets/p384_sign.s
@@ -884,7 +884,7 @@
bn.addc w3, w3, w3
/* skip multiplication if C flag not set */
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, nomul
diff --git a/sw/otbn/code-snippets/p384_verify.s b/sw/otbn/code-snippets/p384_verify.s
index 671edf0..6c7d2d6 100644
--- a/sw/otbn/code-snippets/p384_verify.s
+++ b/sw/otbn/code-snippets/p384_verify.s
@@ -187,7 +187,7 @@
ebgcd_loop:
/* test if u is odd */
bn.or w8, w8, w8
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 4
bne x2, x0, ebgcd_u_odd
@@ -198,7 +198,7 @@
/* test if r is odd */
bn.or w4, w4, w4
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 4
bne x2, x0, ebgcd_r_odd
@@ -219,7 +219,7 @@
ebgcd_u_odd:
/* test if v is odd */
bn.or w10, w10, w10
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 4
bne x2, x0, ebgcd_uv_odd
@@ -230,7 +230,7 @@
/* test if s is odd */
bn.or w6, w6, w6
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 4
bne x2, x0, ebgcd_s_odd
@@ -252,7 +252,7 @@
/* test if v >= u */
bn.cmp w10, w8
bn.cmpb w11, w9
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, ebgcd_v_gte_u
@@ -286,7 +286,7 @@
/* if v > 0 go back to start of loop */
bn.cmp w31, w10
bn.cmpb w31, w11
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
bne x2, x0, ebgcd_loop
@@ -438,14 +438,14 @@
/* goto 'fail' if [w30,w29] == [w31, w31] <=> s == 0 */
bn.cmp w31, w29
bn.cmpb w31, w30
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, fail
/* goto 'fail' if [w30,w29] >= [w12,w13] <=> s >= n */
bn.cmp w29, w12
bn.cmpb w30, w13
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, fail
@@ -481,14 +481,14 @@
/* goto 'fail' if [w11, w10] == [w31, w31] <=> r == 0 */
bn.cmp w31, w10
bn.cmpb w31, w11
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, fail
/* goto 'fail' if [w11,w10] >= [w12,w13] <=> r >= n */
bn.cmp w10, w12
bn.cmpb w11, w13
- csrrs x2, 1984, x0
+ csrrs x2, 0x7c0, x0
andi x2, x2, 1
beq x2, x0, fail
@@ -606,7 +606,7 @@
bn.addc w1, w1, w1
/* keep MSB/carry bit in x3: x3 <= u1[i] */
- csrrs x3, 1984, x0
+ csrrs x3, 0x7c0, x0
andi x3, x3, 1
/* left shift u2 = [w3,w2] <= [w3,w2] << 1 */
@@ -614,7 +614,7 @@
bn.addc w3, w3, w3
/* keep MSB/carry bit in x3: x4 <= u2[i] */
- csrrs x4, 1984, x0
+ csrrs x4, 0x7c0, x0
andi x4, x4, 1
li x2, 0