You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: extensions/memcpy/README.md
+11-14Lines changed: 11 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,28 +11,20 @@ memcpy_loop shift
11
11
12
12
Where `shift` is an immediate value (0, 1, 2, or 3) representing the byte alignment shift.
13
13
14
-
### RISC-V Encoding
15
-
-**Opcode**: `0x73` (custom opcode)
16
-
-**Funct3**: `0x0` (custom funct3)
17
-
-**Immediate**: 12-bit signed immediate for shift value
18
-
-**Format**: I-type instruction
19
14
20
15
### Usage
21
16
The `memcpy_loop` instruction is designed to replace repetitive shift-handling code in memcpy implementations. Instead of having separate code blocks for each shift value, you can use a single instruction:
22
17
23
18
```assembly
24
-
# Instead of this repetitive code:
25
-
.Lshift_1:
26
-
lw a5, 0(a4)
27
-
sb a5, 0(a3)
28
-
srli a1, a5, 8
29
-
sb a1, 1(a3)
30
-
# ... more shift handling code
31
-
32
-
# You can use:
33
19
memcpy_loop 1 # Handles shift=1 case
34
20
```
35
21
22
+
Note that you must define `memcpy_loop` before using it. For example, in [memcpy.s](../../crates/toolchain/openvm/src/memcpy.s) it is defined at the beginning of the assembly code as follows:
23
+
```assembly
24
+
.macro memcpy_loop shift
25
+
.word 0x00000072 | (\shift << 12) # opcode 0x72 + shift in immediate field (bits 12-31)
0 commit comments