Does GCC generate wrong assembly code for the "beq" instruction of riscv?

Viewed 55

I have a riscv assembly code in beq.s

beq x0, x0, 42

And I compile it with

riscv64-unknown-elf-gcc -Wl,-Ttext=0x0 -nostdlib -march=rv64i -mabi=lp64 -o beq beq.s

Then I generate the raw riscv binary by

riscv64-unknown-elf-objcopy -O binary beq beq.bin

I use hexdump -C beq.bin to generate its hex code:

63 14 00 00 6f 00 00 00

Then I use riscv64-unknown-elf-objdump to disasm it. I got

bnez    zero,0x8
j       0x4

I think the bnez is wrong. It should be something like beqz.

May I do something wrong?

System: WSL ubuntu 20.04 gcc verison: 9.3.0

0 Answers
Related