summaryrefslogtreecommitdiff
path: root/riscv/location_counter.s
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/location_counter.s')
-rw-r--r--riscv/location_counter.s18
1 files changed, 18 insertions, 0 deletions
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