This project showcases a custom implementation of the memset function written in RISC-V assembly, integrated with a C program. The memset function is designed to fill a block of memory with a specified value, demonstrating low-level memory manipulation and efficient assembly programming.
main.c: Contains the main C program that declares and calls the custommemsetfunction.memset.s: Implements thememsetfunction in RISC-V assembly, optimized for memory alignment and performance.README.md: This file, providing a comprehensive overview, instructions, and insights into the project.
The program performs the following tasks:
- Declares a 32-byte character buffer in the C code.
- Calls the custom
memsetfunction to fill the buffer with the character'A'. - Prints the contents of the buffer to verify correct operation.
Before running this project, ensure the following tools and environment are available:
- A RISC-V toolchain (e.g.,
riscv64-unknown-elf-gcc). - A RISC-V emulator (e.g., QEMU) or access to a physical RISC-V hardware platform.
- Save the C code in a file named
main.cand the assembly code in a file namedmemset.s. - Compile and link the files using the RISC-V compiler:
riscv64-unknown-elf-gcc -o memset_program main.c memset.s - Run the program:
Using QEMU:
qemu-riscv64 ./memset_programOn RISC-V hardware:./memset_program
The program will print 32 'A' characters in a single line:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA