You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After successfully getting "print 42 to the console" working, I'm trying to write hello world, and am getting assembler errors. Here's my code, adapted from gcc -s:
.data
Hello:
.string "hello, world!"
.text
.align 1
.globl main
__start:
lui a1, %hi(Hello) <- here the error says "got 3 arguments but expected 2)
addi a1, a1, %lo(Hello) <- here it says got 4 expected 3
addi a0, x0, 4 # print_string
ecall
addi a1, x0, 0
addi a0, x0, 17 # exit2
ecall
I've looked at the ISA (no mention of the %hi/lo directives), and other locations - this seems to be an underdocumented aspect of RISC-V, but the current use of it is taken from how risc-v-gcc does it. What am I doing wrong, or is this a bug?
The text was updated successfully, but these errors were encountered:
dylanmc
changed the title
lui & %hi not working
%hi & %lo not working
Sep 11, 2019
I've looked at the ISA (no mention of the %hi/lo directives), and other locations - this seems to be an underdocumented aspect of RISC-V, but the current use of it is taken from how risc-v-gcc does it.
%hi and %lo are builtin functions of the the GCC assembler; there is no need for an assembler for risc-v to implement those functions and be compliant.
What am I doing wrong, or is this a bug?
Neither, there are certainly several assemblers which will assembler your code, but venus doesn't support it.
If you want your code to be accepted by all assemblers you should write it with the pseudo-instruction la. In most cases handwritten code doesn't benefit from using %hi and %lo over standard pseudo-instructions.
After successfully getting "print 42 to the console" working, I'm trying to write hello world, and am getting assembler errors. Here's my code, adapted from gcc -s:
I've looked at the ISA (no mention of the %hi/lo directives), and other locations - this seems to be an underdocumented aspect of RISC-V, but the current use of it is taken from how risc-v-gcc does it. What am I doing wrong, or is this a bug?
The text was updated successfully, but these errors were encountered: