0% found this document useful (0 votes)
68 views

Lab RISC-V

The document summarizes a laboratory activity on RISC-V control transfer and multiplication. It includes questions about RISC-V assembly code instructions and operations, as well as programming exercises to write RISC-V assembly code to perform calculations like addition, multiplication, division, perimeter and area computations. Students are asked to provide the assembly code and screenshots demonstrating it works.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

Lab RISC-V

The document summarizes a laboratory activity on RISC-V control transfer and multiplication. It includes questions about RISC-V assembly code instructions and operations, as well as programming exercises to write RISC-V assembly code to perform calculations like addition, multiplication, division, perimeter and area computations. Students are asked to provide the assembly code and screenshots demonstrating it works.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

De La Salle University

Computer Technology Department

Laboratory for Computer Organization and Architecture

Laboratory Activity #10: RISCV Control Transfer and Multiplication

Members Date
Performed

Question and Answer:

Answer Question

ADDI x11, x0, 0xFFFFF888


ADDI x12, x0, 0x00000777
BGT x11, x12, L1
J L2
L1: NOP
L2: NOP
Will conditional jump to L1?
a. No
b. Yes
c. None of the above

ADD x10, x0, x0


ADDI x11, x0, 0xFFFFF888
ADDI x12, x0, 0x00000777
JAL x1, L1

L1: ADDI x10, x0, 0x00000002


JALR x0, 0(x1)
What will x10 contain after execution?

ADDI x11, x0, 0xFFFFF888


JAL x0, L2
L1: ADDI x11, x0, 0x00000001
L2: ADDI x11, x0, 0x00000002

What will x11 contain after execution?

addi x10, x0, 0x64


xor x11, x12, x12
divu x12, x10, x11
remu x13, x10, x11
What will x13 contain after execution?

lui x10, 0xF0000


addi x11, x0, 0x05
mul x12, x10, x11
mulhu x13, x10, x11

What will x13 contain after execution?

lui x10, 0xF0000


addi x11, x0, 0x05
mul x12, x10, x11
mulh x13, x10, x11

What will x12 contain after execution?

addi x10, x0, 100


xor x11, x12, x12
div x12, x10, x11
rem x13, x10, x11

What will x12 contain after execution?

addi x10, x0, 100


xor x11, x12, x12
div x12, x10, x11
rem x13, x10, x11

What will x13 contain after execution?

addi x10, x0, +3


addi x11, x0, +4
mul x12, x10, x11
mulhsu x13, x10, x11

What will x13 contain after execution?

addi x10, x0, -3


addi x11, x0, -4
mul x12, x10, x11
mulhsu x13, x10, x11

What will x12 contain after execution?

lui x10, 0x70000


addi x11, x0, 0x05
mul x12, x10, x11
mulh x13, x10, x11

What will x12 contain after execution?


addi x10, x0, 100
addi x11, x0, 3
div x12, x10, x11
rem x13, x10, x11

What will x12 contain after execution?

addi x10, x0, 0x64


xor x11, x12, x12
divu x12, x10, x11
remu x13, x10, x11

What will x12 contain after execution?

addi x10, x0, 0x64


addi x11, x0, 0x03
divu x12, x10, x11
rem x13, x10, x11

What will x13 contain after execution?

addi x10, x0, -3


addi x11, x0, +4
mul x12, x10, x11
mulhsu x13, x10, x11

What will x13 contain after execution?

addi x10, x0, -3


addi x11, x0, -4
mul x12, x10, x11
mulhsu x13, x10, x11

What will x13 contain after execution?

lui x10, 0x80000


addi x11, x0, -1
div x12, x10, x11
rem x13, x10, x11

What will x13 contain after execution?

addi x10, x0, -3


addi x11, x0, +4
mul x12, x10, x11
mulhsu x13, x10, x11

What will x12 contain after execution?

Programming Exercises:
Place your code on the box provided. Provide a screenshot that your code works.

1. Write a program that asks for two signed decimal inputs then display the sum,
difference, product, quotient, and remainder of the two numbers. Should support output
value up to +/- (231-1). Provide a screenshot with a test case demonstrating that your
code works.

RISCV assembly code

Screenshot

2. Write a RISC-V program to compute for the perimeter and area of a square. The side of
the square is obtained from the input prompt. Output the required result. There should
be an error check for negative input. Support output value up to 232 -1. Provide a
screenshot with a test case demonstrating that your code works.

Enter length: 20
Perimeter: 80
Area: 400
-----------
Enter length: -20
Error: Negative input not allowed, please try again.
Enter length: 2
Perimeter: 8
Area: 4

RISCV assembly code

Screenshot

3. Write a program that computes the arithmetic mean of N input numbers. N is provided as
an input that precedes the numbers to be averaged. Provide a screenshot with a test
case demonstrating that your code works.

N: 4
3
7
3
7
Mean: 5

RISCV assembly code

Screenshot

You might also like