User Tools

Site Tools


riscv

This is an old revision of the document!


Riscv - how to use prinf from assembler

The following link explains how to setup and run RiscV Debian in qemu:-

https://www.codeproject.com/Tips/5383029/Run-Debian-RISC-V-In-QEMU-Virtual-Environment-For

All work has been carried out in the resulting operating system.

assemble with: as test2.s -o test2.o

then compile with: gcc test2.o -o test2

run with: ./test

test2.s
.section .rodata
prompt: .asciz "Value of t0 = %ld and value of t1 = %ld\n"
.globl main
.section .text
main:
    addi    sp, sp, -8
    sd      ra, 0(sp)
    la      a0, prompt
    li      t0,44
    li      t1,88
    mv      a1, t0
    mv      a2, t1
    call    printf
    ld      ra, 0(sp)
    addi    sp, sp, 8
    ret
riscv.1738509906.txt.gz · Last modified: 2025/02/02 15:25 by admin