100% found this document useful (1 vote)
100 views1 page

RISC-V Assembly Code Assignment

The document provides a series of assignments focused on RISC-V assembly code, including tasks for addition, subtraction, and complex expressions. It also requires the translation of various assembly instructions into machine language across different instruction types (I-type, S-type, B-type, U-type, and J-type). The assignments aim to reinforce understanding of RISC-V assembly programming and machine language translation.

Uploaded by

rosiesandra086
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
100 views1 page

RISC-V Assembly Code Assignment

The document provides a series of assignments focused on RISC-V assembly code, including tasks for addition, subtraction, and complex expressions. It also requires the translation of various assembly instructions into machine language across different instruction types (I-type, S-type, B-type, U-type, and J-type). The assignments aim to reinforce understanding of RISC-V assembly programming and machine language translation.

Uploaded by

rosiesandra086
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Assignment on RISC-V

1. Write down the RISC-V assembly code to add ‘b’, ‘c’ and store in ‘a’.
2. Write down the RISC-V assembly code to subtract ‘c’ from ‘b’ and store in ‘a’.
3. Write down the RISC-V assembly code to implement a=b+c-d.
4. Translate the following high-level code into RISC-V assembly language. Assume
variables a-h are held in registers s0-s7.
a= b - c;
d=(e+f) - (g+h);
5. Translate the following I-type assembly instruction into machine language.
add x18, x19, x20
sub x5, x6, x7
6. Translate the following I-type assembly instruction into machine language.
s11 x23, x5, x9
xor x24, x25, x26
add x28, x20, x21
7. Translate the following I-type assembly instruction into machine language.
lw x28, −36(x20)
8. Translate the following I-type assembly instruction into machine language.
addi x8, x9, x12
addi x18, x6, -14
lw x7, -6(x19)
lb x20, ox1F (x20)
s11i x18, x23, 5
sari x6, x7, 29
9. Translate the following S-type assembly instruction into machine language.
sw x7, -6(x19)
sh x20, 23(x5)
sb x30, 0x2D(x0)
10. Translate the following B-type assembly instruction into machine language.
beq x8, x30, 16
bne x24, x25, L1
11. Translate the following U-type assembly instruction into machine language.
lui x21, 0x8CDEF
12. Translate the following J-type assembly instruction into machine language.
jal x1, 0xA67F8

You might also like