From 8c6fc0c15415b32080a848bbde640e104098cf13 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Thu, 10 Jul 2025 22:18:39 +0200 Subject: Initial drop Add some riscv code Signed-off-by: Carlos Maiolino --- riscv/location_counter.s | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 riscv/location_counter.s (limited to 'riscv/location_counter.s') diff --git a/riscv/location_counter.s b/riscv/location_counter.s new file mode 100644 index 0000000..de0fbfe --- /dev/null +++ b/riscv/location_counter.s @@ -0,0 +1,18 @@ +.globl _start + +.section .data +# x: .word 42 # Use a label to store the retval in the file's mem address space +.set retval, 88 # Use .set to create a symbol in the object/executable's symbol table + +.section .text + # with the return value +_start: +# la t1, x # If we have the value stored in the .data section, we need to + # use 'la' to retrieve the address and +# lw a0, (t1) # 'lw' to load it into the register + + li a0, retval # We have retval defined in the file's symbol table (use nm or readelf) + # to display the symbol table. + + li a7, 93 + ecall -- cgit v1.2.3