Git Product home page Git Product logo

riscvv-test's Introduction

This repository contains RISC-V assembly examples.

RISC-V Vector Assembly Code Examples

These example use RISC-V "V" vector instructions (version 0.8).

  • bcd2ascii.s - convert BCD strings into ASCII strings. See also https://gms.tf/riscv-vector.html for details.
  • ascii2bcd.s - convert ASCII strings into BCD strings.
  • memchr.s - vector version of the well-known memchr() libc function
  • mempchr.s - similar to memchr(), but mempchr() returns the one-past-the-end pointer instead of NULL. This is more useful e.g. in text scanning code.
  • memrchr.s - vector version of the well-known memrchr() libc function
  • memcmp.s - vector version of the well-known memcmp() libc function
  • rawmemchr.s - vector version of the well-known rawmemchr() glibc function
  • strlen.s, strlen_small.s - vector versions of the well-known strlen() libc function

See Also

The RISC-V "V" extension specification contains several vector assembly code example, e.g. vector versions of memcpy(), strcpy(), strncpy() and strlen().

Other Examples

  • rotate.s - the general purpose RISC-V instruction sets don't include rotate instructions, instead they are part of the Bitmanip "B" extension. This example shows how to bit-rotate without the "B" extension.

Comparison with x86 SIMD

To stress the point that a length agnostic vector instruction set allows to write very compact (and arguably elegant) code (cf. https://gms.tf/riscv-vector.html), this repository also contains an x86 SIMD version of bcd2ascii.s: x86_64/bcd2ascii.S It requires many more instructions because of extra code that deals with input that isn't dividable by the SIMD register size.

It also demonstrates how many x86 SIMD instructions encode into 4 or more bytes due to the bloated x86 opcode space:

$ objdump -M intel -d bcd2ascii.o | grep '^.*\<v[^ ]*' -o \
     | awk '{ print NF-2, $NF }'

(whereas RISC-V vector instructions uniformly encode into 4 bytes)

2020, Georg Sauthoff [email protected]

riscvv-test's People

Contributors

gsauthof avatar

Forkers

enthusi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.