(no commit message)
authorlkcl <lkcl@web>
Mon, 24 Jun 2019 06:00:55 +0000 (07:00 +0100)
committerIkiWiki <ikiwiki.info>
Mon, 24 Jun 2019 06:00:55 +0000 (07:00 +0100)
simple_v_extension/specification.mdwn

index e71414f4a40454282e102f0b15f1c359cbd20e61..26ee6c01059480d165ec5791e0c643ee794bea0e 100644 (file)
@@ -2533,38 +2533,38 @@ Could the 8 bit Register VLIW format use regnum<<1 instead, only accessing regs
 TODO evaluate strncpy and strlen
 https://groups.google.com/forum/m/#!msg/comp.arch/bGBeaNjAKvc/_vbqyxTUAQAJ
 
-strncpy: 
-    mv a3, a0               # Copy dst 
+    strncpy: 
+        mv a3, a0               # Copy dst 
+    loop: 
+        setvli x0, a2, vint8    # Vectors of bytes. 
+        vlbff.v v1, (a1)        # Get src bytes 
+        vseq.vi v0, v1, 0       # Flag zero bytes 
+        vmfirst a4, v0          # Zero found? 
+        vmsif.v v0, v0          # Set mask up to and including zero byte. 
+        vsb.v v1, (a3), v0.t    # Write out bytes 
+        bgez a4, exit           # Done 
+        csrr t1, vl             # Get number of bytes fetched 
+        add a1, a1, t1          # Bump src pointer 
+        sub a2, a2, t1          # Decrement count. 
+        add a3, a3, t1          # Bump dst pointer 
+        bnez a2, loop           # Anymore? 
+
+    exit: 
+        ret 
+
+
+
+        mv a3, a0             # Save start 
 loop: 
-    setvli x0, a2, vint8    # Vectors of bytes. 
-    vlbff.v v1, (a1)        # Get src bytes 
-    vseq.vi v0, v1, 0       # Flag zero bytes 
-    vmfirst a4, v0          # Zero found? 
-    vmsif.v v0, v0          # Set mask up to and including zero byte. 
-    vsb.v v1, (a3), v0.t    # Write out bytes 
-    bgez a4, exit           # Done 
-    csrr t1, vl             # Get number of bytes fetched 
-    add a1, a1, t1          # Bump src pointer 
-    sub a2, a2, t1          # Decrement count. 
-    add a3, a3, t1          # Bump dst pointer 
-    bnez a2, loop           # Anymore? 
-
-exit: 
-    ret 
-
-
-
-    mv a3, a0             # Save start 
-loop: 
-    setvli a1, x0, vint8  # byte vec, x0 (Zero reg) => use max hardware len 
-    vldbff.v v1, (a3)     # Get bytes 
-    csrr a1, vl           # Get bytes actually read e.g. if fault 
-    vseq.vi v0, v1, 0     # Set v0[i] where v1[i] = 0 
-    add a3, a3, a1        # Bump pointer 
-    vmfirst a2, v0        # Find first set bit in mask, returns -1 if none 
-    bltz a2, loop         # Not found? 
-
-    add a0, a0, a1        # Sum start + bump 
-    add a3, a3, a2        # Add index of zero byte 
-    sub a0, a3, a0        # Subtract start address+bump 
-    ret 
+        setvli a1, x0, vint8  # byte vec, x0 (Zero reg) => use max hardware len 
+        vldbff.v v1, (a3)     # Get bytes 
+        csrr a1, vl           # Get bytes actually read e.g. if fault 
+        vseq.vi v0, v1, 0     # Set v0[i] where v1[i] = 0 
+        add a3, a3, a1        # Bump pointer 
+        vmfirst a2, v0        # Find first set bit in mask, returns -1 if none 
+        bltz a2, loop         # Not found? 
+
+        add a0, a0, a1        # Sum start + bump 
+        add a3, a3, a2        # Add index of zero byte 
+        sub a0, a3, a0        # Subtract start address+bump 
+        ret