0
votes

I need help with understanding how to solve this problem in RISCV. Provide the assembly language instruction for the following hex values:
Address 1000: b3 Address 1001: 0b Address 1002: 9c Address 1003: 41

I know I have to change to binary and that RISCV is little Endian, but beyond that I dont know how to proceed. I have several problems like this but I want to do the rest myself.

1
Welcome to StackOverflow! It's not clear for me: are you trying to disassemble binary code by hand?Alex Yu

1 Answers

4
votes

As you said, RISC-V is little-endian, so the word at address 1000 through 1003 is 0x419c0bb3, in binary:

01000001100111000000101110110011

First thing to notice, the instruction ends in 0110011. This matches several instructions, see pages 104 and 105 in riscv-spec-v2.2.pdf. To further decode the instruction I examine the FUNC3 field in bits 14-12, these are 000. I am down to a few possible instructions, ADD, SUB or MUL. I now examine the most significant 7 bits of the instruction, 0100000. The instruction is SUB. The full decoding of the instruction is:

FUNC7   rs2   rs1   FUNC3 rd    OPCODE
0100000 11001 11000 000   10111 0110011

In assembler this should be sub x23,x24,x25. To check the answer it is best to use an assembler/emulator.