radu242753435752 has quit [Ping timeout: 260 seconds]
JanC has quit [Remote host closed the connection]
JanC has joined #riscv
JanC has quit [Excess Flood]
JanC has joined #riscv
SpaceCoaster has quit [Ping timeout: 240 seconds]
SpaceCoaster has joined #riscv
JanC_ has joined #riscv
JanC is now known as Guest7282
JanC_ is now known as JanC
Guest7282 has quit [Ping timeout: 250 seconds]
JanC has quit [Excess Flood]
JanC has joined #riscv
JanC has quit [Excess Flood]
JanC has joined #riscv
JanC has quit [Excess Flood]
JanC has joined #riscv
JanC has quit [Excess Flood]
JanC has joined #riscv
mechaniputer has joined #riscv
JanC has quit [Read error: Connection reset by peer]
JanC has joined #riscv
pecastro has joined #riscv
JanC_ has joined #riscv
JanC is now known as Guest3457
Guest3457 has quit [Killed (calcium.libera.chat (Nickname regained by services))]
JanC_ is now known as JanC
JanC_ has joined #riscv
JanC has quit [Read error: Connection reset by peer]
JanC_ is now known as JanC
SpaceCoaster has quit [Read error: Connection reset by peer]
JanC has quit [Excess Flood]
SpaceCoaster has joined #riscv
JanC has joined #riscv
Stat_headcrabed has quit [Quit: Stat_headcrabed]
JanC_ has joined #riscv
JanC has quit [Killed (molybdenum.libera.chat (Nickname regained by services))]
JanC_ is now known as JanC
PobodysNerfect has quit [Ping timeout: 240 seconds]
JanC_ has joined #riscv
JanC is now known as Guest4797
JanC_ is now known as JanC
Guest4797 has quit [Killed (silver.libera.chat (Nickname regained by services))]
JanC has quit [Excess Flood]
JanC has joined #riscv
JanC has quit [Ping timeout: 255 seconds]
JanC_ has joined #riscv
PobodysNerfect has joined #riscv
JanC_ is now known as JanC
SpaceCoaster has quit [Ping timeout: 260 seconds]
SpaceCoaster has joined #riscv
Tenkawa has joined #riscv
PobodysNerfect has quit [Quit: Gone to sleep. ZZZzzz…]
PobodysNerfect has joined #riscv
BootLayer has quit [Quit: Leaving]
cousteau has joined #riscv
Tenkawa has quit [Quit: Was I really ever here?]
hrberg has quit [Ping timeout: 240 seconds]
hrberg has joined #riscv
terminalpusher has joined #riscv
mechaniputer has quit [Quit: leaving]
terminalpusher has quit [Ping timeout: 245 seconds]
Andre_Z has joined #riscv
DynamiteDan has quit [Excess Flood]
DynamiteDan has joined #riscv
DynamiteDan has quit [Excess Flood]
DynamiteDan has joined #riscv
PobodysNerfect_ has joined #riscv
JanC has quit [Ping timeout: 255 seconds]
PobodysNerfect has quit [Ping timeout: 260 seconds]
JanC has joined #riscv
Andre_Z has quit [Quit: Leaving.]
solrize has quit [Ping timeout: 246 seconds]
PobodysNerfect has joined #riscv
PobodysNerfect_ has quit [Ping timeout: 260 seconds]
Tenkawa has joined #riscv
solrize has joined #riscv
solrize has joined #riscv
solrize has quit [Changing host]
Leopold has quit [Remote host closed the connection]
jay321 has quit [Quit: Leaving...]
PobodysNerfect has quit [Quit: Gone to sleep. ZZZzzz…]
solrize has quit [Ping timeout: 255 seconds]
Leopold has joined #riscv
vagrantc has joined #riscv
dobson has quit [Quit: Leaving]
Xav101 has joined #riscv
JanC has quit [Remote host closed the connection]
JanC has joined #riscv
<Xav101>
So I'm running into a bit of an odd issue with RISC-V assembly and I'm not sure what's going on. I'm using crosscompiled gas from the riscv-collab /
<Xav101>
riscv-gnu-toolchain repo and I'm trying to assemble the instruction "jal 16". According to the ISA manual this is a pseudoinstruction which should assemble to a "jal x1, 16". However when I actually assemble it and then objdump it I get machine code of "000000ef". This has the correct opcode for JAL (1101111) and a destination register of (00001) but the fields for the immediate are just zeroed out. Any idea what's going on?
<Xav101>
It just doesn't seem to be encoding the immediate for some reason.
dobson has joined #riscv
<Xav101>
Am I missing something obvious here
Tenkawa has quit [Quit: Was I really ever here?]
<dh`>
(a) are you assembling to an .o file or to a whole program?
<dh`>
and (b) how are you expecting the assembler to interpret that "16"?
<Xav101>
a - Just assembling to a .o file.
<Xav101>
b - I'd expect it to get interpreted as a signed decimal number and encoded into the J-type immediate field
<dh`>
ok, b first.
<dh`>
that's not how it works.
<dh`>
the target of a branch instruction is an assembler label
<Xav101>
Can you not just specify the constant?
<dh`>
no
<Xav101>
ah
<dh`>
not in ~any assembly language
<Xav101>
So as is probably just unable to find a label and so it emits a zero
<dh`>
second, the symbol doesn't get an address assigned until link time (if then) so there'll be a relocation entry in the .o file that you need to look at to get the full picture
<dh`>
no
<dh`>
16 likely means scratch label #16
<dh`>
I would expect it to fail if you don't define such a label, though
<Xav101>
ok
<dh`>
hmm, I'm not sure how it _is_ interpreting just '16'
<Xav101>
Numeric label maybe?
<Xav101>
for a local reference
<dh`>
might actually be treating it as an absolute address after all
<dh`>
but, don't do that :-|
<dh`>
if you want to call an absolute address for some reason, define an absolute symbol and call that
<dh`>
more robust, plus also you don't want to explore dusty and likely untested paths in the toolchain
<Xav101>
Ok, cool
<Xav101>
Wouldn't that actually emit multiple instructions depending on where it's located
<dh`>
I forget what the gas syntax for absolute symbols is, might be just foo = 16
<Xav101>
Because jal can only do a +/- 1MB range and anything more needs a jalr
<dh`>
if you do it right, nm on the output object file will show an absolute symbol with A
<dh`>
yes probably but you need that regardless
<dh`>
if you're trying to jump forward 16 bytes you need to put a label 16 bytes forward to jump to
<dh`>
(which is annoying to arrange, but it's also something you don't normally ever need to do)
<dh`>
I'm not sure what the output encoding I'm seeing in the .o file here means but it's pretty clearly not that
<Xav101>
What's the syntax for that? Is it something with %pcrel_high and $pcrel_lo
<Xav101>
*%pcrel_lo
<dh`>
no, something like jal 1f; nop; nop; nop; nop; 1:
<Xav101>
ah
<dh`>
%pcrel_lo will give you the low part of the pc-relative offset to the argument symbol