title: la Instruction Returning Weird Memory Addresses on .asciz Symbols (gas / ld / RISCV / Devterm R-01)
body: <p>I'm trying to learn RISC-V assembly using gas and ld.  I'm running my code natively on a Devterm R-1.  My issue is that the la pseudoinstruction does not seem to always give me a usable memory address when I use .asciz.  Here is what I have:</p>
  <p><strong>Filename m.asm</strong></p>
  <pre><code>     .global start
  
       .text
  _start:
       la     a1,     w1
       la     a2,     w2
       la     a3,     w3
       la     a4,     w4
       la     a5,     w5
  
       nop
  
       addi     a0,     x0,     0
       addi     a7,     x0,     93
       ecall
  
       .data
  w1:  .asciz &quot;Odd&quot;
  w2:  .asciz &quot;Even&quot;
  w3:  .asciz &quot;NineChars&quot;
  w4:  .asciz &quot;\n&quot;
  w5:  .asciz &quot;I&quot;
  </code></pre>
  <p>I built an executable with these commands:</p>
  <pre><code>as m.asm -g -o m.o
  ld m.o -o m
  </code></pre>
  <p>And tested with:</p>
  <pre><code>gdb m
  </code></pre>
  <p>I stepped down to the <code>nop</code> instruction and used p to print the memory addresses stored at each register:</p>
  <pre><code>a1 = 69912
  a2 = 69916
  a3 = 69921
  a4 = 183252031331
  a5 = 183252031333
  </code></pre>
  <p>The first three look reasonable and do indeed contain data if I use <code>x/c</code> to view the contents as characters.  However, trying to do the same to <code>a4</code> or <code>a5</code> gives me a <code>cannot access memory at address...</code> error.</p>
  <p><strong>System details:</strong>
  OS is:
  &quot;Linux devterm-R01 5.4.61 #12 PREEMPT Wed Mar 30 14:44:22 CST 2022 riscv64 riscv64 riscv64 GNU/Linux&quot;</p>
  <p>gas is version is 2.39
  ld is version 2.39
  gdb is version 12.1</p>
  <p><strong>Ask:</strong>
  Can someone educate me into what is happening with the memory addresses returned by la on these .asciz strings?  As they are they are unusable.</p>