Learn with SHAKTI
My First C program
Open a file in text editor, Lets say hello.c is the C file.
Write a simple C program to print Hello world (Copy paste the below content in it and save the file.)
Before starting compilation, Please check if the shakti-tools are installed.
riscv64-unknown-elf-gcc hello.c -o hello.elf
On successful compilation, a executable binary named hello.elf will be generated.
The executable is ready. Now execute the program using spike and pk. spike is the hardware simulator that simulates RISC-V. pk is the proxy kernel, which provides drivers to use the peripherals.
spike $(which pk) hello.elf
Object dump for the compiled C Program
objdump displays the assembly code contained in an elf file.
riscv64-unknown-elf-objdump -d hello.elf &> hello.dump
Use vim or gedit to view the objdump file created i.e hello.dump